Skip to content

Commit 654c4ee

Browse files
committed
Add support for type steps
1 parent ef627b4 commit 654c4ee

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

javascript/ql/lib/semmle/javascript/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,9 @@ private API::Node getNodeFromPath(string package, string type, AccessPath path,
394394
// Apply a subpath
395395
result =
396396
getNodeFromSubPath(getNodeFromPath(package, type, path, n - 1), getSubPathAt(path, n - 1))
397+
or
398+
// Apply a receiver step
399+
typeStep(getNodeFromPath(package, type, path, n), result)
397400
}
398401

399402
/**
@@ -419,6 +422,13 @@ private API::Node getNodeFromSubPath(API::Node base, AccessPath subPath, int n)
419422
n = 0
420423
)
421424
or
425+
exists(string package, string type, AccessPath basePath |
426+
typeStepModel(package, type, basePath, subPath) and
427+
base = getNodeFromPath(package, type, basePath) and
428+
result = base and
429+
n = 0
430+
)
431+
or
422432
result = getSuccessorFromNode(getNodeFromSubPath(base, subPath, n - 1), subPath.getToken(n - 1))
423433
or
424434
result =
@@ -451,6 +461,20 @@ API::Node getNodeFromPath(string package, string type, AccessPath path) {
451461
result = getNodeFromPath(package, type, path, path.getNumToken())
452462
}
453463

464+
pragma[nomagic]
465+
private predicate typeStepModel(string package, string type, AccessPath basePath, AccessPath output) {
466+
summaryModel(package, type, basePath, "", output, "type")
467+
}
468+
469+
pragma[nomagic]
470+
private predicate typeStep(API::Node pred, API::Node succ) {
471+
exists(string package, string type, AccessPath basePath, AccessPath output |
472+
typeStepModel(package, type, basePath, output) and
473+
pred = getNodeFromPath(package, type, basePath) and
474+
succ = getNodeFromSubPath(pred, output)
475+
)
476+
}
477+
454478
/**
455479
* Gets an invocation identified by the given `(package, type, path)` tuple.
456480
*

0 commit comments

Comments
 (0)