Skip to content

Commit 0c081a8

Browse files
authored
Merge pull request #3497 from esbena/js/yield-and-local-objects
Approved by asgerf, erik-krogh
2 parents 0d76206 + a9ba6ac commit 0c081a8

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
@@ -41,6 +41,7 @@
4141
| Unknown directive (`js/unknown-directive`) | Less results | This query no longer flags directives generated by the Babel compiler. |
4242
| Code injection (`js/code-injection`) | More results | More potential vulnerabilities involving NoSQL code operators are now recognized. |
4343
| Zip Slip (`js/zipslip`) | More results | This query now recognizes additional vulnerabilities. |
44+
| Unused property (`js/unused-property`) | Less results | This query no longer flags properties of objects that are operands of `yield` expressions. |
4445

4546
## Changes to libraries
4647

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)