Skip to content

Commit 5d901ef

Browse files
committed
move extend aliasing to getAnAliasedSourceNode
1 parent 2d907f8 commit 5d901ef

File tree

3 files changed

+13
-15
lines changed

3 files changed

+13
-15
lines changed

javascript/ql/lib/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,17 @@ module AccessPath {
426426
result = AccessPath::getAReferenceTo(root, accessPath)
427427
)
428428
or
429+
// step over extend calls. Handle aliasing both ways through the extend call.
430+
exists(
431+
DataFlow::SourceNode rootOne, DataFlow::SourceNode rootTwo, string accessPath,
432+
ExtendCall extendCall
433+
|
434+
rootOne = [extendCall, extendCall.getAnOperand().getALocalSource()] and
435+
rootTwo = [extendCall, extendCall.getAnOperand().getALocalSource()] and
436+
node = pragma[only_bind_into](AccessPath::getAReferenceTo(rootOne, accessPath)) and
437+
result = AccessPath::getAReferenceTo(rootTwo, accessPath)
438+
)
439+
or
429440
result = node.getALocalSource()
430441
}
431442

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

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,8 @@ private predicate aliasPropertyPresenceStepHelper(
7676
) {
7777
exists(PropertyPresenceSanitizer sanitizer |
7878
src = sanitizer.getPropRead() and
79+
sink = AccessPath::getAnAliasedSourceNode(src) and
7980
srcBB = src.getBasicBlock() and
80-
sinkBB = sink.getBasicBlock() and
81-
(
82-
sink = AccessPath::getAnAliasedSourceNode(src)
83-
or
84-
// step over extend calls
85-
exists(ExtendCall extendCall, string prop |
86-
src = extendCall.getASourceOperand().getALocalSource().getAPropertyReference(prop) and
87-
sink =
88-
[extendCall, extendCall.getDestinationOperand()]
89-
.(DataFlow::SourceNode)
90-
.getAPropertyReference(prop)
91-
)
92-
)
81+
sinkBB = sink.getBasicBlock()
9382
)
9483
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
WARNING: Unused predicate sink (/home/erik/dev/code/ql/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql:30,6-10)
2-
WARNING: Unused predicate source (/home/erik/dev/code/ql/javascript/ql/src/Security/CWE-079/UnsafeJQueryPlugin.ql:28,10-16)
31
nodes
42
| unsafe-jquery-plugin.js:2:38:2:44 | options |
53
| unsafe-jquery-plugin.js:2:38:2:44 | options |

0 commit comments

Comments
 (0)