Search in sources :

Example 31 with ImmutableMultimap

use of org.apache.beam.vendor.calcite.v1_28_0.com.google.common.collect.ImmutableMultimap in project graylog2-server by Graylog2.

the class EntityDependencyPermissionChecker method check.

/**
 * Runs permission checks for the given dependencies for every selected grantee and returns the entities that
 * grantees cannot access.
 *
 * @param sharingUser      the sharing user
 * @param dependencies     the dependencies to check
 * @param selectedGrantees the selected grantees
 * @return dependencies that grantees cannot access, grouped by grantee
 */
public ImmutableMultimap<GRN, EntityDescriptor> check(GRN sharingUser, ImmutableSet<EntityDescriptor> dependencies, Set<GRN> selectedGrantees) {
    final ImmutableMultimap.Builder<GRN, EntityDescriptor> deniedDependencies = ImmutableMultimap.builder();
    final GranteeAuthorizer sharerAuthorizer = granteeAuthorizerFactory.create(sharingUser);
    for (final GRN grantee : selectedGrantees) {
        // We only check for existing grants for the actual grantee. If the grantee is a team, we only check if
        // the team has a grant, not if any users in the team can access the dependency via other grants.
        // The same for the "everyone" grantee, we only check if  the "everyone" grantee has access to a dependency.
        final GranteeAuthorizer granteeAuthorizer = granteeAuthorizerFactory.create(grantee);
        for (final EntityDescriptor dependency : dependencies) {
            // leaking information to the sharing user.
            if (cannotView(sharerAuthorizer, dependency)) {
                continue;
            }
            if (cannotView(granteeAuthorizer, dependency)) {
                deniedDependencies.put(grantee, dependency);
            }
        }
    }
    return deniedDependencies.build();
}
Also used : GRN(org.graylog.grn.GRN) GranteeAuthorizer(org.graylog.security.GranteeAuthorizer) ImmutableMultimap(com.google.common.collect.ImmutableMultimap)

Aggregations

ImmutableMultimap (com.google.common.collect.ImmutableMultimap)30 Path (java.nio.file.Path)9 ImmutableMap (com.google.common.collect.ImmutableMap)8 ImmutableSet (com.google.common.collect.ImmutableSet)7 Map (java.util.Map)6 BuildTarget (com.facebook.buck.model.BuildTarget)4 ImmutableList (com.google.common.collect.ImmutableList)4 SourcePath (com.facebook.buck.rules.SourcePath)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)3 Multimap (com.google.common.collect.Multimap)3 IOException (java.io.IOException)3 List (java.util.List)3 ClasspathTraversal (com.facebook.buck.jvm.java.classes.ClasspathTraversal)2 ClasspathTraverser (com.facebook.buck.jvm.java.classes.ClasspathTraverser)2 DefaultClasspathTraverser (com.facebook.buck.jvm.java.classes.DefaultClasspathTraverser)2 FileLike (com.facebook.buck.jvm.java.classes.FileLike)2 UnflavoredBuildTarget (com.facebook.buck.model.UnflavoredBuildTarget)2 Column (com.facebook.presto.hive.metastore.Column)2 ExtendedHiveMetastore (com.facebook.presto.hive.metastore.ExtendedHiveMetastore)2 HivePrivilegeInfo (com.facebook.presto.hive.metastore.HivePrivilegeInfo)2