Skip to content

Commit 14a7f46

Browse files
authored
Merge pull request #22784 from asgerf/js/fix-member-token
JS: Fix parsing of Member[num] token in summaries
2 parents 65f9256 + 3f9e584 commit 14a7f46

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎javascript/ql/lib/semmle/javascript/dataflow/internal/FlowSummaryPrivate.qll‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,10 @@ ArgumentPosition decodeUnknownArgumentPosition(AccessPathSyntax::AccessPathToken
252252
* `encodeContent` predicate.
253253
*/
254254
bindingset[token]
255-
ContentSet decodeUnknownContent(AccessPathSyntax::AccessPathTokenBase token) { none() }
255+
ContentSet decodeUnknownContent(AccessPathSyntax::AccessPathTokenBase token) {
256+
token.getName() = "Member" and
257+
result.asPropertyName() = token.getAnArgument()
258+
}
256259

257260
/**
258261
* Gets a return kind corresponding to the unknown token `token`.

‎javascript/ql/test/library-tests/FlowSummary/DataFlowConsistency.expected‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ postIsInSameCallable
1818
reverseRead
1919
| tst.js:109:11:113:3 | [dynamic parameter array] | Origin of readStep is missing a PostUpdateNode. |
2020
| tst.js:267:28:267:31 | map3 | Origin of readStep is missing a PostUpdateNode. |
21+
| tst.js:305:30:305:43 | constructedMap | Origin of readStep is missing a PostUpdateNode. |
2122
argHasPostUpdate
2223
postWithInFlow
2324
viableImplInCallContextTooLarge

‎javascript/ql/test/library-tests/FlowSummary/tst.js‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,3 +299,11 @@ function m18() {
299299
sink(dynamicParam1("safe", ...[source()])); // NOT OK
300300
sink(dynamicParam1(source(), ...["safe"])); // OK
301301
}
302+
303+
function m19() {
304+
const constructedMap = new Map([["key", source()]]);
305+
for (const [key, value] of constructedMap) {
306+
sink(key); // OK
307+
sink(value); // NOT OK
308+
}
309+
}

0 commit comments

Comments
 (0)