Skip to content

Commit 355786c

Browse files
author
Max Schaefer
authored
Merge pull request #296 from esben-semmle/js/more-array-creation
JS: use DataFlow::ArrayCreationNode in additional places
2 parents b1ece81 + 70cd03d commit 355786c

File tree

7 files changed

+13
-13
lines changed

7 files changed

+13
-13
lines changed

javascript/ql/src/AngularJS/InsecureUrlWhitelist.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import javascript
1717
* Holds if `setupCall` is a call to `$sceDelegateProvider.resourceUrlWhitelist` with
1818
* argument `list`.
1919
*/
20-
predicate isResourceUrlWhitelist(DataFlow::MethodCallNode setupCall, DataFlow::ArrayLiteralNode list) {
20+
predicate isResourceUrlWhitelist(DataFlow::MethodCallNode setupCall, DataFlow::ArrayCreationNode list) {
2121
exists (AngularJS::ServiceReference service |
2222
service.getName() = "$sceDelegateProvider" and
2323
setupCall.asExpr() = service.getAMethodCall("resourceUrlWhitelist") and
@@ -33,7 +33,7 @@ class ResourceUrlWhitelistEntry extends Expr {
3333
string pattern;
3434

3535
ResourceUrlWhitelistEntry() {
36-
exists (DataFlow::ArrayLiteralNode whitelist |
36+
exists (DataFlow::ArrayCreationNode whitelist |
3737
isResourceUrlWhitelist(setupCall, whitelist) and
3838
this = whitelist.getAnElement().asExpr() and
3939
this.mayHaveStringValue(pattern)

javascript/ql/src/Expressions/UnboundEventHandlerReceiver.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ private predicate isBoundInMethod(MethodDeclaration method) {
3636
bindAll.getArgument(1).mayHaveStringValue(name)
3737
or
3838
// _.bindAll(this, [<name1>, <name2>])
39-
exists (DataFlow::ArrayLiteralNode names |
39+
exists (DataFlow::ArrayCreationNode names |
4040
names.flowsTo(bindAll.getArgument(1)) and
4141
names.getAnElement().mayHaveStringValue(name)
4242
)

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ private class LibraryPartialCall extends AdditionalPartialInvokeNode {
407407

408408
override predicate isPartialArgument(DataFlow::Node callback, DataFlow::Node argument, int index) {
409409
callback = getArgument(0) and
410-
exists (DataFlow::ArrayLiteralNode array |
410+
exists (DataFlow::ArrayCreationNode array |
411411
array.flowsTo(getArgument(1)) and
412412
argument = array.getElement(index))
413413
}

javascript/ql/src/semmle/javascript/frameworks/AngularJS/DependencyInjections.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private DataFlow::PropWrite getAPropertyDependencyInjection(Function function) {
146146
*/
147147
private class FunctionWithInjectProperty extends InjectableFunction {
148148
override Function astNode;
149-
DataFlow::ArrayLiteralNode dependencies;
149+
DataFlow::ArrayCreationNode dependencies;
150150

151151
FunctionWithInjectProperty() {
152152
(

javascript/ql/src/semmle/javascript/frameworks/Express.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ module Express {
891891
getMethodName() = methodName and
892892
exists (DataFlow::ValueNode arg |
893893
arg = getAnArgument() |
894-
exists (DataFlow::ArrayLiteralNode array |
894+
exists (DataFlow::ArrayCreationNode array |
895895
array.flowsTo(arg) and
896896
routeHandlerArg = array.getAnElement()
897897
) or

javascript/ql/src/semmle/javascript/frameworks/ExpressModules.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,8 @@ module ExpressLibraries {
144144

145145
override DataFlow::Node getASecretKey() {
146146
exists (DataFlow::Node secret | secret = getOption("secret") |
147-
if exists(DataFlow::ArrayLiteralNode arr | arr.flowsTo(secret)) then
148-
result = any (DataFlow::ArrayLiteralNode arr | arr.flowsTo(secret)).getAnElement()
147+
if exists(DataFlow::ArrayCreationNode arr | arr.flowsTo(secret)) then
148+
result = any (DataFlow::ArrayCreationNode arr | arr.flowsTo(secret)).getAnElement()
149149
else
150150
result = secret
151151
)
@@ -182,8 +182,8 @@ module ExpressLibraries {
182182

183183
override DataFlow::Node getASecretKey() {
184184
exists (DataFlow::Node arg0 | arg0 = getArgument(0) |
185-
if exists(DataFlow::ArrayLiteralNode arr | arr.flowsTo(arg0)) then
186-
result = any (DataFlow::ArrayLiteralNode arr | arr.flowsTo(arg0)).getAnElement()
185+
if exists(DataFlow::ArrayCreationNode arr | arr.flowsTo(arg0)) then
186+
result = any (DataFlow::ArrayCreationNode arr | arr.flowsTo(arg0)).getAnElement()
187187
else
188188
result = arg0
189189
)
@@ -220,7 +220,7 @@ module ExpressLibraries {
220220

221221
override DataFlow::Node getASecretKey() {
222222
result = getOption("secret") or
223-
exists (DataFlow::ArrayLiteralNode keys |
223+
exists (DataFlow::ArrayCreationNode keys |
224224
keys.flowsTo(getOption("keys")) and
225225
result = keys.getAnElement()
226226
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ module CommandInjection {
7575
ArgumentListTracking() { this = "ArgumentListTracking" }
7676

7777
override predicate isSource(DataFlow::Node nd) {
78-
nd instanceof DataFlow::ArrayLiteralNode
78+
nd instanceof DataFlow::ArrayCreationNode
7979
or
8080
exists (StringLiteral shell | shellCmd(shell, _) |
8181
nd = DataFlow::valueNode(shell)
@@ -125,7 +125,7 @@ module CommandInjection {
125125
* we want to report the `spawn` call as the sink, so we bind it to `sys`.
126126
*/
127127
private predicate indirectCommandInjection(DataFlow::Node sink, SystemCommandExecution sys) {
128-
exists (ArgumentListTracking cfg, DataFlow::ArrayLiteralNode args,
128+
exists (ArgumentListTracking cfg, DataFlow::ArrayCreationNode args,
129129
StringLiteral shell, string dashC |
130130
shellCmd(shell, dashC) and
131131
cfg.hasFlow(DataFlow::valueNode(shell), sys.getACommandArgument()) and

0 commit comments

Comments
 (0)