Skip to content

Commit 8e316d2

Browse files
committed
add unary type-tracking predicates
1 parent c6668da commit 8e316d2

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/IndirectCommandArgument.qll

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ private DataFlow::Node commandArgument(SystemCommandExecution sys, DataFlow::Typ
3333
exists(DataFlow::TypeBackTracker t2 | t = t2.smallstep(result, commandArgument(sys, t2)))
3434
}
3535

36+
/**
37+
* Gets a data-flow node whose value ends up being interpreted as the command argument in `sys`.
38+
*/
39+
private DataFlow::Node commandArgument(SystemCommandExecution sys) {
40+
result = commandArgument(sys, DataFlow::TypeBackTracker::end())
41+
}
42+
3643
/**
3744
* Gets a data-flow node whose value ends up being interpreted as the argument list in `sys`
3845
* after a flow summarized by `t`.
@@ -51,6 +58,13 @@ private DataFlow::SourceNode argumentList(SystemCommandExecution sys, DataFlow::
5158
)
5259
}
5360

61+
/**
62+
* Gets a data-flow node whose value ends up being interpreted as the argument list in `sys`.
63+
*/
64+
private DataFlow::SourceNode argumentList(SystemCommandExecution sys) {
65+
result = argumentList(sys, DataFlow::TypeBackTracker::end())
66+
}
67+
5468
/**
5569
* Holds if `source` contributes to the arguments of an indirect command execution `sys`.
5670
*
@@ -73,13 +87,13 @@ private DataFlow::SourceNode argumentList(SystemCommandExecution sys, DataFlow::
7387
predicate isIndirectCommandArgument(DataFlow::Node source, SystemCommandExecution sys) {
7488
exists(DataFlow::ArrayCreationNode args, DataFlow::Node shell, string dashC |
7589
shellCmd(shell.asExpr(), dashC) and
76-
shell = commandArgument(sys, DataFlow::TypeBackTracker::end()) and
90+
shell = commandArgument(sys) and
7791
args.getAPropertyWrite().getRhs().mayHaveStringValue(dashC) and
78-
args = argumentList(sys, DataFlow::TypeBackTracker::end()) and
92+
args = argumentList(sys) and
7993
(
80-
source = argumentList(sys, DataFlow::TypeBackTracker::end())
94+
source = argumentList(sys)
8195
or
82-
source = argumentList(sys, DataFlow::TypeBackTracker::end()).getAPropertyWrite().getRhs()
96+
source = argumentList(sys).getAPropertyWrite().getRhs()
8397
)
8498
)
8599
}

0 commit comments

Comments
 (0)