Skip to content

Commit 1f6335f

Browse files
committed
JS: Port tutorial query3
1 parent 3319870 commit 1f6335f

File tree

1 file changed

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

1 file changed

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

3-
class CheckPathSanitizerGuard extends TaintTracking::SanitizerGuardNode, DataFlow::CallNode {
3+
class CheckPathSanitizerGuard extends DataFlow::CallNode {
44
CheckPathSanitizerGuard() { this.getCalleeName() = "checkPath" }
55

6-
override predicate sanitizes(boolean outcome, Expr e) {
6+
predicate blocksExpr(boolean outcome, Expr e) {
77
outcome = true and
88
e = this.getArgument(0).asExpr()
99
}
1010
}
1111

12-
class CommandLineFileNameConfiguration extends TaintTracking::Configuration {
13-
CommandLineFileNameConfiguration() { this = "CommandLineFileNameConfiguration" }
14-
15-
override predicate isSource(DataFlow::Node source) {
12+
module CommandLineFileNameConfig implements DataFlow::ConfigSig {
13+
predicate isSource(DataFlow::Node source) {
1614
DataFlow::globalVarRef("process").getAPropertyRead("argv").getAPropertyRead() = source
1715
}
1816

19-
override predicate isSink(DataFlow::Node sink) {
17+
predicate isSink(DataFlow::Node sink) {
2018
DataFlow::moduleMember("fs", "readFile").getACall().getArgument(0) = sink
2119
}
2220

23-
override predicate isSanitizerGuard(TaintTracking::SanitizerGuardNode nd) {
24-
nd instanceof CheckPathSanitizerGuard
21+
predicate isBarrier(DataFlow::Node node) {
22+
node = DataFlow::MakeBarrierGuard<CheckPathSanitizerGuard>::getABarrierNode()
2523
}
2624
}
2725

28-
from CommandLineFileNameConfiguration cfg, DataFlow::Node source, DataFlow::Node sink
29-
where cfg.hasFlow(source, sink)
26+
module CommandLineFileNameFlow = TaintTracking::Global<CommandLineFileNameConfig>;
27+
28+
from DataFlow::Node source, DataFlow::Node sink
29+
where CommandLineFileNameFlow::flow(source, sink)
3030
select source, sink

0 commit comments

Comments
 (0)