Improve detection of UMD modules.

We previously required the `define` to appear directly as an expression statement, but there are common patterns where this is not the case.
This commit is contained in:
Max Schaefer
2022-03-30 10:48:49 +01:00
committed by Erik Krogh Kristensen
parent 47e425a184
commit ea70aaff57
3 changed files with 35 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
import javascript
private import semmle.javascript.internal.CachedStages
private import Expressions.ExprHasNoEffect
/**
* An AMD `define` call.
@@ -26,7 +27,7 @@ private import semmle.javascript.internal.CachedStages
*/
class AmdModuleDefinition extends CallExpr {
AmdModuleDefinition() {
getParent() instanceof ExprStmt and
inVoidContext(this) and
getCallee().(GlobalVarAccess).getName() = "define" and
exists(int n | n = getNumArgument() |
n = 1