diff --git a/docs/codeql/codeql-language-guides/codeql-library-for-javascript.rst b/docs/codeql/codeql-language-guides/codeql-library-for-javascript.rst index 8c9c6d8cffa..6742dfa8e76 100644 --- a/docs/codeql/codeql-language-guides/codeql-library-for-javascript.rst +++ b/docs/codeql/codeql-language-guides/codeql-library-for-javascript.rst @@ -193,7 +193,7 @@ The class `ASTNode `__, the standard Node.js ``http`` and ``https`` modules, `Connect `__, `Koa `__, `Hapi `__ and `Restify `__. diff --git a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/query17.qll b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/query17.qll index 0b21d872ad6..1de380f710b 100644 --- a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/query17.qll +++ b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/query17.qll @@ -11,11 +11,8 @@ class PasswordTracker extends DataFlow::Configuration { override predicate isSink(DataFlow::Node nd) { this.passwordVarAssign(_, nd) } predicate passwordVarAssign(Variable v, DataFlow::Node nd) { - exists(SsaExplicitDefinition def | - nd = DataFlow::ssaDefinitionNode(def) and - def.getSourceVariable() = v and - v.getName().toLowerCase() = "password" - ) + v.getAnAssignedExpr() = nd.asExpr() and + v.getName().toLowerCase() = "password" } } diff --git a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tests.expected b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tests.expected index 57bfd73841f..bbec34be602 100644 --- a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tests.expected +++ b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tests.expected @@ -9,6 +9,7 @@ test_query4 | tst.js:29:1:29:5 | 1 + 2 | This expression should be bracketed to clarify precedence rules. | test_query19 test_query17 +| tst.js:38:18:38:23 | "blah" | Password variable password is assigned a constant string. | test_query18 | m.js:1:1:3:0 | | 0 | test_query8 @@ -18,6 +19,7 @@ test_query11 | tst.js:31:12:31:12 | x | Dead store of local variable. | | tst.js:31:15:31:15 | y | Dead store of local variable. | | tst.js:31:18:31:18 | x | Dead store of local variable. | +| tst.js:38:7:38:23 | password = "blah" | Dead store of local variable. | test_query12 test_query20 test_query3 diff --git a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tst.js b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tst.js index 804012a2673..0714ee8101a 100644 --- a/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tst.js +++ b/javascript/ql/test/tutorials/Introducing the JavaScript libraries/tst.js @@ -32,4 +32,8 @@ function l(x, y, x) { for (i=0;i<10;++i); } -var j, j; \ No newline at end of file +var j, j; + +function foo() { + var password = "blah"; +}