|
| 1 | +// module in root folder |
| 2 | +import workspaceConfig |
| 3 | + |
| 4 | +import javascript |
| 5 | +import DataFlow::PathGraph |
| 6 | + |
| 7 | + |
| 8 | +class FlowToWritePath extends TaintTracking::Configuration { |
| 9 | + FlowToWritePath() { this = "FlowToWritePath" } |
| 10 | + |
| 11 | + override predicate isSource(DataFlow::Node source) { |
| 12 | + exists(VSCodeWorkspaceConfig config, DataFlow::SourceNode src | |
| 13 | + src.getFile() = config.getFile() and src.getStartLine() = config.getStartLine() | |
| 14 | + source = src) |
| 15 | + } |
| 16 | + |
| 17 | + override predicate isSink(DataFlow::Node sink) { |
| 18 | + exists(FileSystemWriteAccess write | sink = write.getAPathArgument()) |
| 19 | + } |
| 20 | +} |
| 21 | +class FlowToWriteContent extends TaintTracking::Configuration { |
| 22 | + FlowToWriteContent() { this = "FlowToWriteContent" } |
| 23 | + |
| 24 | + override predicate isSource(DataFlow::Node source) { |
| 25 | + exists(VSCodeWorkspaceConfig config, DataFlow::SourceNode src | |
| 26 | + src.getFile() = config.getFile() and src.getStartLine() = config.getStartLine() | |
| 27 | + source = src) |
| 28 | +} |
| 29 | + |
| 30 | + override predicate isSink(DataFlow::Node sink) { |
| 31 | + exists(FileSystemWriteAccess write | sink = write.getADataNode()) |
| 32 | + } |
| 33 | +} |
| 34 | + |
| 35 | + |
| 36 | +from |
| 37 | +FlowToWritePath writepath, FlowToWriteContent writecontent, |
| 38 | +DataFlow::PathNode source_path, DataFlow::PathNode source_content, |
| 39 | +DataFlow::PathNode sink_path, DataFlow::PathNode sink_content, |
| 40 | +FileSystemWriteAccess filewrite_func |
| 41 | + |
| 42 | + |
| 43 | +where |
| 44 | +writepath.hasFlowPath(source_path, sink_path) |
| 45 | +and |
| 46 | +writecontent.hasFlowPath(source_content, sink_content) |
| 47 | +and |
| 48 | +filewrite_func.getADataNode() = sink_content.getNode() |
| 49 | +and |
| 50 | +filewrite_func.getAPathArgument() = sink_path.getNode() |
| 51 | + |
| 52 | + |
| 53 | +select |
| 54 | +sink_path.getNode(), source_path, sink_path, "file read or write depends on $@. $@. $@.", |
| 55 | +source_path.getNode(), "path source", |
| 56 | +source_content.getNode(), "content source", |
| 57 | +sink_content.getNode(), "content sink" |
0 commit comments