mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
JS: Deprecate PathExpr and related classes
This commit is contained in:
@@ -24,7 +24,7 @@ PackageJson getClosestPackageJson(Folder f) {
|
||||
|
||||
from Require r, string path, string mod
|
||||
where
|
||||
path = r.getImportedPath().getValue() and
|
||||
path = r.getImportedPathString() and
|
||||
// the imported module is the initial segment of the path, up to
|
||||
// `/` or the end of the string, whichever comes first; we exclude
|
||||
// local paths starting with `.` or `/`, since they might refer to files
|
||||
|
||||
@@ -23,7 +23,17 @@ predicate declaresDependency(NpmPackage pkg, string name, JsonValue dep) {
|
||||
/**
|
||||
* Gets a path expression in a module belonging to `pkg`.
|
||||
*/
|
||||
PathExpr getAPathExpr(NpmPackage pkg) { result.getEnclosingModule() = pkg.getAModule() }
|
||||
Expr getAPathExpr(NpmPackage pkg) {
|
||||
exists(Import imprt |
|
||||
result = imprt.getImportedPathExpr() and
|
||||
pkg.getAModule() = imprt.getEnclosingModule()
|
||||
)
|
||||
or
|
||||
exists(ReExportDeclaration decl |
|
||||
result = decl.getImportedPath() and
|
||||
pkg.getAModule() = decl.getEnclosingModule()
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a URL-valued attribute in a module or HTML file belonging to `pkg`.
|
||||
@@ -56,9 +66,8 @@ predicate usesDependency(NpmPackage pkg, string name) {
|
||||
(
|
||||
// there is a path expression (e.g., in a `require` or `import`) that
|
||||
// references `pkg`
|
||||
exists(PathExpr path | path = getAPathExpr(pkg) |
|
||||
// check whether the path is `name` or starts with `name/`, ignoring a prefix that ends with '!' (example: "scriptloader!moment")
|
||||
path.getValue().regexpMatch("(.*!)?\\Q" + name + "\\E(/.*)?")
|
||||
exists(Expr path | path = getAPathExpr(pkg) |
|
||||
path.getStringValue().(FilePath).getPackagePrefix() = name
|
||||
)
|
||||
or
|
||||
// there is an HTML URL attribute that may reference `pkg`
|
||||
|
||||
Reference in New Issue
Block a user