Skip to content

Commit d166727

Browse files
committed
JS: Add WithStringArgument[arg=const] filter
1 parent 4f3c8ec commit d166727

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ predicate invocationMatchesExtraCallSiteFilter(API::InvokeNode invoke, AccessPat
166166
token.getName() = "Call" and
167167
invoke instanceof API::CallNode and
168168
invoke instanceof DataFlow::CallNode // Workaround compiler bug
169+
or
170+
token.getName() = "WithStringArgument" and
171+
exists(string operand, string argIndex, string stringValue |
172+
operand = token.getAnArgument() and
173+
argIndex = operand.splitAt("=", 0) and
174+
stringValue = operand.splitAt("=", 1) and
175+
invoke
176+
.getArgument(AccessPath::parseIntWithArity(argIndex, invoke.getNumArgument()))
177+
.getStringValue() = stringValue
178+
)
169179
}
170180

171181
/**
@@ -229,7 +239,8 @@ predicate isExtraValidTokenNameInIdentifyingAccessPath(string name) {
229239
name =
230240
[
231241
"Member", "AnyMember", "Instance", "Awaited", "ArrayElement", "Element", "MapValue",
232-
"NewCall", "Call", "DecoratedClass", "DecoratedMember", "DecoratedParameter"
242+
"NewCall", "Call", "DecoratedClass", "DecoratedMember", "DecoratedParameter",
243+
"WithStringArgument"
233244
]
234245
}
235246

@@ -253,4 +264,8 @@ bindingset[name, argument]
253264
predicate isExtraValidTokenArgumentInIdentifyingAccessPath(string name, string argument) {
254265
name = ["Member"] and
255266
exists(argument)
267+
or
268+
name = "WithStringArgument" and
269+
exists(argument.indexOf("=")) and
270+
exists(AccessPath::parseIntWithArity(argument.splitAt("=", 0), 10))
256271
}

0 commit comments

Comments
 (0)