You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(appsec): instrument Files.copy(Path,Path) and Files.copy(Path,OutputStream) for RASP
Files.copy(Path source, Path target, CopyOption[]) was missing from FilesCallSite:
- fires beforeFileLoaded(source) for LFI detection on the source path
- fires beforeFileWritten(target) for write detection on the target path
Files.copy(Path source, OutputStream out) was also missing:
- fires beforeFileLoaded(source) for LFI detection on the source path
Copy file name to clipboardExpand all lines: dd-java-agent/instrumentation/java/java-io-1.8/src/main/java/datadog/trace/instrumentation/java/lang/FilesCallSite.java
+20Lines changed: 20 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -43,6 +43,19 @@ public static void beforeCopyFromStream(@CallSite.Argument(1) @Nullable final Pa
Copy file name to clipboardExpand all lines: dd-java-agent/instrumentation/java/java-io-1.8/src/test/groovy/datadog/trace/instrumentation/java/io/FilesCallSiteTest.groovy
+29Lines changed: 29 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,35 @@ class FilesCallSiteTest extends BaseIoRaspCallSiteTest {
102
102
1* helper.beforeFileWritten(path.toString())
103
103
}
104
104
105
+
void'test RASP Files.copy path to path fires beforeFileLoaded on source and beforeFileWritten on target'() {
106
+
setup:
107
+
final helper =Mock(FileIORaspHelper)
108
+
FileIORaspHelper.INSTANCE= helper
109
+
final source = newFile('test_rasp_copy_src.txt').toPath()
110
+
final target = temporaryFolder.resolve('test_rasp_copy_path_dst.txt')
111
+
112
+
when:
113
+
TestFilesSuite.copyPathToPath(source, target)
114
+
115
+
then:
116
+
1* helper.beforeFileLoaded(source.toString())
117
+
1* helper.beforeFileWritten(target.toString())
118
+
}
119
+
120
+
void'test RASP Files.copy path to OutputStream fires beforeFileLoaded on source'() {
121
+
setup:
122
+
final helper =Mock(FileIORaspHelper)
123
+
FileIORaspHelper.INSTANCE= helper
124
+
final source = newFile('test_rasp_copy_stream_src.txt').toPath()
0 commit comments