Skip to content

Commit 61a7ee9

Browse files
committed
JS: Use getABoundFunctionValue instead of type-tracking
1 parent 32d7a80 commit 61a7ee9

File tree

2 files changed

+3
-21
lines changed

2 files changed

+3
-21
lines changed

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

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -563,25 +563,6 @@ module JQuery {
563563
}
564564
}
565565

566-
/** Gets a data flow node that reaches a sink that is interpreted as HTML. */
567-
private DataFlow::SourceNode htmlCallback(DataFlow::TypeBackTracker t) {
568-
t.start() and
569-
any(JQuery::MethodCall c).interpretsArgumentAsHtml(result.getALocalUse())
570-
or
571-
exists(DataFlow::TypeBackTracker t2 | result = htmlCallback(t2).backtrack(t2, t))
572-
}
573-
574-
/**
575-
* Gets a function that is passed as a callback to a jQuery function, which will interpret its return value as HTML.
576-
*
577-
* For example, this gets the function `f` below:
578-
* ```js
579-
* function f() { ... }
580-
* $('#foo').replaceWith(f);
581-
* ```
582-
*/
583-
DataFlow::FunctionNode htmlCallback() { result = htmlCallback(DataFlow::TypeBackTracker::end()) }
584-
585566
/**
586567
* Holds for jQuery plugin definitions of the form `$.fn.<pluginName> = <plugin>` or `$.extend($.fn, {<pluginName>, <plugin>})`.
587568
*/

javascript/ql/lib/semmle/javascript/security/dataflow/DomBasedXssQuery.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ class Configuration extends TaintTracking::Configuration {
123123
inlbl = TaintedUrlSuffix::label() and
124124
outlbl = prefixLabel()
125125
or
126-
exists(DataFlow::FunctionNode callback |
127-
callback = JQuery::htmlCallback() and
126+
exists(DataFlow::FunctionNode callback, DataFlow::Node arg |
127+
any(JQuery::MethodCall c).interpretsArgumentAsHtml(arg) and
128+
callback = arg.getABoundFunctionValue(_) and
128129
src = callback.getReturnNode() and
129130
trg = callback and
130131
inlbl = outlbl

0 commit comments

Comments
 (0)