Skip to content

Commit 3433437

Browse files
author
Stephan Brandauer
committed
Java: automodel application mode: only extract the first argument corresponding to a varargs array
1 parent e1a5eba commit 3433437

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

java/ql/src/Telemetry/AutomodelApplicationModeCharacteristics.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ newtype TApplicationModeEndpoint =
3131
TImplicitVarargsArray(Call call, DataFlow::Node arg, int idx) {
3232
exists(Argument argExpr |
3333
arg.asExpr() = argExpr and
34-
call = argExpr.getCall() and
34+
call.getArgument(idx) = argExpr and
3535
argExpr.isVararg() and
36-
idx = min(int n | argExpr = call.getArgument(n) and argExpr.isVararg() | n)
36+
not exists(int i | i < idx and call.getArgument(i).(Argument).isVararg())
3737
)
3838
}
3939

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
| Test.java:16:3:16:11 | reference | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@. | Test.java:16:3:16:11 | reference | CallContext | file://java.util.concurrent.atomic:1:1:1:1 | java.util.concurrent.atomic | package | file://AtomicReference:1:1:1:1 | AtomicReference | type | file://false:1:1:1:1 | false | subtypes | file://set:1:1:1:1 | set | name | file://(String):1:1:1:1 | (String) | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray |
22
| Test.java:21:3:21:10 | supplier | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@. | Test.java:21:3:21:10 | supplier | CallContext | file://java.util.function:1:1:1:1 | java.util.function | package | file://Supplier:1:1:1:1 | Supplier | type | file://true:1:1:1:1 | true | subtypes | file://get:1:1:1:1 | get | name | file://():1:1:1:1 | () | signature | file://Argument[this]:1:1:1:1 | Argument[this] | input | file://false:1:1:1:1 | false | isVarargsArray |
3-
| Test.java:53:4:53:4 | o | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@. | Test.java:51:3:54:3 | walk(...) | CallContext | file://java.nio.file:1:1:1:1 | java.nio.file | package | file://Files:1:1:1:1 | Files | type | file://false:1:1:1:1 | false | subtypes | file://walk:1:1:1:1 | walk | name | file://(Path,FileVisitOption[]):1:1:1:1 | (Path,FileVisitOption[]) | signature | file://Argument[1]:1:1:1:1 | Argument[1] | input | file://true:1:1:1:1 | true | isVarargsArray |
3+
| Test.java:53:4:53:4 | o | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@.\nmetadata: $@, $@, $@, $@, $@, $@. | Test.java:51:3:56:3 | walk(...) | CallContext | file://java.nio.file:1:1:1:1 | java.nio.file | package | file://Files:1:1:1:1 | Files | type | file://false:1:1:1:1 | false | subtypes | file://walk:1:1:1:1 | walk | name | file://(Path,FileVisitOption[]):1:1:1:1 | (Path,FileVisitOption[]) | signature | file://Argument[1]:1:1:1:1 | Argument[1] | input | file://true:1:1:1:1 | true | isVarargsArray |

java/ql/test/query-tests/Telemetry/AutomodelApplicationModeExtraction/Test.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public static int compareFiles(File f1, File f2) {
5050
public static void FilesWalkExample(Path p, FileVisitOption o) throws Exception {
5151
Files.walk(
5252
p, // negative example (modeled as a taint step)
53-
o // the implicit varargs array is a candidate
53+
o, // the implicit varargs array is a candidate
54+
o // not a candidate (only the first arg corresponding to a varargs array
55+
// is extracted)
5456
);
5557
}
5658
}

0 commit comments

Comments
 (0)