diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 3e4e2b7e9b..797b3f81cf 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,3 +6,7 @@ updates: interval: "weekly" commit-message: prefix: "dependabot:" + ignore: + # For all packages, ignore all major versions to minimize breaking issues + - dependency-name: "*" + update-types: ["version-update:semver-major"] diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index ab835cbe9a..6472a968d8 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -7,6 +7,7 @@ on: jobs: backport: + if: github.event.pull_request.merged == true runs-on: ubuntu-latest permissions: contents: write @@ -25,6 +26,5 @@ jobs: uses: VachaShah/backport@v2.2.0 with: github_token: ${{ steps.github_app_token.outputs.token }} - branch_name: backport/backport-${{ github.event.number }} head_template: backport/backport-<%= number %>-to-<%= base %> failure_labels: backport-failed diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a6cd5b141..66919ab87e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -126,11 +126,11 @@ jobs: - uses: actions/setup-java@v1 with: java-version: 11 - - uses: github/codeql-action/init@v1 + - uses: github/codeql-action/init@v2 with: languages: java - - run: ./gradlew clean build -Dbuild.snapshot=false -x test -x integrationTest - - uses: github/codeql-action/analyze@v1 + - run: ./gradlew clean assemble + - uses: github/codeql-action/analyze@v2 build-artifact-names: runs-on: ubuntu-latest diff --git a/build.gradle b/build.gradle index a22a044ba0..442cd414ad 100644 --- a/build.gradle +++ b/build.gradle @@ -61,7 +61,7 @@ plugins { id 'idea' id 'jacoco' id 'maven-publish' - id 'com.diffplug.spotless' version '6.19.0' + id 'com.diffplug.spotless' version '6.20.0' id 'checkstyle' id 'com.netflix.nebula.ospackage' version "11.3.0" id "org.gradle.test-retry" version "1.5.4" @@ -420,7 +420,7 @@ configurations { resolutionStrategy { force 'commons-codec:commons-codec:1.16.0' force 'org.slf4j:slf4j-api:1.7.30' - force 'org.scala-lang:scala-library:2.13.9' + force 'org.scala-lang:scala-library:2.13.11' force "com.fasterxml.jackson:jackson-bom:${versions.jackson}" force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}" force "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${versions.jackson}" @@ -432,7 +432,7 @@ configurations { force "io.netty:netty-transport-native-unix-common:${versions.netty}" force "org.apache.bcel:bcel:6.7.0" // This line should be removed once Spotbugs is upgraded to 4.7.4 force "com.github.luben:zstd-jni:${versions.zstd}" - force "org.xerial.snappy:snappy-java:1.1.10.1" + force "org.xerial.snappy:snappy-java:1.1.10.3" force "com.google.guava:guava:${guava_version}" } } @@ -511,7 +511,7 @@ dependencies { //JSON path implementation 'com.jayway.jsonpath:json-path:2.8.0' - implementation 'net.minidev:json-smart:2.4.11' + implementation 'net.minidev:json-smart:2.5.0' implementation "org.apache.kafka:kafka-clients:${kafka_version}" @@ -565,7 +565,7 @@ dependencies { runtimeOnly 'io.dropwizard.metrics:metrics-core:4.2.19' runtimeOnly 'org.slf4j:slf4j-api:1.7.30' runtimeOnly "org.apache.logging.log4j:log4j-slf4j-impl:${versions.log4j}" - runtimeOnly 'org.xerial.snappy:snappy-java:1.1.10.1' + runtimeOnly 'org.xerial.snappy:snappy-java:1.1.10.3' runtimeOnly 'org.codehaus.woodstox:stax2-api:4.2.1' runtimeOnly "org.glassfish.jaxb:txw2:${jaxb_version}" runtimeOnly 'com.fasterxml.woodstox:woodstox-core:6.4.0' @@ -614,7 +614,7 @@ dependencies { testRuntimeOnly ('org.springframework:spring-core:5.3.27') { exclude(group:'org.springframework', module: 'spring-jcl' ) } - testRuntimeOnly 'org.scala-lang:scala-library:2.13.9' + testRuntimeOnly 'org.scala-lang:scala-library:2.13.11' testRuntimeOnly 'com.yammer.metrics:metrics-core:2.2.0' testRuntimeOnly 'com.typesafe.scala-logging:scala-logging_3:3.9.5' testRuntimeOnly 'org.apache.zookeeper:zookeeper:3.7.1' @@ -627,7 +627,7 @@ dependencies { compileOnly "org.opensearch:opensearch:${opensearch_version}" //integration test framework: - integrationTestImplementation('com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.7.1') { + integrationTestImplementation('com.carrotsearch.randomizedtesting:randomizedtesting-runner:2.8.1') { exclude(group: 'junit', module: 'junit') } integrationTestImplementation 'junit:junit:4.13.2' diff --git a/scripts/integtest.sh b/scripts/integtest.sh index 0401d00fa0..98ee40fbd6 100755 --- a/scripts/integtest.sh +++ b/scripts/integtest.sh @@ -20,7 +20,6 @@ function usage() { echo -e "-v OPENSEARCH_VERSION\t, no defaults" echo -e "-n SNAPSHOT\t, defaults to false" echo -e "-m CLUSTER_NAME\t, defaults to docker-cluster" - echo -e "-u COMMON_UTILS_VERSION\t, defaults to 3.0.0.0-SNAPSHOT" echo "--------------------------------------------------------------------------" } @@ -99,12 +98,8 @@ if [ -z "$CLUSTER_NAME" ] then CLUSTER_NAME="docker-cluster" fi -if [ -z "$COMMON_UTILS_VERSION" ] -then - COMMON_UTILS_VERSION="3.0.0.0-SNAPSHOT" -fi USERNAME=`echo $CREDENTIAL | awk -F ':' '{print $1}'` PASSWORD=`echo $CREDENTIAL | awk -F ':' '{print $2}'` -./gradlew integTestRemote -Dtests.rest.cluster="$BIND_ADDRESS:$BIND_PORT" -Dtests.cluster="$BIND_ADDRESS:$BIND_PORT" -Dsecurity_enabled=$SECURITY_ENABLED -Dtests.clustername=$CLUSTER_NAME -Dhttps=true -Duser=$USERNAME -Dpassword=$PASSWORD -Dcommon_utils.version=$COMMON_UTILS_VERSION +./gradlew integTestRemote -Dtests.rest.cluster="$BIND_ADDRESS:$BIND_PORT" -Dtests.cluster="$BIND_ADDRESS:$BIND_PORT" -Dsecurity_enabled=$SECURITY_ENABLED -Dtests.clustername=$CLUSTER_NAME -Dhttps=true -Duser=$USERNAME -Dpassword=$PASSWORD diff --git a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java index b05b29657d..3ac120b35a 100644 --- a/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java +++ b/src/main/java/org/opensearch/security/privileges/PrivilegesEvaluator.java @@ -38,7 +38,6 @@ import java.util.regex.Pattern; import com.google.common.collect.ImmutableSet; -import com.google.common.collect.Sets; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.greenrobot.eventbus.Subscribe; @@ -202,12 +201,12 @@ public boolean isInitialized() { return configModel != null && configModel.getSecurityRoles() != null && dcm != null; } - private void setUserInfoInThreadContext(User user, Set mappedRoles) { + private void setUserInfoInThreadContext(User user) { if (threadContext.getTransient(OPENDISTRO_SECURITY_USER_INFO_THREAD_CONTEXT) == null) { StringJoiner joiner = new StringJoiner("|"); joiner.add(user.getName()); joiner.add(String.join(",", user.getRoles())); - joiner.add(String.join(",", Sets.union(user.getSecurityRoles(), mappedRoles))); + joiner.add(String.join(",", user.getSecurityRoles())); String requestedTenant = user.getRequestedTenant(); if (!Strings.isNullOrEmpty(requestedTenant)) { joiner.add(requestedTenant); @@ -260,9 +259,9 @@ public PrivilegesEvaluatorResponse evaluate( presponse.resolvedSecurityRoles.addAll(mappedRoles); final SecurityRoles securityRoles = getSecurityRoles(mappedRoles); - setUserInfoInThreadContext(user, mappedRoles); // Add the security roles for this user so that they can be used for DLS parameter substitution. user.addSecurityRoles(mappedRoles); + setUserInfoInThreadContext(user); final boolean isDebugEnabled = log.isDebugEnabled(); if (isDebugEnabled) { diff --git a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java index 5a175f57f7..344b7cddc2 100644 --- a/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java +++ b/src/test/java/org/opensearch/security/test/helper/cluster/ClusterHelper.java @@ -319,14 +319,12 @@ private void deleteTestsDataDirectory() throws IOException { Files.walkFileTree(testsDataDir.toPath(), new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - System.out.println("Deleting file " + file.getFileName()); Files.delete(file); return FileVisitResult.CONTINUE; } @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { - System.out.println("Deleting directory " + dir.getFileName()); Files.delete(dir); return FileVisitResult.CONTINUE; }