Merge pull request #2254 from asger-semmle/for-of-propread

Approved by max-schaefer
This commit is contained in:
semmle-qlci
2019-11-06 13:44:55 +00:00
committed by GitHub
6 changed files with 43 additions and 1 deletions

View File

@@ -741,7 +741,8 @@ module DataFlow {
PropReadAsSourceNode() {
this = TPropNode(any(PropertyPattern p)) or
this instanceof RestPatternNode or
this instanceof ElementPatternNode
this instanceof ElementPatternNode or
this = lvalueNode(any(ForOfStmt stmt).getLValue())
}
}
@@ -826,6 +827,24 @@ module DataFlow {
override string getPropertyName() { result = astNode.getImportedName() }
}
/**
* The left-hand side of a `for..of` statement, seen as a property read
* on the object being iterated over.
*/
private class ForOfLvalueAsPropRead extends PropRead {
ForOfStmt stmt;
ForOfLvalueAsPropRead() {
this = lvalueNode(stmt.getLValue())
}
override Node getBase() { result = stmt.getIterationDomain().flow() }
override Expr getPropertyNameExpr() { none() }
override string getPropertyName() { none() }
}
/**
* A data flow node representing an unused parameter.
*