Skip to content

Commit

Permalink
JS: Add test for use steps
Browse files Browse the repository at this point in the history
  • Loading branch information
asgerf committed Apr 17, 2024
1 parent 2dcb5fb commit eab9698
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Empty file.
13 changes: 13 additions & 0 deletions javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.ql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ApiGraphs.VerifyAssertions
private import semmle.javascript.dataflow.internal.PreCallGraphStep

class CustomUseStep extends PreCallGraphStep {
override predicate loadStep(DataFlow::Node pred, DataFlow::Node succ, string prop) {
exists(DataFlow::CallNode call |
call.getCalleeName() = "customLoad" and
pred = call.getArgument(0) and
succ = call and
prop = call.getArgument(1).getStringValue()
)
}
}
4 changes: 4 additions & 0 deletions javascript/ql/test/ApiGraphs/custom-use-steps/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const foo = require("foo");

foo.bar; // use=moduleImport("foo").getMember("exports").getMember("bar")
customLoad(foo, "baz") // use=moduleImport("foo").getMember("exports").getMember("baz")
3 changes: 3 additions & 0 deletions javascript/ql/test/ApiGraphs/custom-use-steps/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "custom-use-steps"
}

0 comments on commit eab9698

Please sign in to comment.