diff --git a/javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.expected b/javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.ql b/javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.ql new file mode 100644 index 000000000000..3c51eecf21f0 --- /dev/null +++ b/javascript/ql/test/ApiGraphs/custom-use-steps/VerifyAssertions.ql @@ -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() + ) + } +} diff --git a/javascript/ql/test/ApiGraphs/custom-use-steps/index.js b/javascript/ql/test/ApiGraphs/custom-use-steps/index.js new file mode 100644 index 000000000000..6302c9f2e8cf --- /dev/null +++ b/javascript/ql/test/ApiGraphs/custom-use-steps/index.js @@ -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") diff --git a/javascript/ql/test/ApiGraphs/custom-use-steps/package.json b/javascript/ql/test/ApiGraphs/custom-use-steps/package.json new file mode 100644 index 000000000000..71206e92e6bf --- /dev/null +++ b/javascript/ql/test/ApiGraphs/custom-use-steps/package.json @@ -0,0 +1,3 @@ +{ + "name": "custom-use-steps" +}