Skip to content

Commit

Permalink
Java: Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
aschackmull committed Nov 4, 2024
1 parent 146553f commit e5cd0a4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
35 changes: 35 additions & 0 deletions java/ql/test/library-tests/listofconstants/A.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.util.*;

public class A {
private static final Set<String> SEPARATORS =
Collections.unmodifiableSet(
new HashSet<>(Arrays.asList("\t", "\n", ";")));

public static void sink(String s) { }

private void checkSeparator(String separator) {
if (SEPARATORS.contains(separator)) {
sink(separator);
}
}

public static final String URI1 = "yarn.io/gpu";
public static final String URI2 = "yarn.io/fpga";

public static final Set<String> SCHEMAS = Set.of(URI1, URI2, "s3a", "wasb");

private void checkSchema(String schema) {
if (SCHEMAS.contains(schema)) {
sink(schema);
}
}

private void testAdd(String inp) {
Set<String> s = new HashSet<>();
s.add("AA");
s.add("BB");
if (s.contains(inp.toUpperCase())) {
sink(inp);
}
}
}
3 changes: 3 additions & 0 deletions java/ql/test/library-tests/listofconstants/test.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
| A.java:12:12:12:20 | separator |
| A.java:23:12:23:17 | schema |
| A.java:32:12:32:14 | inp |
6 changes: 6 additions & 0 deletions java/ql/test/library-tests/listofconstants/test.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import java
import semmle.code.java.dataflow.FlowSteps
// import semmle.code.java.security.ListOfConstantsSanitizer

from DefaultTaintSanitizer e
select e

0 comments on commit e5cd0a4

Please sign in to comment.