Visitar URL original
JS: Fix `Map` content flow by MathiasVP · Pull Request #22781 · github/codeql · GitHub
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@ class MapConstructor extends SummarizedCallable::Range {
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
preservesValue = true and
(
input = "Argument[0]." + ["ArrayElement", "SetElement", "IteratorElement"] + ".Member[0]" and
input =
"Argument[0]." + ["ArrayElement", "SetElement", "IteratorElement"] + ".ArrayElement[0]" and
Comment on lines +23 to +24

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm @asgerf this sounds right. What do you say here?

output = "ReturnValue.MapKey"
or
input = "Argument[0]." + ["ArrayElement", "SetElement", "IteratorElement"] + ".Member[1]" and
input =
"Argument[0]." + ["ArrayElement", "SetElement", "IteratorElement"] + ".ArrayElement[1]" and
output = "ReturnValue.MapValue"
or
input = ["Argument[0].WithMapKey", "Argument[0].WithMapValue"] and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ postIsInSameCallable
reverseRead
| tst.js:109:11:113:3 | [dynamic parameter array] | Origin of readStep is missing a PostUpdateNode. |
| tst.js:267:28:267:31 | map3 | Origin of readStep is missing a PostUpdateNode. |
| tst.js:305:30:305:43 | constructedMap | Origin of readStep is missing a PostUpdateNode. |
argHasPostUpdate
postWithInFlow
viableImplInCallContextTooLarge
Expand Down
8 changes: 8 additions & 0 deletions javascript/ql/test/library-tests/FlowSummary/tst.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,11 @@ function m18() {
sink(dynamicParam1("safe", ...[source()])); // NOT OK
sink(dynamicParam1(source(), ...["safe"])); // OK
}

function m19() {
const constructedMap = new Map([["key", source()]]);
for (const [key, value] of constructedMap) {
sink(key); // OK
sink(value); // NOT OK
}
}
Loading