Skip to content

Commit 190bfec

Browse files
committed
Merge branch 'main' of github.com:opensearch-project/security into HEAD
2 parents e255e14 + c84caef commit 190bfec

File tree

51 files changed

+1461
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1461
-195
lines changed

.github/actions/run-bwc-suite/action.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ runs:
5050
-Dbwc.version.previous=${{ steps.build-previous.outputs.built-version }}
5151
-Dbwc.version.next=${{ steps.build-next.outputs.built-version }} -i
5252
53-
- uses: alehechka/upload-tartifact@v2
53+
- uses: actions/upload-artifact@v4
5454
if: always()
5555
with:
5656
name: ${{ inputs.report-artifact-name }}

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ jobs:
8181
working-directory: downloaded-artifacts
8282

8383
- name: Upload Coverage with retry
84-
uses: Wandalen/wretry.action@v3.7.3
84+
uses: Wandalen/wretry.action@v3.8.0
8585
with:
8686
attempt_limit: 5
8787
attempt_delay: 2000

.github/workflows/integration-tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- run: OPENDISTRO_SECURITY_TEST_OPENSSL_OPT=true ./gradlew test
2626

27-
- uses: alehechka/upload-tartifact@v2
27+
- uses: actions/upload-artifact@v4
2828
if: always()
2929
with:
3030
name: ${{ matrix.jdk }}-${{ matrix.test-run }}-reports

build.gradle

