Skip to content

Commit 93bd2a9

Browse files
committed
Refactor PathSanitizer test
1 parent 547f00c commit 93bd2a9

File tree

1 file changed

+11
-9
lines changed
  • java/ql/test/library-tests/pathsanitizer

1 file changed

+11
-9
lines changed

java/ql/test/library-tests/pathsanitizer/test.ql

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@ import java
22
import semmle.code.java.security.PathSanitizer
33
import TestUtilities.InlineFlowTest
44

5-
class EnableLegacy extends EnableLegacyConfiguration {
6-
EnableLegacy() { exists(this) }
7-
}
5+
module PathSanitizerConfig implements DataFlow::ConfigSig {
6+
predicate isSource(DataFlow::Node source) { DefaultFlowConfig::isSource(source) }
87

9-
class PathSanitizerConf extends DefaultTaintFlowConf {
10-
override predicate isSanitizer(DataFlow::Node sanitizer) {
11-
sanitizer instanceof PathInjectionSanitizer
12-
}
8+
predicate isSink(DataFlow::Node sink) { DefaultFlowConfig::isSink(sink) }
9+
10+
predicate isBarrier(DataFlow::Node sanitizer) { sanitizer instanceof PathInjectionSanitizer }
1311
}
1412

13+
module PathSanitizerFlow = TaintTracking::Global<PathSanitizerConfig>;
14+
1515
class Test extends InlineFlowTest {
16-
override DataFlow::Configuration getValueFlowConfig() { none() }
16+
override predicate hasValueFlow(DataFlow::Node src, DataFlow::Node sink) { none() }
1717

18-
override DataFlow::Configuration getTaintFlowConfig() { result = any(PathSanitizerConf config) }
18+
override predicate hasTaintFlow(DataFlow::Node src, DataFlow::Node sink) {
19+
PathSanitizerFlow::flow(src, sink)
20+
}
1921
}

0 commit comments

Comments
 (0)