Rename moduleImport to getTopLevelMember

This commit is contained in:
Tom Hvitved
2021-08-04 10:57:57 +02:00
parent 8451286754
commit 0eaeb3b5a6
2 changed files with 6 additions and 4 deletions

View File

@@ -212,13 +212,15 @@ module API {
Root root() { any() }
/**
* Gets a node corresponding to an import of top-level module `m`.
* Gets a node corresponding to a top-level member `m` (typically a module).
*
* This is equivalent to `root().getAMember("m")`.
*
* Note: You should only use this predicate for top level modules or classes. If you want nodes corresponding to a nested module or class,
* you should use `.getMember` on the parent module/class. For example, for nodes corresponding to the class `Gem::Version`,
* use `moduleImport("Gem").getMember("Version")`.
* use `getTopLevelMember("Gem").getMember("Version")`.
*/
Node moduleImport(string m) { result = root().getMember(m) }
Node getTopLevelMember(string m) { result = root().getMember(m) }
/**
* Provides the actual implementation of API graphs, cached for performance.

View File

@@ -49,7 +49,7 @@ class PermissionArgument extends DataFlow::Node {
PermissionArgument() {
exists(string methodName |
call = API::moduleImport(["File", "FileUtils"]).getAMethodCall(methodName)
call = API::getTopLevelMember(["File", "FileUtils"]).getAMethodCall(methodName)
|
methodName in ["chmod", "chmod_R", "lchmod"] and this = call.getArgument(0)
or