Skip to content

JS: Minor fixes to package export detection#3662

Merged
semmle-qlci merged 4 commits intogithub:js-team-sprintfrom
asger-semmle:js/package-export-fixes
Jun 12, 2020
Merged

JS: Minor fixes to package export detection#3662
semmle-qlci merged 4 commits intogithub:js-team-sprintfrom
asger-semmle:js/package-export-fixes

Conversation

@asgerf
Copy link
Contributor

@asgerf asgerf commented Jun 9, 2020

Two minor fixes that were needed to detect the exported members of the package in https://github.com/github/codeql-javascript-CVE-coverage/issues/80.

The first commit removes an if and instead uses the priority to choose between the two alternatives. (I imagine this could eventually be unified with the entry-point guessing logic from the WIP monorepo support.)

@max-schaefer the first commit might be relevant for you.

@asgerf asgerf added the JS label Jun 9, 2020
@asgerf asgerf marked this pull request as ready for review June 10, 2020 13:08
@asgerf asgerf requested a review from a team as a code owner June 10, 2020 13:08
@esbena esbena self-assigned this Jun 10, 2020
result.analyze().getAValue() = mod.(NodeModule).getAModuleExportsValue()
or
exists(ASTNode export | result.getEnclosingExpr() = export | mod.exports(_, export))
or
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not understand this change. Can you elaborate with a comment?

I would expect the above cases to handle the added case. If they didn't, why? And why not add yet another subclass of Module with a Module::experts that handles this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that Module::exports just exposes an ASTNode and there is no reliable way to map that to the correct data-flow node. It would be great to modernize that abstraction but I don't think this PR is the right place to do that.

@semmle-qlci semmle-qlci merged commit 2342d3d into github:js-team-sprint Jun 12, 2020
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.

3 participants