mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
JavaScript: Teach InvalidExport to never flag module.exports = exports = ... and similar.
This was previously flagged if `exports` wasn't used any further. While it's true that the assignment to `exports` is redundant in this case, the assignment is also flagged by DeadStorOfLocal, so there is no point in InvalidExport flagging it as well.
This commit is contained in:
@@ -41,12 +41,8 @@ from Assignment assgn, Variable exportsVar, DataFlow::Node exportsVal
|
||||
where
|
||||
exportsAssign(assgn, exportsVar, exportsVal) and
|
||||
not exists(exportsVal.getAPredecessor()) and
|
||||
not (
|
||||
// this is OK if `exportsVal` flows into `module.exports`
|
||||
moduleExportsAssign(_, exportsVal) and
|
||||
// however, if there are no further uses of `exports` the assignment is useless anyway
|
||||
strictcount(exportsVar.getAnAccess()) > 1
|
||||
) and
|
||||
// this is OK if `exportsVal` flows into `module.exports`
|
||||
not moduleExportsAssign(_, exportsVal) and
|
||||
// export assignments do work in closure modules
|
||||
not assgn.getTopLevel() instanceof Closure::ClosureModule
|
||||
select assgn, "Assigning to 'exports' does not export anything."
|
||||
|
||||
Reference in New Issue
Block a user