JS: Align DOM::locationRef with isDocumentURL

This commit is contained in:
Asger F
2019-05-22 15:51:39 +01:00
parent 8590042a7e
commit 8b7dbf8b0f
3 changed files with 11 additions and 12 deletions

View File

@@ -326,7 +326,15 @@ module DOM {
private class DefaultRange extends Range {
DefaultRange() {
this = domValueRef().getAPropertyRead("location")
exists(string propName | this = documentRef().getAPropertyRead(propName) |
propName = "documentURI" or
propName = "documentURIObject" or
propName = "location" or
propName = "referrer" or
propName = "URL"
)
or
this = DOM::domValueRef().getAPropertyRead("baseUri")
or
this = DataFlow::globalVarRef("location")
}

View File

@@ -38,17 +38,7 @@ predicate isDocument(Expr e) { DOM::documentRef().flowsToExpr(e) }
/** Holds if `e` could refer to the document URL. */
predicate isDocumentURL(Expr e) {
exists(string propName | e = DOM::documentRef().getAPropertyRead(propName).asExpr() |
propName = "documentURI" or
propName = "documentURIObject" or
propName = "location" or
propName = "referrer" or
propName = "URL"
)
or
e = DOM::domValueRef().getAPropertyRead("baseUri").asExpr()
or
e.accessesGlobal("location")
DOM::locationRef().flowsToExpr(e)
}
/**

View File

@@ -1,5 +1,6 @@
test_documentRef
| customization.js:2:13:2:31 | customGetDocument() |
test_locationRef
| customization.js:3:3:3:14 | doc.location |
test_domValueRef
| customization.js:4:3:4:28 | doc.get ... 'test') |