Skip to content

Commit 63cdda0

Browse files
committed
fix(appsec): inspect file content even when filename is empty
1 parent 0032a7e commit 63cdda0

3 files changed

Lines changed: 4 additions & 8 deletions

File tree

dd-java-agent/instrumentation/commons-fileupload-1.5/src/main/java/datadog/trace/instrumentation/commons/fileupload/CommonsFileUploadAppSecInstrumentation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ static void after(
8383
filenames.add(name);
8484
}
8585
}
86-
if (filenames.isEmpty()) {
86+
if (filenames.isEmpty() && contentCallback == null) {
8787
return;
8888
}
8989

9090
// Fire filenames event
91-
if (filenamesCallback != null) {
91+
if (filenamesCallback != null && !filenames.isEmpty()) {
9292
Flow<Void> flow = filenamesCallback.apply(reqCtx, filenames);
9393
Flow.Action action = flow.getAction();
9494
if (action instanceof Flow.Action.RequestBlockingAction) {

dd-java-agent/instrumentation/commons-fileupload-1.5/src/main/java/datadog/trace/instrumentation/commons/fileupload/FileItemContentReader.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ public static List<String> readContents(List<FileItem> fileItems) {
2121
if (fileItem.isFormField()) {
2222
continue;
2323
}
24-
String name = fileItem.getName();
25-
if (name == null || name.isEmpty()) {
26-
continue;
27-
}
2824
result.add(readContent(fileItem));
2925
}
3026
return result;

dd-java-agent/instrumentation/commons-fileupload-1.5/src/test/groovy/FileItemContentReaderTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class FileItemContentReaderTest extends Specification {
6363
result == ['content']
6464
}
6565

66-
void 'readContents skips files with null or empty name'() {
66+
void 'readContents includes file parts with empty or null name'() {
6767
given:
6868
def items = [
6969
fileItem('content-no-name', null),
@@ -75,7 +75,7 @@ class FileItemContentReaderTest extends Specification {
7575
def result = FileItemContentReader.readContents(items)
7676

7777
then:
78-
result == ['content-named']
78+
result == ['content-no-name', 'content-empty-name', 'content-named']
7979
}
8080

8181
void 'readContents stops after MAX_FILES_TO_INSPECT files'() {

0 commit comments

Comments
 (0)