Skip to content

Commit b33f1e9

Browse files
authored
Merge branch 'main' into policy_parser_java_agent
Signed-off-by: Gulshan <71965388+kumargu@users.noreply.github.com>
2 parents ab107dd + cec8fb9 commit b33f1e9

File tree

51 files changed

+5240
-129
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

+5240
-129
lines changed

.github/CODEOWNERS

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,27 @@
1111
# 3. Use the command palette to run the CODEOWNERS: Show owners of current file command, which will display all code owners for the current file.
1212

1313
# Default ownership for all repo files
14-
* @anasalkouz @andrross @ashking94 @bugmakerrrrrr @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jainankitk @kotwanikunal @linuxpi @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
14+
* @anasalkouz @andrross @ashking94 @bugmakerrrrrr @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jainankitk @kotwanikunal @linuxpi @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
1515

16-
/modules/lang-painless/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
17-
/modules/parent-join/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
16+
/modules/lang-painless/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
17+
/modules/parent-join/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
1818
/modules/transport-netty4/ @peternied
1919

2020
/plugins/identity-shiro/ @peternied @cwperks
2121

22-
/server/src/internalClusterTest/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
23-
/server/src/internalClusterTest/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
22+
/server/src/internalClusterTest/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
23+
/server/src/internalClusterTest/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
2424

2525
/server/src/main/java/org/opensearch/extensions/ @peternied
2626
/server/src/main/java/org/opensearch/identity/ @peternied @cwperks
27-
/server/src/main/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
28-
/server/src/main/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
27+
/server/src/main/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
28+
/server/src/main/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
2929
/server/src/main/java/org/opensearch/threadpool/ @jed326 @peternied
3030
/server/src/main/java/org/opensearch/transport/ @peternied
3131

32-
/server/src/test/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
33-
/server/src/test/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
32+
/server/src/test/java/org/opensearch/index/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
33+
/server/src/test/java/org/opensearch/search/ @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
3434

3535
/.github/ @jed326 @peternied
3636

