mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
JS: Add test case
This commit is contained in:
4
javascript/ql/test/ApiGraphs/call-nodes/index.js
Normal file
4
javascript/ql/test/ApiGraphs/call-nodes/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
import { foo } from 'mylibrary';
|
||||
|
||||
foo({ value: 1 }, { value: 1 });
|
||||
foo({ value: 2 }, { value: 2 });
|
||||
3
javascript/ql/test/ApiGraphs/call-nodes/test.expected
Normal file
3
javascript/ql/test/ApiGraphs/call-nodes/test.expected
Normal 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)
|
||||
25
javascript/ql/test/ApiGraphs/call-nodes/test.ql
Normal file
25
javascript/ql/test/ApiGraphs/call-nodes/test.ql
Normal 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"
|
||||
}
|
||||
Reference in New Issue
Block a user