Skip to content

Commit 8b7dbf8

Browse files
committed
JS: Align DOM::locationRef with isDocumentURL
1 parent 8590042 commit 8b7dbf8

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,15 @@ module DOM {
326326

327327
private class DefaultRange extends Range {
328328
DefaultRange() {
329-
this = domValueRef().getAPropertyRead("location")
329+
exists(string propName | this = documentRef().getAPropertyRead(propName) |
330+
propName = "documentURI" or
331+
propName = "documentURIObject" or
332+
propName = "location" or
333+
propName = "referrer" or
334+
propName = "URL"
335+
)
336+
or
337+
this = DOM::domValueRef().getAPropertyRead("baseUri")
330338
or
331339
this = DataFlow::globalVarRef("location")
332340
}

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

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +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-
exists(string propName | e = DOM::documentRef().getAPropertyRead(propName).asExpr() |
42-
propName = "documentURI" or
43-
propName = "documentURIObject" or
44-
propName = "location" or
45-
propName = "referrer" or
46-
propName = "URL"
47-
)
48-
or
49-
e = DOM::domValueRef().getAPropertyRead("baseUri").asExpr()
50-
or
51-
e.accessesGlobal("location")
41+
DOM::locationRef().flowsToExpr(e)
5242
}
5343

5444
/**
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
test_documentRef
22
| customization.js:2:13:2:31 | customGetDocument() |
33
test_locationRef
4+
| customization.js:3:3:3:14 | doc.location |
45
test_domValueRef
56
| customization.js:4:3:4:28 | doc.get ... 'test') |

0 commit comments

Comments
 (0)