Skip to content

Commit a9ba6ac

Browse files
committed
JS: make LocalObjects::isEscape aware of yield
1 parent 14664be commit a9ba6ac

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

change-notes/1.25/analysis-javascript.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
| Unknown directive (`js/unknown-directive`) | Less results | This query no longer flags directives generated by the Babel compiler. |
3434
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
3535
| Zip Slip (`js/zipslip`) | More results | This query now recognizes additional vulnerabilities. |
36+
| Unused property (`js/unused-property`) | Less results | This query no longer flags properties of objects that are operands of `yield` expressions. |
3637

3738
## Changes to libraries
3839

javascript/ql/src/semmle/javascript/dataflow/LocalObjects.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ private predicate isEscape(DataFlow::Node escape, string cause) {
1212
or
1313
escape = any(DataFlow::FunctionNode fun).getAReturn() and cause = "return"
1414
or
15+
escape = any(YieldExpr yield).getOperand().flow() and cause = "yield"
16+
or
1517
escape = any(ThrowStmt t).getExpr().flow() and cause = "throw"
1618
or
1719
escape = any(GlobalVariable v).getAnAssignedExpr().flow() and cause = "global"

javascript/ql/test/library-tests/LocalObjects/tst.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,9 @@
8989
let bound = {};
9090
bound::unknown();
9191
});
92+
93+
(async function* f() {
94+
yield* {
95+
get p() { }
96+
};
97+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
async function* f() {
2+
yield* {
3+
get p() { }
4+
};
5+
}

0 commit comments

Comments
 (0)