Skip to content

Commit 18fe587

Browse files
author
Stephan Brandauer
committed
Java: tests for automodel framework mode candidate extraction
1 parent 5a5e921 commit 18fe587

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
| com/github/codeql/test/PublicClass.java:4:21:4:30 | arg | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | com/github/codeql/test/PublicClass.java:4:21:4:30 | arg | MethodDoc | com/github/codeql/test/PublicClass.java:4:21:4:30 | arg | ClassDoc | file://com.github.codeql.test:1:1:1:1 | com.github.codeql.test | package | file://PublicClass:1:1:1:1 | PublicClass | type | file://true:1:1:1:1 | true | subtypes | file://stuff:1:1:1:1 | stuff | name | file://(String):1:1:1:1 | (String) | signature | file://Argument[0]:1:1:1:1 | Argument[0] | input | file://arg:1:1:1:1 | arg | parameterName |
2+
| com/github/codeql/test/PublicClass.java:8:34:8:43 | arg | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | com/github/codeql/test/PublicClass.java:8:34:8:43 | arg | MethodDoc | com/github/codeql/test/PublicClass.java:8:34:8:43 | arg | ClassDoc | file://com.github.codeql.test:1:1:1:1 | com.github.codeql.test | package | file://PublicClass:1:1:1:1 | PublicClass | type | file://false:1:1:1:1 | false | subtypes | file://staticStuff:1:1:1:1 | staticStuff | name | file://(String):1:1:1:1 | (String) | signature | file://Argument[0]:1:1:1:1 | Argument[0] | input | file://arg:1:1:1:1 | arg | parameterName |
3+
| java/nio/file/Files.java:12:42:12:57 | out | command-injection, path-injection, request-forgery, sql-injection\nrelated locations: $@, $@.\nmetadata: $@, $@, $@, $@, $@, $@, $@. | java/nio/file/Files.java:12:42:12:57 | out | MethodDoc | java/nio/file/Files.java:12:42:12:57 | out | ClassDoc | 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://copy:1:1:1:1 | copy | name | file://(Path,OutputStream):1:1:1:1 | (Path,OutputStream) | signature | file://Argument[1]:1:1:1:1 | Argument[1] | input | file://out:1:1:1:1 | out | parameterName |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Telemetry/AutomodelFrameworkModeExtractCandidates.ql
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.github.codeql.test;
2+
3+
/**
4+
* No candidates in this class, as it's not public!
5+
*/
6+
class NonPublicClass {
7+
public void noCandidates(String here) {
8+
System.out.println(here);
9+
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.github.codeql.test;
2+
3+
public class PublicClass {
4+
public void stuff(String arg) { // arg is a candidate
5+
System.out.println(arg);
6+
}
7+
8+
public static void staticStuff(String arg) { // arg is a candidate
9+
System.out.println(arg);
10+
}
11+
12+
// arg is not a candidate because the method is not public:
13+
protected void nonPublicStuff(String arg) {
14+
System.out.println(arg);
15+
}
16+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package java.nio.file;
2+
3+
import java.nio.file.Path;
4+
import java.io.IOException;
5+
import java.io.OutputStream;
6+
7+
public class Files {
8+
// - source is not a candidate because a manual model exists:
9+
// ["java.nio.file", "Files", False, "copy", "(Path,OutputStream)", "", "Argument[0]", "path-injection", "manual"]
10+
// - out is a candidate. NB: may be worthwile to implement the same behaviour as in application mode where out
11+
// would not be a candidate because another param is already modeled.
12+
public static void copy(Path source, OutputStream out) throws IOException {
13+
// ...
14+
}
15+
}

0 commit comments

Comments
 (0)