mirror of
https://github.com/github/codeql.git
synced 2025-12-22 11:46:32 +01:00
JS: Add more bad promise contexts
This commit is contained in:
@@ -46,6 +46,14 @@ predicate isBadPromiseContext(Expr expr) {
|
|||||||
expr = any(UnaryExpr e).getOperand()
|
expr = any(UnaryExpr e).getOperand()
|
||||||
or
|
or
|
||||||
expr = any(UpdateExpr e).getOperand()
|
expr = any(UpdateExpr e).getOperand()
|
||||||
|
or
|
||||||
|
expr = any(ConditionalExpr e).getCondition()
|
||||||
|
or
|
||||||
|
expr = any(IfStmt stmt).getCondition()
|
||||||
|
or
|
||||||
|
expr = any(ForInStmt stmt).getIterationDomain()
|
||||||
|
or
|
||||||
|
expr = any(IndexExpr e).getIndex()
|
||||||
}
|
}
|
||||||
|
|
||||||
string tryGetPromiseExplanation(Expr e) {
|
string tryGetPromiseExplanation(Expr e) {
|
||||||
|
|||||||
@@ -1,2 +1,9 @@
|
|||||||
| tst.js:8:9:8:13 | thing | Missing await. The value 'thing' is always a promise. |
|
| tst.js:8:9:8:13 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
| tst.js:32:12:32:16 | thing | Missing await. The value 'thing' is always a promise. |
|
| tst.js:10:9:10:13 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:12:15:12:19 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:14:19:14:23 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:19:19:19:23 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:20:9:20:13 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:22:15:22:19 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:25:13:25:17 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
| tst.js:48:12:48:16 | thing | Missing await. The value 'thing' is always a promise. |
|
||||||
|
|||||||
@@ -9,7 +9,23 @@ function useThing() {
|
|||||||
|
|
||||||
if (thing == null) {} // NOT OK
|
if (thing == null) {} // NOT OK
|
||||||
|
|
||||||
return thing + "bar"; // NOT OK
|
something(thing ? 1 : 2); // NOT OK
|
||||||
|
|
||||||
|
for (let x in thing) { // NOT OK
|
||||||
|
something(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
let obj = something();
|
||||||
|
something(obj[thing]); // NOT OK
|
||||||
|
obj[thing] = 5; // NOT OK
|
||||||
|
|
||||||
|
something(thing + "bar"); // NOT OK
|
||||||
|
|
||||||
|
if (something()) {
|
||||||
|
if (thing) { // NOT OK
|
||||||
|
something(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function useThingCorrectly() {
|
async function useThingCorrectly() {
|
||||||
|
|||||||
Reference in New Issue
Block a user