Skip to content

Commit 59b94b3

Browse files
committed
revert back to having 2 separate cases in JQuery::MethodCall
1 parent 9fc29ee commit 59b94b3

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

javascript/ql/src/semmle/javascript/frameworks/jQuery.qll

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,12 @@ module JQuery {
538538
MethodCall() {
539539
this = dollarCall() and name = "$"
540540
or
541+
this = ([dollar(), objectRef()]).getAMemberCall(name)
542+
or
541543
// Handle basic dynamic method dispatch (e.g. `$element[html ? 'html' : 'text'](content)`)
542544
exists(DataFlow::PropRead read | read = this.getCalleeNode() |
543545
read.getBase().getALocalSource() = [dollar(), objectRef()] and
544-
(
545-
read.getPropertyNameExpr().flow().mayHaveStringValue(name) or
546-
read.getPropertyName() = name
547-
)
546+
read.getPropertyNameExpr().flow().mayHaveStringValue(name)
548547
)
549548
or
550549
// Handle contributed JQuery objects that aren't source nodes (usually parameter uses)

javascript/ql/test/query-tests/Security/CWE-079/XssThroughDom.expected

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ nodes
3535
| xss-through-dom.js:61:30:61:69 | $(docum ... value") |
3636
| xss-through-dom.js:61:30:61:69 | $(docum ... value") |
3737
| xss-through-dom.js:61:30:61:69 | $(docum ... value") |
38+
| xss-through-dom.js:64:30:64:40 | valMethod() |
39+
| xss-through-dom.js:64:30:64:40 | valMethod() |
40+
| xss-through-dom.js:64:30:64:40 | valMethod() |
3841
edges
3942
| xss-through-dom.js:2:16:2:34 | $("textarea").val() | xss-through-dom.js:2:16:2:34 | $("textarea").val() |
4043
| xss-through-dom.js:4:16:4:40 | $(".som ... .text() | xss-through-dom.js:4:16:4:40 | $(".som ... .text() |
@@ -48,6 +51,7 @@ edges
4851
| xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name | xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name |
4952
| xss-through-dom.js:57:30:57:67 | $("inpu ... "name") | xss-through-dom.js:57:30:57:67 | $("inpu ... "name") |
5053
| xss-through-dom.js:61:30:61:69 | $(docum ... value") | xss-through-dom.js:61:30:61:69 | $(docum ... value") |
54+
| xss-through-dom.js:64:30:64:40 | valMethod() | xss-through-dom.js:64:30:64:40 | valMethod() |
5155
#select
5256
| xss-through-dom.js:2:16:2:34 | $("textarea").val() | xss-through-dom.js:2:16:2:34 | $("textarea").val() | xss-through-dom.js:2:16:2:34 | $("textarea").val() | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:2:16:2:34 | $("textarea").val() | DOM text |
5357
| xss-through-dom.js:4:16:4:40 | $(".som ... .text() | xss-through-dom.js:4:16:4:40 | $(".som ... .text() | xss-through-dom.js:4:16:4:40 | $(".som ... .text() | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:4:16:4:40 | $(".som ... .text() | DOM text |
@@ -61,3 +65,4 @@ edges
6165
| xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name | xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name | xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:56:30:56:51 | $("inpu ... 0).name | DOM text |
6266
| xss-through-dom.js:57:30:57:67 | $("inpu ... "name") | xss-through-dom.js:57:30:57:67 | $("inpu ... "name") | xss-through-dom.js:57:30:57:67 | $("inpu ... "name") | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:57:30:57:67 | $("inpu ... "name") | DOM text |
6367
| xss-through-dom.js:61:30:61:69 | $(docum ... value") | xss-through-dom.js:61:30:61:69 | $(docum ... value") | xss-through-dom.js:61:30:61:69 | $(docum ... value") | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:61:30:61:69 | $(docum ... value") | DOM text |
68+
| xss-through-dom.js:64:30:64:40 | valMethod() | xss-through-dom.js:64:30:64:40 | valMethod() | xss-through-dom.js:64:30:64:40 | valMethod() | Cross-site scripting vulnerability due to $@. | xss-through-dom.js:64:30:64:40 | valMethod() | DOM text |

javascript/ql/test/query-tests/Security/CWE-079/xss-through-dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161
$("#id").get(0).innerHTML = $(document).find("option").attr("value"); // NOT OK.
6262

6363
var valMethod = $("textarea").val;
64-
$("#id").get(0).innerHTML = valMethod(); // OK - Not a method call, not valid receiver for jQuery.
64+
$("#id").get(0).innerHTML = valMethod(); // NOT OK
6565
})();

0 commit comments

Comments
 (0)