fabric8-analytics-lsp-server
Advanced tools
Comparing version 0.4.5 to 0.4.6
@@ -32,5 +32,4 @@ /* -------------------------------------------------------------------------------------------- | ||
this.vulnerabilities.forEach((pckg, index) => { | ||
// Module and package can come in any order due to parallel batch requests. | ||
// Need handle use case (1) Module first followed by package and (2) Vulnerability first followed by module. | ||
if (newVulnerability.name.startsWith(pckg.name + "/") || pckg.name.startsWith(newVulnerability.name + "/")) { | ||
// Merge vulnerabilities for same modules. | ||
if (this.getModuleName(newVulnerability.name) == this.getModuleName(pckg.name)) { | ||
// Module / package exists, so aggregate the data and update Diagnostic message and code action. | ||
@@ -48,2 +47,6 @@ this.mergeVulnerability(index, newVulnerability); | ||
} | ||
getModuleName(vulnerabilityName) { | ||
const parts = vulnerabilityName.split('@'); | ||
return parts.length == 2 ? parts[1] : vulnerabilityName; | ||
} | ||
mergeVulnerability(existingIndex, newVulnerability) { | ||
@@ -50,0 +53,0 @@ // Between current name and new name, smallest will be the module name. |
@@ -77,3 +77,3 @@ /* -------------------------------------------------------------------------------------------- | ||
static parseDependencies(contents, goImports) { | ||
return contents.split("\n").reduce((dependencies, line, index) => { | ||
let goModDeps = contents.split("\n").reduce((dependencies, line, index) => { | ||
// Ignore "replace" lines | ||
@@ -99,11 +99,2 @@ if (!line.includes("=>")) { | ||
dependencies.push(new Dependency(entry)); | ||
// Find packages of this module. | ||
goImports.forEach(pckg => { | ||
if (pckg != pkgName && pckg.startsWith(pkgName + "/")) { | ||
const entry = new types_1.KeyValueEntry(pckg, { line: 0, column: 0 }); | ||
entry.value = new types_1.Variant(types_1.ValueType.String, 'v' + version[0]); | ||
entry.value_position = { line: index + 1, column: version.index }; | ||
dependencies.push(new Dependency(entry)); | ||
} | ||
}); | ||
} | ||
@@ -114,2 +105,34 @@ } | ||
}, []); | ||
let dependencies = []; | ||
goImports.forEach(importStatement => { | ||
let exactMatchDep = null; | ||
let moduleMatchDep = null; | ||
goModDeps.forEach(goModDep => { | ||
if (importStatement == goModDep.name.value) { | ||
// Software stack uses the module | ||
exactMatchDep = goModDep; | ||
} | ||
else if (importStatement.startsWith(goModDep.name.value + "/")) { | ||
// Find longest module name that matches the import statement | ||
if (moduleMatchDep == null) { | ||
moduleMatchDep = goModDep; | ||
} | ||
else if (moduleMatchDep.name.value.length < goModDep.name.value.length) { | ||
moduleMatchDep = goModDep; | ||
} | ||
} | ||
}); | ||
if (exactMatchDep) { | ||
// Software stack uses the module | ||
dependencies.push(exactMatchDep); | ||
} | ||
else if (moduleMatchDep != null) { | ||
// Software stack uses a package from the module | ||
const entry = new types_1.KeyValueEntry(importStatement + '@' + moduleMatchDep.name.value, moduleMatchDep.name.position); | ||
entry.value = new types_1.Variant(types_1.ValueType.String, moduleMatchDep.version.value); | ||
entry.value_position = moduleMatchDep.version.position; | ||
dependencies.push(new Dependency(entry)); | ||
} | ||
}); | ||
return dependencies; | ||
} | ||
@@ -116,0 +139,0 @@ parse() { |
{ | ||
"name": "fabric8-analytics-lsp-server", | ||
"description": "LSP Server for Dependency Analytics", | ||
"version": "0.4.5", | ||
"version": "0.4.6", | ||
"author": "Pavel Odvody", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -36,6 +36,9 @@ /* -------------------------------------------------------------------------------------------- | ||
var numberOfPackagesMsg = ""; | ||
var packageName = this.name; | ||
if (this.ecosystem == "golang") { | ||
numberOfPackagesMsg = `\nNumber of packages: ${this.packageCount}`; | ||
const parts = this.name.split('@'); | ||
packageName = parts.length == 2 ? parts[1] : packageName; | ||
} | ||
const msg = `${this.name}: ${this.version}${numberOfPackagesMsg} | ||
const msg = `${packageName}: ${this.version}${numberOfPackagesMsg} | ||
Known security vulnerability: ${this.vulnerabilityCount} | ||
@@ -42,0 +45,0 @@ Security advisory: ${this.advisoryCount} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91095
966