Skip to content

Commit 12dff37

Browse files
committed
Support phasing off SecurityManager usage in favor of Java Agent
Signed-off-by: Gulshan <[email protected]>
1 parent e4cbf79 commit 12dff37

File tree

7 files changed

+109
-0
lines changed

7 files changed

+109
-0
lines changed

build.gradle

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,16 @@ allprojects {
8383
}
8484

8585
project.getExtensions().getExtraProperties().set("versions", VersionProperties.getVersions());
86+
}
87+
88+
configurations {
89+
agent
90+
}
8691

92+
dependencies {
93+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
94+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
95+
agent "net.bytebuddy:byte-buddy:1.17.5"
8796
}
8897

8998
subprojects {
@@ -115,3 +124,13 @@ task updateVersion {
115124
ant.replaceregexp(file:'build.gradle', match: '"opensearch.version", "\\d.*"', replace: '"opensearch.version", "' + newVersion.tokenize('-')[0] + '-SNAPSHOT"', flags:'g', byline:true)
116125
}
117126
}
127+
128+
task prepareAgent(type: Copy) {
129+
from(configurations.agent)
130+
into "$buildDir/agent"
131+
}
132+
133+
tasks.withType(Test) {
134+
dependsOn prepareAgent
135+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
136+
}

common/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ plugins {
1414
id 'signing'
1515
}
1616

17+
configurations {
18+
agent
19+
}
20+
1721
dependencies {
1822
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
1923
compileOnly group: 'org.reflections', name: 'reflections', version: '0.9.12'
@@ -44,6 +48,10 @@ dependencies {
4448
compileOnly group: 'com.networknt' , name: 'json-schema-validator', version: '1.4.0'
4549
// Multi-tenant SDK Client
4650
compileOnly "org.opensearch:opensearch-remote-metadata-sdk:${opensearch_build}"
51+
52+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
53+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
54+
agent "net.bytebuddy:byte-buddy:1.17.5"
4755
}
4856

4957
lombok {
@@ -157,3 +165,13 @@ publishing {
157165
}
158166
}
159167
publishShadowPublicationToMavenLocal.mustRunAfter shadowJar
168+
169+
task prepareAgent(type: Copy) {
170+
from(configurations.agent)
171+
into "$buildDir/agent"
172+
}
173+
174+
tasks.withType(Test) {
175+
dependsOn prepareAgent
176+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
177+
}

memory/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ plugins {
2323
id 'com.diffplug.spotless' version '6.25.0'
2424
}
2525

26+
configurations {
27+
agent
28+
}
29+
2630
dependencies {
2731
implementation project(path: ":${rootProject.name}-common", configuration: 'shadow')
2832
implementation group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
@@ -47,6 +51,10 @@ dependencies {
4751
exclude group: 'net.minidev', module: 'json-smart'
4852
}
4953
testImplementation('net.minidev:json-smart:2.5.2')
54+
55+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
56+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
57+
agent "net.bytebuddy:byte-buddy:1.17.5"
5058
}
5159

5260
test {
@@ -90,3 +98,13 @@ spotless {
9098
eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('.eclipseformat.xml')
9199
}
92100
}
101+
102+
task prepareAgent(type: Copy) {
103+
from(configurations.agent)
104+
into "$buildDir/agent"
105+
}
106+
107+
tasks.withType(Test) {
108+
dependsOn prepareAgent
109+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
110+
}

ml-algorithms/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ repositories {
1717
mavenCentral()
1818
}
1919

20+
configurations {
21+
agent
22+
}
23+
2024
dependencies {
2125
implementation project(path: ":${rootProject.name}-spi", configuration: 'shadow')
2226
implementation project(path: ":${rootProject.name}-common", configuration: 'shadow')
@@ -88,6 +92,10 @@ dependencies {
8892
testImplementation("com.fasterxml.jackson.core:jackson-annotations:${versions.jackson}")
8993
testImplementation("com.fasterxml.jackson.core:jackson-databind:${versions.jackson_databind}")
9094
testImplementation group: 'com.networknt' , name: 'json-schema-validator', version: '1.4.0'
95+
96+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
97+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
98+
agent "net.bytebuddy:byte-buddy:1.17.5"
9199
}
92100

93101
lombok {
@@ -144,3 +152,13 @@ spotless {
144152
eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('.eclipseformat.xml')
145153
}
146154
}
155+
156+
task prepareAgent(type: Copy) {
157+
from(configurations.agent)
158+
into "$buildDir/agent"
159+
}
160+
161+
tasks.withType(Test) {
162+
dependsOn prepareAgent
163+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
164+
}

plugin/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ opensearchplugin {
4949

5050
configurations {
5151
zipArchive
52+
agent
5253
}
5354

5455
dependencies {
@@ -94,6 +95,10 @@ dependencies {
9495
exclude group: 'net.minidev', module: 'json-smart'
9596
}
9697
implementation('net.minidev:json-smart:2.5.2')
98+
99+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
100+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
101+
agent "net.bytebuddy:byte-buddy:1.17.5"
97102
}
98103

99104
publishing {
@@ -651,3 +656,13 @@ forbiddenPatterns {
651656
exclude '**/*.pdf'
652657
exclude '**/*.jpg'
653658
}
659+
660+
task prepareAgent(type: Copy) {
661+
from(configurations.agent)
662+
into "$buildDir/agent"
663+
}
664+
665+
tasks.withType(Test) {
666+
dependsOn prepareAgent
667+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
668+
}

plugin/src/main/plugin-metadata/plugin-security.policy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ grant {
1212
// Register model
1313
permission java.net.SocketPermission "*", "connect,resolve";
1414

15+
// for accessing Unix domain socket on windows
16+
permission java.net.NetPermission "accessUnixDomainSocket";
17+
1518
// Deploy model
1619
permission java.lang.RuntimePermission "createClassLoader";
1720
permission java.lang.RuntimePermission "loadLibrary.*";

search-processors/build.gradle

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ repositories {
2727
mavenLocal()
2828
}
2929

30+
configurations {
31+
agent
32+
}
33+
3034
dependencies {
3135
implementation project(path: ":${rootProject.name}-common", configuration: 'shadow')
3236
compileOnly group: 'org.opensearch', name: 'opensearch', version: "${opensearch_version}"
@@ -42,6 +46,10 @@ dependencies {
4246
implementation group: 'org.json', name: 'json', version: '20231013'
4347
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
4448
testImplementation "org.opensearch.test:framework:${opensearch_version}"
49+
50+
agent "org.opensearch:opensearch-agent-bootstrap:${opensearch_version}"
51+
agent "org.opensearch:opensearch-agent:${opensearch_version}"
52+
agent "net.bytebuddy:byte-buddy:1.17.5"
4553
}
4654

4755
test {
@@ -83,3 +91,13 @@ spotless {
8391
eclipse().withP2Mirrors(Map.of("https://download.eclipse.org/", "https://mirror.umd.edu/eclipse/")).configFile rootProject.file('.eclipseformat.xml')
8492
}
8593
}
94+
95+
task prepareAgent(type: Copy) {
96+
from(configurations.agent)
97+
into "$buildDir/agent"
98+
}
99+
100+
tasks.withType(Test) {
101+
dependsOn prepareAgent
102+
jvmArgs += ["-javaagent:" + project.layout.buildDirectory.file("agent/opensearch-agent-${opensearch_version}.jar").get()]
103+
}

0 commit comments

Comments
 (0)