Skip to content

Commit a568d8c

Browse files
committed
JS: Port threat-model test to ConfigSig
1 parent f758b67 commit a568d8c

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
legacyDataFlowDifference
12
testFailures
23
failures

javascript/ql/test/library-tests/threat-models/sources/TestSources.ql

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
import javascript
22
import testUtilities.InlineExpectationsTest
33

4-
class TestSourcesConfiguration extends TaintTracking::Configuration {
5-
TestSourcesConfiguration() { this = "TestSources" }
4+
module TestConfig implements DataFlow::ConfigSig {
5+
predicate isSource(DataFlow::Node source) { source instanceof ThreatModelSource }
66

7-
override predicate isSource(DataFlow::Node source) { source instanceof ThreatModelSource }
8-
9-
override predicate isSink(DataFlow::Node sink) {
7+
predicate isSink(DataFlow::Node sink) {
108
exists(CallExpr call |
119
call.getAnArgument() = sink.asExpr() and
1210
call.getCalleeName() = "SINK"
1311
)
1412
}
1513
}
1614

15+
module TestFlow = TaintTracking::Global<TestConfig>;
16+
17+
deprecated class LegacyConfig extends TaintTracking::Configuration {
18+
LegacyConfig() { this = "TestSources" }
19+
20+
override predicate isSource(DataFlow::Node source) { TestConfig::isSource(source) }
21+
22+
override predicate isSink(DataFlow::Node sink) { TestConfig::isSink(sink) }
23+
}
24+
1725
private module InlineTestSources implements TestSig {
1826
string getARelevantTag() { result in ["hasFlow", "threat-source"] }
1927

2028
predicate hasActualResult(Location location, string element, string tag, string value) {
2129
exists(DataFlow::Node sink |
22-
any(TestSourcesConfiguration c).hasFlow(_, sink) and
30+
TestFlow::flowTo(sink) and
2331
value = "" and
2432
location = sink.getLocation() and
2533
tag = "hasFlow" and
@@ -36,3 +44,4 @@ private module InlineTestSources implements TestSig {
3644
}
3745

3846
import MakeTest<InlineTestSources>
47+
deprecated import testUtilities.LegacyDataFlowDiff::DataFlowDiff<TestFlow, LegacyConfig>

0 commit comments

Comments
 (0)