Skip to content

Commit 742c970

Browse files
author
Max Schaefer
authored
Merge pull request #1828 from asger-semmle/jsdoc-relation
JS: Make getDocumentation handle chain assignments
2 parents 0cf872e + 4594186 commit 742c970

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

change-notes/1.23/analysis-javascript.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@
1818
| Client-side cross-site scripting (`js/xss`) | More results | More potential vulnerabilities involving functions that manipulate DOM attributes are now recognized. |
1919

2020
## Changes to QL libraries
21+
22+
* `Expr.getDocumentation()` now handles chain assignments.

javascript/ql/src/semmle/javascript/Expr.qll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ class ExprOrType extends @exprortype, Documentable {
5555
exists(DotExpr dot | this = dot.getProperty() |
5656
result = dot.getDocumentation()
5757
)
58+
or
59+
exists(AssignExpr e | this = e.getRhs() |
60+
result = e.getDocumentation()
61+
)
62+
or
63+
exists(ParExpr p | this = p.getExpression() |
64+
result = p.getDocumentation()
65+
)
5866
)
5967
}
6068

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
| tst.js:4:4:4:9 | @param | @param tag refers to non-existent parameter prameter. |
22
| tst.js:12:4:12:9 | @param | @param tag refers to non-existent parameter sign. |
3+
| tst.js:51:4:51:9 | @param | @param tag refers to non-existent parameter opts. |
4+
| tst.js:57:4:57:9 | @param | @param tag refers to non-existent parameter opts. |

javascript/ql/test/query-tests/JSDoc/JSDocForNonExistentParameter/tst.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,16 @@ function good3() {
4545
lastName = arguments[0];
4646
}
4747
return firstName + sep + lastName;
48-
}
48+
}
49+
50+
/**
51+
* @param {IncomingMessage} opts
52+
*/
53+
var Cookie = foo.bar = function Cookie(options) {
54+
}
55+
56+
/**
57+
* @param {IncomingMessage} opts
58+
*/
59+
Cookie2 = foo.bar2 = function Cookie2(options) {
60+
}

0 commit comments

Comments
 (0)