代码示例1

    1. import javascript
    2. from DataFlow::MethodCallNode readFile, DataFlow::Node source
    3. where
    4. readFile.getMethodName() = "readFile" and
    5. source.getASuccessor*() = readFile.getArgument(0)
    6. select source

    捕获示例1
    image.png
    捕获示例2
    image.png

    1. import javascript
    2. from DataFlow::CallNode method, DataFlow::Node source
    3. where
    4. method = DataFlow::globalVarRef("document").getAMethodCall("write")
    5. and source.getASuccessor*() = method.getArgument(0)
    6. select source

    捕获示例
    image.png
    Taint tracking

    1. import javascript
    2. class WriteLocationConfiguration extends TaintTracking::Configuration {
    3. WriteLocationConfiguration() { this = "WriteLocationConfiguration" }
    4. override predicate isSource(DataFlow::Node source) {
    5. DataFlow::globalVarRef("document").getAPropertyRead("location").getAPropertyRead() = source
    6. }
    7. override predicate isSink(DataFlow::Node sink) {
    8. DataFlow::globalVarRef("document").getAMethodCall("write").getArgument(0) = sink
    9. }
    10. }
    11. from WriteLocationConfiguration cfg, DataFlow::Node source, DataFlow::Node sink
    12. where cfg.hasFlow(source, sink)
    13. select source, sink

    捕获示例
    image.png