Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fabric8-analytics-lsp-server

Package Overview
Dependencies
Maintainers
3
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fabric8-analytics-lsp-server - npm Package Compare versions

Comparing version 0.2.8 to 0.3.0

49

collector.js

@@ -7,6 +7,7 @@ /* --------------------------------------------------------------------------------------------

Object.defineProperty(exports, "__esModule", { value: true });
exports.ReqDependencyCollector = exports.PomXmlDependencyCollector = exports.DependencyCollector = void 0;
exports.GomodDependencyCollector = exports.ReqDependencyCollector = exports.PomXmlDependencyCollector = exports.DependencyCollector = void 0;
const json_1 = require("./json");
const Xml2Object = require("xml2object");
const utils_1 = require("./utils");
const semverRegex = require("semver-regex");
/* By default the collector is going to process these dependency keys */

@@ -93,2 +94,48 @@ const DefaultClasses = ["dependencies"];

exports.ReqDependencyCollector = ReqDependencyCollector;
class NaiveGomodParser {
constructor(contents) {
this.dependencies = NaiveGomodParser.parseDependencies(contents);
}
static parseDependencies(contents) {
const gomod = contents.split("\n");
return gomod.reduce((dependencies, line, index) => {
// Ignore "replace" lines
if (!line.includes("=>")) {
// skip any text after '//'
if (line.includes("//")) {
line = line.split("//")[0];
}
const version = semverRegex().exec(line);
// Skip lines without version string
if (version && version.length > 0) {
const parts = line.trim().split(' ');
const pkgName = (parts[0] || '').trim();
// Ignore line starting with replace clause and empty package
if (pkgName.length > 0) {
const entry = new json_1.KeyValueEntry(pkgName, { line: 0, column: 0 });
entry.value = new json_1.Variant(json_1.ValueType.String, version[0]);
entry.value_position = { line: index + 1, column: version.index + 1 };
dependencies.push(new Dependency(entry));
}
}
}
return dependencies;
}, []);
}
parse() {
return this.dependencies;
}
}
/* Process entries found in the go.mod file and collect all dependency
* related information */
class GomodDependencyCollector {
constructor(classes = ["dependencies"]) {
this.classes = classes;
}
async collect(contents) {
let parser = new NaiveGomodParser(contents);
return parser.parse();
}
}
exports.GomodDependencyCollector = GomodDependencyCollector;
class NaivePomXmlSaxParser {

@@ -95,0 +142,0 @@ constructor(stream) {

5

package.json
{
"name": "fabric8-analytics-lsp-server",
"description": "LSP Server for Dependency Analytics",
"version": "0.2.8",
"version": "0.3.0",
"author": "Pavel Odvody",

@@ -37,3 +37,4 @@ "contributors": [

"winston": "3.2.1",
"xml2object": "0.1.2"
"xml2object": "0.1.2",
"semver-regex": "3.1.1"
},

@@ -40,0 +41,0 @@ "devDependencies": {

@@ -218,3 +218,6 @@ /* --------------------------------------------------------------------------------------------

const deps = await collector.collect(contents);
const validPackages = deps.filter(d => regexVersion.test(d.version.value.trim()));
let validPackages = deps;
if (ecosystem != "golang") {
validPackages = deps.filter(d => regexVersion.test(d.version.value.trim()));
}
const requestPayload = validPackages.map(d => ({ "package": d.name.value, "version": d.version.value }));

@@ -241,2 +244,5 @@ const requestMapper = new Map(validPackages.map(d => [d.name.value + d.version.value, d]));

});
files.on(EventStream.Diagnostics, "^go\\.mod$", (uri, name, contents) => {
sendDiagnostics('golang', uri, contents, new collector_1.GomodDependencyCollector());
});
let checkDelay;

@@ -243,0 +249,0 @@ connection.onDidSaveTextDocument((params) => {

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc