Skip to content

Commit 2fc0ab5

Browse files
committed
JS: Stop using the AST-based isDocumentURL internally
1 parent 8b7dbf8 commit 2fc0ab5

File tree

8 files changed

+11
-11
lines changed

8 files changed

+11
-11
lines changed

javascript/ql/src/semmle/javascript/security/dataflow/ClientSideUrlRedirect.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ module ClientSideUrlRedirect {
4040
override predicate isSource(DataFlow::Node source) { source instanceof Source }
4141

4242
override predicate isSource(DataFlow::Node source, DataFlow::FlowLabel lbl) {
43-
isDocumentURL(source.asExpr()) and
43+
source = DOM::locationSource() and
4444
lbl instanceof DocumentUrl
4545
}
4646

javascript/ql/src/semmle/javascript/security/dataflow/CodeInjection.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ module CodeInjection {
5151
/**
5252
* An access to a property that may hold (parts of) the document URL.
5353
*/
54-
class LocationSource extends Source, DataFlow::ValueNode {
55-
LocationSource() { isDocumentURL(astNode) }
54+
class LocationSource extends Source {
55+
LocationSource() { this = DOM::locationSource() }
5656
}
5757

5858
/**

javascript/ql/src/semmle/javascript/security/dataflow/DOM.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ predicate isDocument(Expr e) { DOM::documentRef().flowsToExpr(e) }
3838

3939
/** Holds if `e` could refer to the document URL. */
4040
predicate isDocumentURL(Expr e) {
41-
DOM::locationRef().flowsToExpr(e)
41+
e.flow() = DOM::locationSource()
4242
}
4343

4444
/**

javascript/ql/src/semmle/javascript/security/dataflow/DomBasedXss.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ module DomBasedXss {
4242
/**
4343
* An access of the URL of this page, or of the referrer to this page.
4444
*/
45-
class LocationSource extends Source, DataFlow::ValueNode {
46-
LocationSource() { isDocumentURL(astNode) }
45+
class LocationSource extends Source {
46+
LocationSource() { this = DOM::locationSource() }
4747
}
4848
}

javascript/ql/src/semmle/javascript/security/dataflow/UnsafeDynamicMethodAccess.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ module UnsafeDynamicMethodAccess {
110110
* The page URL considered as a flow source for unsafe dynamic method access.
111111
*/
112112
class DocumentUrlAsSource extends Source {
113-
DocumentUrlAsSource() { isDocumentURL(asExpr()) }
113+
DocumentUrlAsSource() { this = DOM::locationSource() }
114114
}
115115

116116
/**

javascript/ql/src/semmle/javascript/security/dataflow/UnvalidatedDynamicMethodCall.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ module UnvalidatedDynamicMethodCall {
102102
* The page URL considered as a flow source for unvalidated dynamic method calls.
103103
*/
104104
class DocumentUrlAsSource extends Source {
105-
DocumentUrlAsSource() { isDocumentURL(asExpr()) }
105+
DocumentUrlAsSource() { this = DOM::locationSource() }
106106
}
107107

108108
/**

javascript/ql/src/semmle/javascript/security/dataflow/XpathInjection.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ module XpathInjection {
6464
}
6565

6666
/** A part of the document URL, considered as a flow source for XPath injection. */
67-
class DocumentUrlSource extends Source, DataFlow::ValueNode {
68-
DocumentUrlSource() { isDocumentURL(astNode) }
67+
class DocumentUrlSource extends Source {
68+
DocumentUrlSource() { this = DOM::locationSource() }
6969
}
7070

7171
/**

javascript/ql/src/semmle/javascript/security/dataflow/Xss.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ module DomBasedXss {
7070
strval = prefix.getStringValue() and
7171
not strval.regexpMatch("\\s*<.*")
7272
) and
73-
not isDocumentURL(astNode)
73+
not DOM::locationRef().flowsTo(this)
7474
)
7575
or
7676
// call to an Angular method that interprets its argument as HTML

0 commit comments

Comments
 (0)