Skip to content

Change definition of getFactoryNodeInternal #19359

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 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion javascript/ql/lib/semmle/javascript/AMD.qll
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ class AmdModuleDefinition extends CallExpr instanceof AmdModuleDefinition::Range
Function getFactoryFunction() { TValueNode(result) = this.getFactoryNodeInternal() }

private EarlyStageNode getFactoryNodeInternal() {
result = TValueNode(this.getLastArgument())
exists(Function factoryFunction | factoryFunction = this.getArgument(_) |
result = TValueNode(factoryFunction)
)
Copy link
Contributor

Choose a reason for hiding this comment

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

The restriction to Function here is too restrictive as we may need to follow some local flow steps before we get to the function (see the recursive case below). Some tests are failing because of this. Could you try simply changing getLastArgument() to getArgument(_)?

or
DataFlow::localFlowStep(result, this.getFactoryNodeInternal())
}
Expand Down
Loading