+15-15
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ plugins {
6464
id 'maven-publish'
6565
id 'com.diffplug.spotless' version '6.25.0'
6666
id 'checkstyle'
67-
id 'com.netflix.nebula.ospackage' version "11.10.0"
67+
id 'com.netflix.nebula.ospackage' version "11.10.1"
6868
id "org.gradle.test-retry" version "1.6.0"
6969
id 'eclipse'
7070
id "com.github.spotbugs" version "5.2.5"
@@ -469,9 +469,9 @@ bundlePlugin {
469469
configurations {
470470
all {
471471
resolutionStrategy {
472-
force 'commons-codec:commons-codec:1.17.1'
472+
force 'commons-codec:commons-codec:1.17.2'
473473
force 'org.slf4j:slf4j-api:1.7.36'
474-
force 'org.scala-lang:scala-library:2.13.15'
474+
force 'org.scala-lang:scala-library:2.13.16'
475475
force "com.fasterxml.jackson:jackson-bom:${versions.jackson}"
476476
force "com.fasterxml.jackson.core:jackson-core:${versions.jackson}"
477477
force "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:${versions.jackson}"
@@ -496,8 +496,8 @@ configurations {
496496
force "org.apache.httpcomponents:httpclient:4.5.14"
497497
force "org.apache.httpcomponents:httpcore:4.4.16"
498498
force "com.google.errorprone:error_prone_annotations:2.36.0"
499-
force "org.checkerframework:checker-qual:3.48.3"
500-
force "ch.qos.logback:logback-classic:1.5.12"
499+
force "org.checkerframework:checker-qual:3.48.4"
500+
force "ch.qos.logback:logback-classic:1.5.16"
501501
force "commons-io:commons-io:2.18.0"
502502
}
503503
}
@@ -585,7 +585,7 @@ dependencies {
585585
implementation 'commons-cli:commons-cli:1.9.0'
586586
implementation "org.bouncycastle:bcprov-jdk18on:${versions.bouncycastle}"
587587
implementation 'org.ldaptive:ldaptive:1.2.3'
588-
implementation 'com.nimbusds:nimbus-jose-jwt:9.47'
588+
implementation 'com.nimbusds:nimbus-jose-jwt:9.48'
589589
implementation 'com.rfksystems:blake2b:2.0.0'
590590
implementation 'com.password4j:password4j:1.8.2'
591591

@@ -609,14 +609,14 @@ dependencies {
609609

610610
runtimeOnly 'com.sun.activation:jakarta.activation:1.2.2'
611611
runtimeOnly 'com.eclipsesource.minimal-json:minimal-json:0.9.5'
612-
runtimeOnly 'commons-codec:commons-codec:1.17.1'
612+
runtimeOnly 'commons-codec:commons-codec:1.17.2'
613613
runtimeOnly 'org.cryptacular:cryptacular:1.2.7'
614614
compileOnly 'com.google.errorprone:error_prone_annotations:2.36.0'
615615
runtimeOnly 'com.sun.istack:istack-commons-runtime:4.2.0'
616616
runtimeOnly 'jakarta.xml.bind:jakarta.xml.bind-api:4.0.2'
617617
runtimeOnly 'org.ow2.asm:asm:9.7.1'
618618

619-
testImplementation 'org.apache.camel:camel-xmlsecurity:3.22.2'
619+
testImplementation 'org.apache.camel:camel-xmlsecurity:3.22.3'
620620

621621
//OpenSAML
622622
implementation 'net.shibboleth.utilities:java-support:8.4.2'
@@ -653,9 +653,9 @@ dependencies {
653653
runtimeOnly "org.glassfish.jaxb:txw2:${jaxb_version}"
654654
runtimeOnly 'com.fasterxml.woodstox:woodstox-core:6.7.0'
655655
runtimeOnly 'org.apache.ws.xmlschema:xmlschema-core:2.3.1'
656-
runtimeOnly 'org.apache.santuario:xmlsec:2.3.4'
656+
runtimeOnly 'org.apache.santuario:xmlsec:2.3.5'
657657
runtimeOnly "com.github.luben:zstd-jni:${versions.zstd}"
658-
runtimeOnly 'org.checkerframework:checker-qual:3.48.3'
658+
runtimeOnly 'org.checkerframework:checker-qual:3.48.4'
659659
runtimeOnly "org.bouncycastle:bcpkix-jdk18on:${versions.bouncycastle}"
660660
runtimeOnly 'org.scala-lang.modules:scala-java8-compat_3:1.0.2'
661661

@@ -686,10 +686,10 @@ dependencies {
686686
testImplementation "org.apache.kafka:kafka_2.13:${kafka_version}:test"
687687
testImplementation "org.apache.kafka:kafka-clients:${kafka_version}:test"
688688
testImplementation 'commons-validator:commons-validator:1.9.0'
689-
testImplementation 'org.springframework.kafka:spring-kafka-test:3.3.0'
689+
testImplementation 'org.springframework.kafka:spring-kafka-test:3.3.1'
690690
testImplementation "org.springframework:spring-beans:${spring_version}"
691-
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.3'
692-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
691+
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
692+
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.4'
693693
testImplementation('org.awaitility:awaitility:4.2.2') {
694694
exclude(group: 'org.hamcrest', module: 'hamcrest')
695695
}
@@ -708,7 +708,7 @@ dependencies {
708708
testRuntimeOnly ("org.springframework:spring-core:${spring_version}") {
709709
exclude(group:'org.springframework', module: 'spring-jcl' )
710710
}
711-
testRuntimeOnly 'org.scala-lang:scala-library:2.13.15'
711+
testRuntimeOnly 'org.scala-lang:scala-library:2.13.16'
712712
testRuntimeOnly 'com.typesafe.scala-logging:scala-logging_3:3.9.5'
713713
testRuntimeOnly('org.apache.zookeeper:zookeeper:3.9.3') {
714714
exclude(group:'ch.qos.logback', module: 'logback-classic' )
@@ -746,7 +746,7 @@ dependencies {
746746
integrationTestImplementation "org.apache.httpcomponents:fluent-hc:4.5.14"
747747
integrationTestImplementation "org.apache.httpcomponents:httpcore:4.4.16"
748748
integrationTestImplementation "org.apache.httpcomponents:httpasyncclient:4.1.5"
749-
integrationTestImplementation "org.mockito:mockito-core:5.14.2"
749+
integrationTestImplementation "org.mockito:mockito-core:5.15.2"
750750

751751
//spotless
752752
implementation('com.google.googlejavaformat:google-java-format:1.25.2') {

gradle/wrapper/gradle-wrapper.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionSha256Sum=f397b287023acdba1e9f6fc5ea72d22dd63669d59ed4a289a29b1a76eee151c6
4-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
3+
distributionSha256Sum=7a00d51fb93147819aab76024feece20b6b84e420694101f276be952e08bef03
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
55
networkTimeout=10000
66
validateDistributionUrl=true
77
zipStoreBase=GRADLE_USER_HOME

src/integrationTest/java/org/opensearch/security/DoNotFailOnForbiddenTests.java

+10-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.BufferedReader;
1313
import java.io.IOException;
1414
import java.io.InputStreamReader;
15+
import java.nio.charset.StandardCharsets;
1516
import java.util.List;
1617
import java.util.stream.Collectors;
1718

@@ -462,8 +463,9 @@ public void shouldPerformCatIndices_positive() throws IOException {
462463
Request getIndicesRequest = new Request("GET", "/_cat/indices");
463464
// High level client doesn't support _cat/_indices API
464465
Response getIndicesResponse = restHighLevelClient.getLowLevelClient().performRequest(getIndicesRequest);
465-
List<String> indexes = new BufferedReader(new InputStreamReader(getIndicesResponse.getEntity().getContent())).lines()
466-
.collect(Collectors.toList());
466+
List<String> indexes = new BufferedReader(
467+
new InputStreamReader(getIndicesResponse.getEntity().getContent(), StandardCharsets.UTF_8)
468+
).lines().collect(Collectors.toList());
467469

468470
assertThat(indexes.size(), equalTo(1));
469471
assertThat(indexes.get(0), containsString("marvelous_songs"));
@@ -476,8 +478,9 @@ public void shouldPerformCatAliases_positive() throws IOException {
476478
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(LIMITED_USER)) {
477479
Request getAliasesRequest = new Request("GET", "/_cat/aliases");
478480
Response getAliasesResponse = restHighLevelClient.getLowLevelClient().performRequest(getAliasesRequest);
479-
List<String> aliases = new BufferedReader(new InputStreamReader(getAliasesResponse.getEntity().getContent())).lines()
480-
.collect(Collectors.toList());
481+
List<String> aliases = new BufferedReader(
482+
new InputStreamReader(getAliasesResponse.getEntity().getContent(), StandardCharsets.UTF_8)
483+
).lines().collect(Collectors.toList());
481484

482485
// Does not fail on forbidden, but alias response only contains index which user has access to
483486
assertThat(getAliasesResponse.getStatusLine().getStatusCode(), equalTo(200));
@@ -490,8 +493,9 @@ public void shouldPerformCatAliases_positive() throws IOException {
490493
try (RestHighLevelClient restHighLevelClient = cluster.getRestHighLevelClient(ADMIN_USER)) {
491494
Request getAliasesRequest = new Request("GET", "/_cat/aliases");
492495
Response getAliasesResponse = restHighLevelClient.getLowLevelClient().performRequest(getAliasesRequest);
493-
List<String> aliases = new BufferedReader(new InputStreamReader(getAliasesResponse.getEntity().getContent())).lines()
494-
.collect(Collectors.toList());
496+
List<String> aliases = new BufferedReader(
497+
new InputStreamReader(getAliasesResponse.getEntity().getContent(), StandardCharsets.UTF_8)
498+
).lines().collect(Collectors.toList());
495499

496500
// Admin has access to all
497501
assertThat(getAliasesResponse.getStatusLine().getStatusCode(), equalTo(200));

src/integrationTest/java/org/opensearch/security/ThreadPoolTests.java

-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.opensearch.common.xcontent.XContentFactory;
2222
import org.opensearch.core.rest.RestStatus;
2323
import org.opensearch.core.xcontent.XContentBuilder;
24-
import org.opensearch.security.http.ExampleSystemIndexPlugin;
2524
import org.opensearch.test.framework.TestSecurityConfig.AuthcDomain;
2625
import org.opensearch.test.framework.cluster.ClusterManager;
2726
import org.opensearch.test.framework.cluster.LocalCluster;
@@ -47,7 +46,6 @@ public class ThreadPoolTests {
4746
.anonymousAuth(false)
4847
.authc(AUTHC_DOMAIN)
4948
.users(USER_ADMIN)
50-
.plugin(ExampleSystemIndexPlugin.class)
5149
.nodeSettings(Map.of(SECURITY_RESTAPI_ROLES_ENABLED, List.of("user_" + USER_ADMIN.getName() + "__" + ALL_ACCESS.getName())))
5250
.build();
5351

src/integrationTest/java/org/opensearch/security/http/ExampleSystemIndexPlugin.java

-27
This file was deleted.

src/integrationTest/java/org/opensearch/security/privileges/ActionPrivilegesTest.java

+39-1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,28 @@ public void wildcard() throws Exception {
126126
);
127127
}
128128

129+
@Test
130+
public void wildcardByUsername() throws Exception {
131+
SecurityDynamicConfiguration<RoleV7> roles = SecurityDynamicConfiguration.empty(CType.ROLES);
132+
133+
ActionPrivileges subject = new ActionPrivileges(
134+
roles,
135+
FlattenedActionGroups.EMPTY,
136+
null,
137+
Settings.EMPTY,
138+
Map.of("plugin:org.opensearch.sample.SamplePlugin", Set.of("*"))
139+
);
140+
141+
assertThat(
142+
subject.hasClusterPrivilege(ctxByUsername("plugin:org.opensearch.sample.SamplePlugin"), "cluster:whatever"),
143+
isAllowed()
144+
);
145+
assertThat(
146+
subject.hasClusterPrivilege(ctx("plugin:org.opensearch.other.OtherPlugin"), "cluster:whatever"),
147+
isForbidden(missingPrivileges("cluster:whatever"))
148+
);
149+
}
150+
129151
@Test
130152
public void explicit_wellKnown() throws Exception {
131153
SecurityDynamicConfiguration<RoleV7> roles = SecurityDynamicConfiguration.fromYaml("non_explicit_role:\n" + //
@@ -455,7 +477,8 @@ public IndicesAndAliases(IndexSpec indexSpec, ActionSpec actionSpec, Statefulnes
455477
settings,
456478
WellKnownActions.CLUSTER_ACTIONS,
457479
WellKnownActions.INDEX_ACTIONS,
458-
WellKnownActions.INDEX_ACTIONS
480+
WellKnownActions.INDEX_ACTIONS,
481+
Map.of()
459482
);
460483

461484
if (statefulness == Statefulness.STATEFUL || statefulness == Statefulness.STATEFUL_LIMITED) {
@@ -1030,4 +1053,19 @@ static PrivilegesEvaluationContext ctx(String... roles) {
10301053
null
10311054
);
10321055
}
1056+
1057+
static PrivilegesEvaluationContext ctxByUsername(String username) {
1058+
User user = new User(username);
1059+
user.addAttributes(ImmutableMap.of("attrs.dept_no", "a11"));
1060+
return new PrivilegesEvaluationContext(
1061+
user,
1062+
ImmutableSet.of(),
1063+
null,
1064+
null,
1065+
null,
1066+
null,
1067+
new IndexNameExpressionResolver(new ThreadContext(Settings.EMPTY)),
1068+
null
1069+
);
1070+
}
10331071
}

0 commit comments

Comments
 (0)