Skip to content

Commit 3319870

Browse files
committed
JS: Port tutorial query2
1 parent 32f020e commit 3319870

File tree

1 file changed

+8
-10
lines changed
  • javascript/ql/test/tutorials/Analyzing data flow in JavaScript/Global data flow

1 file changed

+8
-10
lines changed
Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,19 @@
11
import javascript
22

3-
class CommandLineFileNameConfiguration extends TaintTracking::Configuration {
4-
CommandLineFileNameConfiguration() { this = "CommandLineFileNameConfiguration" }
5-
6-
override predicate isSource(DataFlow::Node source) {
3+
module CommandLineFileNameConfig implements DataFlow::ConfigSig {
4+
predicate isSource(DataFlow::Node source) {
75
DataFlow::globalVarRef("process").getAPropertyRead("argv").getAPropertyRead() = source
86
}
97

10-
override predicate isSink(DataFlow::Node sink) {
8+
predicate isSink(DataFlow::Node sink) {
119
DataFlow::moduleMember("fs", "readFile").getACall().getArgument(0) = sink
1210
}
1311

14-
override predicate isSanitizer(DataFlow::Node nd) {
15-
nd.(DataFlow::CallNode).getCalleeName() = "checkPath"
16-
}
12+
predicate isBarrier(DataFlow::Node nd) { nd.(DataFlow::CallNode).getCalleeName() = "checkPath" }
1713
}
1814

19-
from CommandLineFileNameConfiguration cfg, DataFlow::Node source, DataFlow::Node sink
20-
where cfg.hasFlow(source, sink)
15+
module CommandLineFileNameFlow = TaintTracking::Global<CommandLineFileNameConfig>;
16+
17+
from DataFlow::Node source, DataFlow::Node sink
18+
where CommandLineFileNameFlow::flow(source, sink)
2119
select source, sink

0 commit comments

Comments
 (0)