JavaScript: Autoformat cookbook examples.

This commit is contained in:
Anders Schack-Mulligen
2019-08-02 15:33:40 +02:00
parent 40f2cec0de
commit 59fb59d109
33 changed files with 45 additions and 40 deletions

View File

@@ -1,7 +1,7 @@
/**
* @name Decoding after sanitization
* @description Tracks the return value of 'escapeHtml' into 'decodeURI', indicating
an ineffective sanitization attempt.
* an ineffective sanitization attempt.
* @kind path-problem
* @tags security
* @id js/examples/decoding-after-sanitization

View File

@@ -1,7 +1,7 @@
/**
* @name Decoding after sanitization (generalized)
* @description Tracks the return value of an HTML sanitizer into an escape-sequence decoder,
indicating an ineffective sanitization attempt.
* indicating an ineffective sanitization attempt.
* @kind path-problem
* @tags security
* @id js/examples/decoding-after-sanitization-generalized

View File

@@ -1,7 +1,7 @@
/**
* @name Information disclosure through postMessage
* @description Tracks values from an 'authKey' property into a postMessage call with unrestricted origin,
indicating a leak of sensitive information.
* indicating a leak of sensitive information.
* @kind path-problem
* @tags security
* @id js/examples/information-disclosure

View File

@@ -5,7 +5,7 @@
* @tags parameter
* arguments
*/
import javascript
from SimpleParameter p

View File

@@ -6,7 +6,7 @@
* function
* eval
*/
import javascript
from CallExpr c

View File

@@ -6,7 +6,7 @@
* callback
* higher-order
*/
import javascript
from InvokeExpr invk, DataFlow::FunctionNode f

View File

@@ -13,4 +13,4 @@ import javascript
from ClassDefinition c
where c.getConstructor().isSynthetic()
select c
select c

View File

@@ -12,4 +12,4 @@ import javascript
from ClassDefinition cd
where cd.getName() = "File"
select cd
select cd

View File

@@ -9,7 +9,7 @@
* index
* constant
*/
import javascript
from IndexExpr idx

View File

@@ -6,7 +6,7 @@
* block
* statement
*/
import javascript
from BlockStmt blk

View File

@@ -9,7 +9,7 @@
* conditional
* branch
*/
import javascript
from IfStmt i

View File

@@ -7,7 +7,7 @@
* non-strict
* expression statement
*/
import javascript
from ExprStmt e

View File

@@ -7,10 +7,13 @@
* comparison
* even
*/
import javascript
from StrictEqExpr eq, ModExpr mod, NumberLiteral zero, NumberLiteral two
where two.getValue() = "2" and mod.getRightOperand() = two and
zero.getValue() = "0" and eq.hasOperands(mod, two)
where
two.getValue() = "2" and
mod.getRightOperand() = two and
zero.getValue() = "0" and
eq.hasOperands(mod, two)
select eq

View File

@@ -13,4 +13,4 @@ import javascript
from ExportDefaultDeclaration e
where e.getOperand() instanceof Function
select e
select e

View File

@@ -4,7 +4,7 @@
* @description Finds files called `index.js`
* @tags file
*/
import javascript
from File f

View File

@@ -9,6 +9,7 @@
import javascript
from Function f
where exists(f.getABodyStmt()) and
not exists (ReturnStmt r | r.getContainer() = f)
select f
where
exists(f.getABodyStmt()) and
not exists(ReturnStmt r | r.getContainer() = f)
select f

View File

@@ -12,4 +12,4 @@ import javascript
from Function f
where f.isGenerator()
select f
select f

View File

@@ -6,7 +6,7 @@
* function
* immediately invoked
*/
import javascript
from CallExpr c

View File

@@ -12,4 +12,4 @@ import javascript
from ImportDeclaration id
where id.getImportedPath().getValue() = "react"
select id
select id

View File

@@ -5,7 +5,7 @@
* @tags JSX
* attribute
*/
import javascript
from JSXAttribute a

View File

@@ -5,10 +5,11 @@
* @tags call
* method
*/
import javascript
from MethodCallExpr c
where c.getReceiver() instanceof ThisExpr and
c.getMethodName() = "isMounted"
where
c.getReceiver() instanceof ThisExpr and
c.getMethodName() = "isMounted"
select c

View File

@@ -4,9 +4,9 @@
* @description Finds function expressions that have a name
* @tags function expression
*/
import javascript
from FunctionExpr fn
where exists(fn.getName())
select fn
select fn

View File

@@ -6,7 +6,7 @@
* constructor
* instantiation
*/
import javascript
from NewExpr new

View File

@@ -9,7 +9,7 @@
* write
* reference
*/
import javascript
from PropAccess p

View File

@@ -12,4 +12,4 @@ import javascript
from MethodDefinition m
where m.getName() = "render"
select m
select m

View File

@@ -6,7 +6,7 @@
* single quote
* quote
*/
import javascript
from StringLiteral s

View File

@@ -5,7 +5,7 @@
* @tags block
* statement
*/
import javascript
from BlockStmt b

View File

@@ -10,4 +10,4 @@
import javascript
from TaggedTemplateExpr e
select e.getTag(), e.getTemplate()
select e.getTag(), e.getTemplate()

View File

@@ -5,7 +5,7 @@
* @tags comment
* TODO
*/
import javascript
from Comment c

View File

@@ -6,7 +6,7 @@
* parameter
* argument
*/
import javascript
from Function f

View File

@@ -5,7 +5,7 @@
* @tags variable
* declaration
*/
import javascript
from VarDecl d

View File

@@ -5,7 +5,7 @@
* @tags variable
* reference
*/
import javascript
from VarRef ref

View File

@@ -12,4 +12,4 @@ import javascript
from YieldExpr yield
where not exists(yield.getOperand())
select yield
select yield