Add lodash GroupBy as taint step#19768
Conversation
| override predicate propagatesFlow(string input, string output, boolean preservesValue) { | ||
| input = "Argument[0]" and | ||
| output = ["Argument[1].Parameter[0]", "ReturnValue"] and | ||
| preservesValue = false |
There was a problem hiding this comment.
The relevant implementation for Map.groupBy is here:
codeql/javascript/ql/lib/semmle/javascript/internal/flow_summaries/Maps.qll
Lines 130 to 139 in 93c891a
This would be the closest matching implementation for _.groupBy I think:
preservesValue = true and
input = "Argument[0].ArrayElement" and
output = ["Argument[1].Parameter[0]", "ReturnValue.AnyMember.ArrayElement"] Note that there is currently no content corresponding to MapKey for the keys of a plain object.
There was a problem hiding this comment.
I based it on:
codeql/javascript/ql/lib/semmle/javascript/Collections.qll
Lines 158 to 166 in 4d2c678
Is there a reason for having these two implementations for Map.groupBy?
Happy to update to your suggestion if you feel that's the best solution. We should add tests for the lodash library, though; they are currently very minimal.
Adds
_.groupByas a taint step.This is analogous to the
GroupByTaintStepclass, which does the same forObjectandMap.https://github.com/github/codeql/blob/d83cbde1cb1263fb476a55ea5fd7972307138905/javascript/ql/lib/semmle/javascript/Collections.qll#L158C1-L166C4