mirror of
https://github.com/github/codeql.git
synced 2026-05-13 02:39:26 +02:00
merge in main
This commit is contained in:
@@ -21,10 +21,10 @@ import javascript
|
||||
|
||||
private DataFlow::Node getNode(API::Node nd, string kind) {
|
||||
kind = "def" and
|
||||
result = nd.getARhs()
|
||||
result = nd.asSink()
|
||||
or
|
||||
kind = "use" and
|
||||
result = nd.getAUse()
|
||||
result = nd.getAValueReachableFromSource()
|
||||
}
|
||||
|
||||
private string getLoc(DataFlow::Node nd) {
|
||||
@@ -84,8 +84,8 @@ class Assertion extends Comment {
|
||||
string tryExplainFailure() {
|
||||
exists(int i, API::Node nd, string prefix, string suffix |
|
||||
nd = this.lookup(i) and
|
||||
i < getPathLength() and
|
||||
not exists(this.lookup([i + 1 .. getPathLength()])) and
|
||||
i < this.getPathLength() and
|
||||
not exists(this.lookup([i + 1 .. this.getPathLength()])) and
|
||||
prefix = nd + " has no outgoing edge labelled " + this.getEdgeLabel(i) + ";" and
|
||||
if exists(nd.getASuccessor())
|
||||
then
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
import ApiGraphs.VerifyAssertions
|
||||
65
javascript/ql/test/ApiGraphs/accessors/index.js
Normal file
65
javascript/ql/test/ApiGraphs/accessors/index.js
Normal file
@@ -0,0 +1,65 @@
|
||||
const foo = require('foo');
|
||||
|
||||
foo({
|
||||
myMethod(x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
});
|
||||
|
||||
foo({
|
||||
get myMethod() {
|
||||
return function (x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x)
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
class C {
|
||||
static myMethod(x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
foo(C);
|
||||
|
||||
class D {
|
||||
myMethod(x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
foo(new D());
|
||||
|
||||
class E {
|
||||
get myMethod() {
|
||||
return function (x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
foo(new E());
|
||||
|
||||
class F {
|
||||
static get myMethod() {
|
||||
return function (x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getMember("myMethod").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
foo(F);
|
||||
|
||||
// Cases where the class is instantiated in `foo`:
|
||||
|
||||
class G {
|
||||
myMethod2(x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getInstance().getMember("myMethod2").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
foo(G);
|
||||
|
||||
class H {
|
||||
get myMethod2() {
|
||||
return function (x) { /* use=moduleImport("foo").getMember("exports").getParameter(0).getInstance().getMember("myMethod2").getParameter(0) */
|
||||
console.log(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
foo(H);
|
||||
@@ -3,9 +3,9 @@ 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 getFirst() { result = getParameter(0).getMember("value").asSink() }
|
||||
|
||||
DataFlow::Node getSecond() { result = getParameter(1).getMember("value").getARhs() }
|
||||
DataFlow::Node getSecond() { result = getParameter(1).getMember("value").asSink() }
|
||||
}
|
||||
|
||||
query predicate values(FooCall call, int first, int second) {
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
class CustomEntryPoint extends API::EntryPoint {
|
||||
CustomEntryPoint() { this = "CustomEntryPoint" }
|
||||
|
||||
override DataFlow::SourceNode getAUse() { result = DataFlow::globalVarRef("CustomEntryPoint") }
|
||||
|
||||
override DataFlow::Node getARhs() { none() }
|
||||
override DataFlow::SourceNode getASource() { result = DataFlow::globalVarRef("CustomEntryPoint") }
|
||||
}
|
||||
|
||||
import ApiGraphs.VerifyAssertions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import javascript
|
||||
|
||||
from string mod, string tp
|
||||
select mod, tp, API::Node::ofType(mod, tp).getAnImmediateUse()
|
||||
select mod, tp, API::Node::ofType(mod, tp).asSource()
|
||||
|
||||
Reference in New Issue
Block a user