-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig-to-shell.ql
39 lines (32 loc) · 1.23 KB
/
config-to-shell.ql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/////////////////////////////////
// this query requires preprocessing to identify a workspace configuration node
/////////////////////////////////import javascript
import javascript
import DataFlow::PathGraph
class Configuration extends TaintTracking::Configuration {
Configuration() { this = "Configuration" }
override predicate isSource(DataFlow::Node source) { any() }
override predicate isSink(DataFlow::Node sink) {
exists(SystemCommandExecution shell | sink = shell.getACommandArgument())
}
}
from
Configuration cfg,
DataFlow::PathNode source,
DataFlow::PathNode sink
////////////////////////////////////////////////////////////
// if preprocessing identified a workspace configuration node
// the fileName can be replaced by the file where node was identified
// the getConfiguration_node can be replaced by the line where node was identified
////////////////////////////////////////////////////////////
where
source.getNode().getFile().getStem().toString().matches("%fileName%")
and
source.getNode().getStartLine() = ${getConfiguration_node}
and
source.getNode().toString().matches("%vscode%")
and
cfg.hasFlowPath(source, sink)
select
sink.getNode(), source, sink, "shell command depends on $@.",
source.getNode(), "config"