Skip to content

Add lodash GroupBy as taint step #19768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Vasco-jofra
Copy link

Adds _.groupBy as a taint step.

This is analogous to the GroupByTaintStep class, which does the same for Object and Map.

https://github.com/github/codeql/blob/d83cbde1cb1263fb476a55ea5fd7972307138905/javascript/ql/lib/semmle/javascript/Collections.qll#L158C1-L166C4

@Vasco-jofra Vasco-jofra requested a review from a team as a code owner June 13, 2025 22:18
@github-actions github-actions bot added the JS label Jun 13, 2025
override predicate propagatesFlow(string input, string output, boolean preservesValue) {
input = "Argument[0]" and
output = ["Argument[1].Parameter[0]", "ReturnValue"] and
preservesValue = false
Copy link
Contributor

Choose a reason for hiding this comment

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

The relevant implementation for Map.groupBy is here:

override predicate propagatesFlow(string input, string output, boolean preservesValue) {
preservesValue = true and
(
input = "Argument[0].ArrayElement" and
output = ["Argument[1].Parameter[0]", "ReturnValue.MapValue.ArrayElement"]
or
input = "Argument[1].ReturnValue" and
output = "ReturnValue.MapKey"
)
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants