mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
Merge pull request #5581 from asgerf/js/dependency-info
Approved by esbena
This commit is contained in:
@@ -127,18 +127,22 @@ class ExternalNPMDependency extends NPMDependency {
|
||||
exists(PackageDependencies pkgdeps | this = pkgdeps.getPropValue(result))
|
||||
}
|
||||
|
||||
override string getVersion() {
|
||||
private string getVersionNumber() {
|
||||
exists(string versionRange | versionRange = this.(JSONString).getValue() |
|
||||
// extract a concrete version from the version range; currently,
|
||||
// we handle exact versions as well as `<=`, `>=`, `~` and `^` ranges
|
||||
result = versionRange.regexpCapture("(?:[><]=|[=~^])?v?(\\d+(\\.\\d+){1,2})", 1)
|
||||
or
|
||||
// if no version is specified, report version `unknown`
|
||||
result = "unknown" and
|
||||
(versionRange = "" or versionRange = "*")
|
||||
)
|
||||
}
|
||||
|
||||
override string getVersion() {
|
||||
result = getVersionNumber()
|
||||
or
|
||||
// if no version is specified or could not be parsed, report version `unknown`
|
||||
not exists(getVersionNumber()) and
|
||||
result = "unknown"
|
||||
}
|
||||
|
||||
override Import getAnImport() {
|
||||
exists(int depth | depth = importsDependency(result, getDeclaringPackage(), this) |
|
||||
// restrict to those results for which this is the closest matching dependency
|
||||
|
||||
Reference in New Issue
Block a user