37-
/MAINTAINERS.md @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dblock @dbwiddis @gaobinlong @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @peternied @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah
37+
/MAINTAINERS.md @anasalkouz @andrross @ashking94 @Bukhtawar @CEHENKLE @cwperks @dbwiddis @gaobinlong @gbbafna @jed326 @kotwanikunal @mch2 @msfroh @nknize @owaiskazi19 @peternied @reta @Rishikesh1159 @sachinpkale @saratvemulapalli @shwetathareja @sohami @VachaShah

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1818
- [Security Manager Replacement] Create initial Java Agent to intercept Socket::connect calls ([#17724](https://github.com/opensearch-project/OpenSearch/pull/17724))
1919
- Add ingestion management APIs for pause, resume and get ingestion state ([#17631](https://github.com/opensearch-project/OpenSearch/pull/17631))
2020
- [Security Manager Replacement] Enhance Java Agent to intercept System::exit ([#17746](https://github.com/opensearch-project/OpenSearch/pull/17746))
21-
- [Security Manager Replacement] Add a policy parser for Java agent security policies ([#17753](https://github.com/opensearch-project/OpenSearch/pull/17753))
21+
- [Security Manager Replacement] Implement File Interceptor and add integration tests ([#17760](https://github.com/opensearch-project/OpenSearch/pull/17760))
2222
- [Security Manager Replacement] Enhance Java Agent to intercept Runtime::halt ([#17757](https://github.com/opensearch-project/OpenSearch/pull/17757))
2323
- Support AutoExpand for SearchReplica ([#17741](https://github.com/opensearch-project/OpenSearch/pull/17741))
2424
- Implement fixed interval refresh task scheduling ([#17777](https://github.com/opensearch-project/OpenSearch/pull/17777))
2525
- Add GRPC DocumentService and Bulk endpoint ([#17727](https://github.com/opensearch-project/OpenSearch/pull/17727))
26+
- Added scale to zero (`search_only` mode) support for OpenSearch reader writer separation ([#17299](https://github.com/opensearch-project/OpenSearch/pull/17299)
2627
- [Security Manager Replacement] Add a policy parser for Java agent security policies ([#17753](https://github.com/opensearch-project/OpenSearch/pull/17753))
2728

2829
### Changed

MAINTAINERS.md

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,46 +4,46 @@ This document contains a list of maintainers in this repo. See [opensearch-proje
44

55
## Current Maintainers
66

7-
| Maintainer | GitHub ID | Affiliation |
8-
| ------------------------ | ------------------------------------------------------- | ----------- |
9-
| Anas Alkouz | [anasalkouz](https://github.com/anasalkouz) | Amazon |
10-
| Andrew Ross | [andrross](https://github.com/andrross) | Amazon |
11-
| Andriy Redko | [reta](https://github.com/reta) | Independent |
12-
| Ankit Jain | [jainankitk](https://github.com/jainankitk) | Amazon |
13-
| Ashish Singh | [ashking94](https://github.com/ashking94) | Amazon |
14-
| Bukhtawar Khan | [Bukhtawar](https://github.com/Bukhtawar) | Amazon |
15-
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
16-
| Craig Perkins | [cwperks](https://github.com/cwperks) | Amazon |
17-
| Dan Widdis | [dbwiddis](https://github.com/dbwiddis) | Amazon |
18-
| Daniel "dB." Doubrovkine | [dblock](https://github.com/dblock) | Independent |
19-
| Binlong Gao | [gaobinlong](https://github.com/gaobinlong) | Amazon |
20-
| Gaurav Bafna | [gbbafna](https://github.com/gbbafna) | Amazon |
21-
| Jay Deng | [jed326](https://github.com/jed326) | Amazon |
22-
| Kunal Kotwani | [kotwanikunal](https://github.com/kotwanikunal) | Amazon |
23-
| Varun Bansal | [linuxpi](https://github.com/linuxpi) | Amazon |
24-
| Marc Handalian | [mch2](https://github.com/mch2) | Amazon |
25-
| Michael Froh | [msfroh](https://github.com/msfroh) | Amazon |
26-
| Nick Knize | [nknize](https://github.com/nknize) | Lucenia |
27-
| Owais Kazi | [owaiskazi19](https://github.com/owaiskazi19) | Amazon |
28-
| Pan Guixin | [bugmakerrrrrr](https://github.com/bugmakerrrrrr) | ByteDance |
29-
| Peter Nied | [peternied](https://github.com/peternied) | Amazon |
30-
| Rishikesh Pasham | [Rishikesh1159](https://github.com/Rishikesh1159) | Amazon |
31-
| Sachin Kale | [sachinpkale](https://github.com/sachinpkale) | Amazon |
32-
| Sarat Vemulapalli | [saratvemulapalli](https://github.com/saratvemulapalli) | Amazon |
33-
| Shweta Thareja | [shwetathareja](https://github.com/shwetathareja) | Amazon |
34-
| Sorabh Hamirwasia | [sohami](https://github.com/sohami) | Amazon |
35-
| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |
7+
| Maintainer | GitHub ID | Affiliation |
8+
| ----------------- | ------------------------------------------------------- | ----------- |
9+
| Anas Alkouz | [anasalkouz](https://github.com/anasalkouz) | Amazon |
10+
| Andrew Ross | [andrross](https://github.com/andrross) | Amazon |
11+
| Andriy Redko | [reta](https://github.com/reta) | Independent |
12+
| Ankit Jain | [jainankitk](https://github.com/jainankitk) | Amazon |
13+
| Ashish Singh | [ashking94](https://github.com/ashking94) | Amazon |
14+
| Bukhtawar Khan | [Bukhtawar](https://github.com/Bukhtawar) | Amazon |
15+
| Charlotte Henkle | [CEHENKLE](https://github.com/CEHENKLE) | Amazon |
16+
| Craig Perkins | [cwperks](https://github.com/cwperks) | Amazon |
17+
| Dan Widdis | [dbwiddis](https://github.com/dbwiddis) | Amazon |
18+
| Binlong Gao | [gaobinlong](https://github.com/gaobinlong) | Amazon |
19+
| Gaurav Bafna | [gbbafna](https://github.com/gbbafna) | Amazon |
20+
| Jay Deng | [jed326](https://github.com/jed326) | Amazon |
21+
| Kunal Kotwani | [kotwanikunal](https://github.com/kotwanikunal) | Amazon |
22+
| Varun Bansal | [linuxpi](https://github.com/linuxpi) | Amazon |
23+
| Marc Handalian | [mch2](https://github.com/mch2) | Amazon |
24+
| Michael Froh | [msfroh](https://github.com/msfroh) | Amazon |
25+
| Nick Knize | [nknize](https://github.com/nknize) | Lucenia |
26+
| Owais Kazi | [owaiskazi19](https://github.com/owaiskazi19) | Amazon |
27+
| Pan Guixin | [bugmakerrrrrr](https://github.com/bugmakerrrrrr) | ByteDance |
28+
| Peter Nied | [peternied](https://github.com/peternied) | Amazon |
29+
| Rishikesh Pasham | [Rishikesh1159](https://github.com/Rishikesh1159) | Amazon |
30+
| Sachin Kale | [sachinpkale](https://github.com/sachinpkale) | Amazon |
31+
| Sarat Vemulapalli | [saratvemulapalli](https://github.com/saratvemulapalli) | Amazon |
32+
| Shweta Thareja | [shwetathareja](https://github.com/shwetathareja) | Amazon |
33+
| Sorabh Hamirwasia | [sohami](https://github.com/sohami) | Amazon |
34+
| Vacha Shah | [VachaShah](https://github.com/VachaShah) | Amazon |
3635

3736
## Emeritus
3837

39-
| Maintainer | GitHub ID | Affiliation |
40-
| --------------------- | ------------------------------------------- | ----------- |
41-
| Megha Sai Kavikondala | [meghasaik](https://github.com/meghasaik) | Amazon |
42-
| Xue Zhou | [xuezhou25](https://github.com/xuezhou25) | Amazon |
43-
| Kartik Ganesh | [kartg](https://github.com/kartg) | Amazon |
44-
| Abbas Hussain | [abbashus](https://github.com/abbashus) | Meta |
45-
| Himanshu Setia | [setiah](https://github.com/setiah) | Amazon |
46-
| Ryan Bogan | [ryanbogan](https://github.com/ryanbogan) | Amazon |
47-
| Rabi Panda | [adnapibar](https://github.com/adnapibar) | Independent |
48-
| Tianli Feng | [tlfeng](https://github.com/tlfeng) | Amazon |
49-
| Suraj Singh | [dreamer-89](https://github.com/dreamer-89) | Amazon |
38+
| Maintainer | GitHub ID | Affiliation |
39+
| ------------------------ | ------------------------------------------- | ----------- |
40+
| Megha Sai Kavikondala | [meghasaik](https://github.com/meghasaik) | Amazon |
41+
| Xue Zhou | [xuezhou25](https://github.com/xuezhou25) | Amazon |
42+
| Kartik Ganesh | [kartg](https://github.com/kartg) | Amazon |
43+
| Abbas Hussain | [abbashus](https://github.com/abbashus) | Meta |
44+
| Himanshu Setia | [setiah](https://github.com/setiah) | Amazon |
45+
| Ryan Bogan | [ryanbogan](https://github.com/ryanbogan) | Amazon |
46+
| Rabi Panda | [adnapibar](https://github.com/adnapibar) | Independent |
47+
| Tianli Feng | [tlfeng](https://github.com/tlfeng) | Amazon |
48+
| Suraj Singh | [dreamer-89](https://github.com/dreamer-89) | Amazon |
49+
| Daniel "dB." Doubrovkine | [dblock](https://github.com/dblock) | Independent |

libs/agent-sm/agent/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ tasks.named('forbiddenApisTest').configure { onlyIf { false } }
4343

4444
tasks.named('forbiddenApisMain').configure {
4545
replaceSignatureFiles 'jdk-signatures'
46+
onlyIf { false }
4647
}
4748

4849
task prepareAgent(type: Copy) {

libs/agent-sm/agent/src/main/java/org/opensearch/javaagent/Agent.java

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import org.opensearch.javaagent.bootstrap.AgentPolicy;
1212

1313
import java.lang.instrument.Instrumentation;
14+
import java.nio.channels.FileChannel;
1415
import java.nio.channels.SocketChannel;
16+
import java.nio.file.Files;
1517
import java.util.Map;
1618

1719
import net.bytebuddy.ByteBuddy;
@@ -33,6 +35,22 @@ public class Agent {
3335
*/
3436
private Agent() {}
3537

38+
/**
39+
* List of methods that are intercepted
40+
*/
41+
private static final String[] INTERCEPTED_METHODS = {
42+
"write",
43+
"createFile",
44+
"createDirectories",
45+
"createLink",
46+
"copy",
47+
"move",
48+
"newByteChannel",
49+
"delete",
50+
"deleteIfExists",
51+
"read",
52+
"open" };
53+
3654
/**
3755
* Premain
3856
* @param agentArguments agent arguments
@@ -55,12 +73,18 @@ public static void agentmain(String agentArguments, Instrumentation instrumentat
5573

5674
private static AgentBuilder createAgentBuilder(Instrumentation inst) throws Exception {
5775
final Junction<TypeDescription> systemType = ElementMatchers.isSubTypeOf(SocketChannel.class);
76+
final Junction<TypeDescription> pathType = ElementMatchers.isSubTypeOf(Files.class);
77+
final Junction<TypeDescription> fileChannelType = ElementMatchers.isSubTypeOf(FileChannel.class);
5878

59-
final AgentBuilder.Transformer transformer = (b, typeDescription, classLoader, module, pd) -> b.visit(
79+
final AgentBuilder.Transformer socketTransformer = (b, typeDescription, classLoader, module, pd) -> b.visit(
6080
Advice.to(SocketChannelInterceptor.class)
6181
.on(ElementMatchers.named("connect").and(ElementMatchers.not(ElementMatchers.isAbstract())))
6282
);
6383

84+
final AgentBuilder.Transformer fileTransformer = (b, typeDescription, classLoader, module, pd) -> b.visit(
85+
Advice.to(FileInterceptor.class).on(ElementMatchers.namedOneOf(INTERCEPTED_METHODS).or(ElementMatchers.isAbstract()))
86+
);
87+
6488
ClassInjector.UsingUnsafe.ofBootLoader()
6589
.inject(
6690
Map.of(
@@ -79,7 +103,9 @@ private static AgentBuilder createAgentBuilder(Instrumentation inst) throws Exce
79103
.with(AgentBuilder.TypeStrategy.Default.REDEFINE)
80104
.ignore(ElementMatchers.none())
81105
.type(systemType)
82-
.transform(transformer)
106+
.transform(socketTransformer)
107+
.type(pathType.or(fileChannelType))
108+
.transform(fileTransformer)
83109
.type(ElementMatchers.is(java.lang.System.class))
84110
.transform(
85111
(b, typeDescription, classLoader, module, pd) -> b.visit(

0 commit comments

Comments
 (0)