Skip to content

Commit afd0016

Browse files
committed
Ruby: introduce getExtraNodeFromType
Using getExtraNodeFromPath with n=0 was a bit of a hack. In principle, the CodeQL libraries might care about the type, even though there are no relevant paths starting at that type.
1 parent b99e9a5 commit afd0016

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModels.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,7 @@ private API::Node getNodeFromType(string package, string type) {
434434
or
435435
result = any(TypeModelDefEntry e).getNodeForType(package, type)
436436
or
437-
isRelevantFullPath(package, type, _) and
438-
result = Specific::getExtraNodeFromPath(package, type, _, 0)
437+
result = Specific::getExtraNodeFromType(package, type)
439438
}
440439

441440
/**

ruby/ql/lib/codeql/ruby/frameworks/data/internal/ApiGraphModelsSpecific.qll

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ predicate isPackageUsed(string package) {
5656
/** Gets a Ruby-specific interpretation of the `(package, type, path)` tuple after resolving the first `n` access path tokens. */
5757
bindingset[package, type, path]
5858
API::Node getExtraNodeFromPath(string package, string type, AccessPath path, int n) {
59-
isRelevantFullPath(package, type, path) and
60-
exists(package) and // Allow any package name, see `isPackageUsed`.
61-
type = "" and
62-
n = 0 and
63-
result = API::root()
64-
or
6559
// A row of form `;any;Method[foo]` should match any method named `foo`.
6660
exists(package) and
6761
type = "any" and
@@ -72,6 +66,14 @@ API::Node getExtraNodeFromPath(string package, string type, AccessPath path, int
7266
)
7367
}
7468

69+
/** Gets a Ruby-specific interpretation of the `(package, type)` tuple. */
70+
API::Node getExtraNodeFromType(string package, string type) {
71+
isRelevantFullPath(package, type, _) and
72+
exists(package) and // Allow any package name, see `isPackageUsed`.
73+
type = "" and
74+
result = API::root()
75+
}
76+
7577
/**
7678
* Holds if `path` occurs in a CSV row with type `any`, meaning it can start
7779
* matching anywhere, and the path begins with `Method[methodName]`.

0 commit comments

Comments
 (0)