mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
JS: Make inline CG tests report call target if NONE was given
Previously it would only report a spurious callee if the target function was named. Now, if specifying 'calls:NONE' if will report any callee as spurious.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
spuriousCallee
|
||||
| accessors.js:54:1:54:7 | new D() | accessors.js:32:9:32:8 | () {} | -1 | calls |
|
||||
missingCallee
|
||||
| constructor-field.ts:40:5:40:14 | f3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
|
||||
| constructor-field.ts:71:1:71:11 | bf3.build() | constructor-field.ts:13:3:13:12 | build() {} | -1 | calls |
|
||||
|
||||
@@ -58,20 +58,23 @@ class AnnotatedCall extends DataFlow::Node {
|
||||
string getKind() { result = kind }
|
||||
}
|
||||
|
||||
predicate callEdge(AnnotatedCall call, AnnotatedFunction target, int boundArgs) {
|
||||
predicate callEdge(AnnotatedCall call, Function target, int boundArgs) {
|
||||
FlowSteps::calls(call, target) and boundArgs = -1
|
||||
or
|
||||
FlowSteps::callsBound(call, target, boundArgs)
|
||||
}
|
||||
|
||||
query predicate spuriousCallee(
|
||||
AnnotatedCall call, AnnotatedFunction target, int boundArgs, string kind
|
||||
) {
|
||||
query predicate spuriousCallee(AnnotatedCall call, Function target, int boundArgs, string kind) {
|
||||
callEdge(call, target, boundArgs) and
|
||||
kind = call.getKind() and
|
||||
not (
|
||||
target = call.getAnExpectedCallee(kind) and
|
||||
boundArgs = call.getBoundArgsOrMinusOne()
|
||||
) and
|
||||
(
|
||||
target instanceof AnnotatedFunction
|
||||
or
|
||||
call.getCallTargetName() = "NONE"
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user