mirror of
https://github.com/github/codeql.git
synced 2026-04-25 08:45:14 +02:00
Add new experimental query MultipleArgumentsToSetConstructor.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* @name Multiple arguments to `Set` constructor
|
||||
* @description The `Set` constructor ignores all but the first argument, so passing multiple
|
||||
* arguments may indicate a mistake.
|
||||
* @kind problem
|
||||
* @problem.severity warning
|
||||
* @precision high
|
||||
* @id js/multiple-arguments-to-set-constructor
|
||||
* @tags correctness
|
||||
*/
|
||||
|
||||
import javascript
|
||||
|
||||
from DataFlow::NewNode newSet, DataFlow::Node ignoredArg
|
||||
where
|
||||
newSet = DataFlow::globalVarRef("Set").getAnInstantiation() and
|
||||
(
|
||||
ignoredArg = newSet.getArgument(any(int n | n > 0))
|
||||
or
|
||||
ignoredArg = newSet.getASpreadArgument()
|
||||
)
|
||||
select ignoredArg, "All but the first argument to the Set constructor are ignored."
|
||||
Reference in New Issue
Block a user