JS: Add test case

This commit is contained in:
Asger Feldthaus
2020-11-23 16:16:50 +00:00
parent ac00e02855
commit b6b8a55b37
3 changed files with 32 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
import { foo } from 'mylibrary';
foo({ value: 1 }, { value: 1 });
foo({ value: 2 }, { value: 2 });

View File

@@ -0,0 +1,3 @@
ERROR: Could not resolve predicate getArgument/1 (/Users/asger/git/code/ql/javascript/ql/src/semmle/javascript/frameworks/NoSQL.qll:716,60-71)
ERROR: Could not resolve predicate getParameter/1 (/Users/asger/git/code/ql/javascript/ql/src/semmle/javascript/frameworks/NoSQL.qll:719,40-52)
ERROR: Could not resolve type API::MethodCallNode (/Users/asger/git/code/ql/javascript/ql/src/semmle/javascript/frameworks/NoSQL.qll:705,51-70)

View File

@@ -0,0 +1,25 @@
import javascript
class FooCall extends API::CallNode {
FooCall() {
this = API::moduleImport("mylibrary").getMember("foo").getACall()
}
DataFlow::Node getFirst() {
result = getParameter(0).getMember("value").getARhs()
}
DataFlow::Node getSecond() {
result = getParameter(1).getMember("value").getARhs()
}
}
query predicate values(FooCall call, int first, int second) {
first = call.getFirst().getIntValue() and
second = call.getSecond().getIntValue()
}
query predicate mismatch(FooCall call, string msg) {
call.getFirst().getIntValue() != call.getSecond().getIntValue() and
msg = "mismatching parameter indices found for call"
}