From 80cefbfe79c62970a609c09a30e035ba720959a9 Mon Sep 17 00:00:00 2001 From: mcoops Date: Mon, 4 Oct 2021 02:35:38 +1000 Subject: [PATCH] npm: remove further version ranges from reporting (#46) --- deplist_test.go | 46 ----------------------------------------- internal/scan/nodejs.go | 12 +++++++++++ 2 files changed, 12 insertions(+), 46 deletions(-) diff --git a/deplist_test.go b/deplist_test.go index ad28982..be40397 100644 --- a/deplist_test.go +++ b/deplist_test.go @@ -50,108 +50,62 @@ func BuildWant() []Dependency { "loose-envify", "iconv-lite", "d3-brush", - "d3-polygon", "d3-zoom", - "d3-path", - "d3-chord", "rw", "d3-ease", "object-assign", - "rw", - "d3-scale-chromatic", - "d3-brush", - "d3-hierarchy", "commander", - "d3-time", - "d3-time-format", "d3-dsv", "d3-scale", "is-plain-object", "d3-quadtree", "tiny-warning", "d3-hierarchy", - "d3-dsv", - "d3-timer", "d3-scale-chromatic", - "d3-time-format", "d3-axis", - "d3-timer", - "d3-ease", "d3-color", "prismjs", - "d3-force", "iconv-lite", "angular", "d3-delaunay", "rxjs", - "d3-zoom", - "d3-scale", - "d3-interpolate", "d3-path", "d3-array", - "d3-time", "js-tokens", - "d3-format", "d3-contour", - "d3-geo", "safer-buffer", "react-is", - "d3-format", - "d3-interpolate", "d3-dispatch", "d3-force", - "d3-color", - "d3-transition", "prop-types", "tiny-emitter", "d3-polygon", "d3-chord", "d3-fetch", - "d3-dispatch", - "d3-contour", "tslib", "good-listener", "d3", - "d3-axis", - "d3-ease", "delegate", "d3-drag", "delaunator", - "commander", - "d3-color", - "delaunator", "d3-timer", - "d3-drag", "d3-geo", "slate", - "d3-interpolate", - "d3-random", "select", "esrever", "d3-transition", "clipboard", - "d3-dispatch", "d3-format", - "d3-path", - "d3-array", "d3-random", - "d3-fetch", - "d3-quadtree", "d3-shape", - "d3-delaunay", "d3-time", - "d3-shape", "immer", "@types/esrever", "d3-time-format", "d3-selection", - "d3-quadtree", - "d3-selection", "react", "tether", "d3-interpolate", - "d3-dsv", - "d3-array", } rubySet := []string{ diff --git a/internal/scan/nodejs.go b/internal/scan/nodejs.go index d148107..7e6506d 100644 --- a/internal/scan/nodejs.go +++ b/internal/scan/nodejs.go @@ -47,6 +47,13 @@ func recordPackage(packageName, version string) { // opposite now, we don't care if its specifying version ranges like 5.x.x, // or 5.* etc. Just get the versions. if len(version) > 0 { + // skip if it's specifying the major + // i.e. d3-path@2 only care about d3-path@2.0.0 + if len(version) == 1 { + return + } + + // if not digit, then range if !utils.CharIsDigit(version) { return } @@ -54,6 +61,11 @@ func recordPackage(packageName, version string) { if version[len(version)-1] == 'x' { return } + + // still a version range + if strings.Contains(version, " - ") || strings.Contains(version, "||") { + return + } } if _, ok := gatheredNode[packageName+version]; !ok {