From 157814cf08ad87e7782552c309b516735a808015 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Mon, 23 Nov 2026 18:07:00 +0000 Subject: [PATCH] fix(npm-audit): audit the package through a wrapper project npm 11 prints via as an array and metadata.dependencies as an object, so the parser failed on every report. It now reads both shapes of via and lists each advisory once. The lockfile step resolved devDependencies, which took 28 seconds for dayjs and reported 142 findings in its development tree. The tarball is now the only dependency of a wrapper project, audited with --omit=dev. This also audits the package itself, which npm audit skips for a root. --- pkg/scanner/npmaudit/npmaudit.go | 258 ++-- pkg/scanner/npmaudit/npmaudit_test.go | 204 ++++ .../npmaudit/testdata/dayjs-1.11.13.json | 22 + .../npmaudit/testdata/minimist-0.0.8.json | 68 ++ .../testdata/mkdirp-0.5.1-dev-tree.json | 1033 +++++++++++++++++ .../npmaudit/testdata/mkdirp-0.5.1.json | 84 ++ .../npmaudit/testdata/request-2.88.2.json | 214 ++++ 7 files changed, 1776 insertions(+), 107 deletions(-) create mode 100644 pkg/scanner/npmaudit/npmaudit_test.go create mode 100644 pkg/scanner/npmaudit/testdata/dayjs-1.11.13.json create mode 100644 pkg/scanner/npmaudit/testdata/minimist-0.0.8.json create mode 100644 pkg/scanner/npmaudit/testdata/mkdirp-0.5.1-dev-tree.json create mode 100644 pkg/scanner/npmaudit/testdata/mkdirp-0.5.1.json create mode 100644 pkg/scanner/npmaudit/testdata/request-2.88.2.json diff --git a/pkg/scanner/npmaudit/npmaudit.go b/pkg/scanner/npmaudit/npmaudit.go index 2e0a38c..a04d774 100644 --- a/pkg/scanner/npmaudit/npmaudit.go +++ b/pkg/scanner/npmaudit/npmaudit.go @@ -3,16 +3,20 @@ package npmaudit import ( + "bytes" "context" "encoding/json" "fmt" + "io" "os" "os/exec" - "path/filepath" + "sort" + "strings" "time" "github.com/lukaszraczylo/gohoarder/pkg/config" "github.com/lukaszraczylo/gohoarder/pkg/metadata" + "github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr" "github.com/lukaszraczylo/gohoarder/pkg/uuid" "github.com/rs/zerolog/log" ) @@ -63,71 +67,60 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin Str("version", version). Msg("Starting npm audit scan") - // Create a temporary directory tmpDir, err := os.MkdirTemp("", "npm-audit-*") if err != nil { return nil, fmt.Errorf("failed to create temp dir: %w", err) } defer func() { _ = os.RemoveAll(tmpDir) }() - // Extract the .tgz file - if err := s.extractTgz(filePath, tmpDir); err != nil { - return nil, fmt.Errorf("failed to extract tgz: %w", err) + if err = writeWrapper(tmpDir, packageName, filePath); err != nil { + return s.scanErrorResult(ctx, registry, packageName, version, fmt.Sprintf("prepare audit project: %v", err), ""), nil } - // Find the package directory (usually "package/") - packageDir := filepath.Join(tmpDir, "package") - if _, err := os.Stat(packageDir); os.IsNotExist(err) { - // Try the tmpDir itself - packageDir = tmpDir - } - - // npm tarballs ship only package.json — there is no lockfile. We must - // generate one before `npm audit` can resolve the dependency tree. - // NOTE: this performs network egress (npm registry lookups for - // transitive deps). Acceptable here because the scanner runs server- - // side and the operator already trusts upstream resolution to cache - // the package; we use --ignore-scripts to avoid running install hooks. + // npm audit needs a lockfile and a tarball ships none. The tarball is installed into a + // wrapper project, so its own advisories are audited with its production dependencies, and + // its devDependencies are never resolved. This step reaches the npm registry. log.Info(). Str("scanner", ScannerName). Str("package", packageName). Msg("Generating package-lock.json for npm audit (network egress)") - installCmd := exec.CommandContext(ctx, "npm", "install", + installCmd := exec.CommandContext(ctx, "npm", "install", // #nosec G204 -- fixed args "--package-lock-only", "--omit=dev", "--ignore-scripts", "--no-audit", + "--no-fund", ) - installCmd.Dir = packageDir - if installOut, err := installCmd.CombinedOutput(); err != nil { + installCmd.Dir = tmpDir + if installOut, installErr := installCmd.CombinedOutput(); installErr != nil { log.Warn(). - Err(err). + Err(installErr). Str("package", packageName). Str("output", string(installOut)). Msg("npm install --package-lock-only failed; returning scan-error") - return s.scanErrorResult(registry, packageName, version, - fmt.Sprintf("npm install --package-lock-only failed: %v", err)), nil + return s.scanErrorResult(ctx, registry, packageName, version, + fmt.Sprintf("npm install --package-lock-only failed: %v", installErr), string(installOut)), nil } - // Run npm audit against the freshly generated lockfile. - cmd := exec.CommandContext(ctx, "npm", "audit", "--json") - cmd.Dir = packageDir - output, _ := cmd.CombinedOutput() // npm audit returns non-zero when vulns found + cmd := exec.CommandContext(ctx, "npm", "audit", "--omit=dev", "--json") // #nosec G204 -- fixed args + cmd.Dir = tmpDir + var stderr bytes.Buffer + cmd.Stderr = &stderr + output, _ := cmd.Output() // npm audit exits non-zero when it finds vulnerabilities - // Parse npm audit output - var auditResult NpmAuditResult - if len(output) > 0 { - if err := json.Unmarshal(output, &auditResult); err != nil { - log.Warn().Err(err).Msg("Failed to parse npm audit output") - // Parse failure means we couldn't determine vulnerability state — fail closed. - return s.scanErrorResult(registry, packageName, version, - fmt.Sprintf("failed to parse npm audit output: %v", err)), nil - } + auditResult, err := parse(output) + if err != nil { + log.Warn().Err(err).Msg("Failed to parse npm audit output") + return s.scanErrorResult(ctx, registry, packageName, version, + fmt.Sprintf("failed to parse npm audit output: %v", err), stderr.String()), nil + } + if auditResult.Error != nil { + return s.scanErrorResult(ctx, registry, packageName, version, + fmt.Sprintf("npm audit failed: %s %s", auditResult.Error.Code, auditResult.Error.Summary), stderr.String()), nil } - // Convert to our format - result := s.convertResult(&auditResult, registry, packageName, version) + result := s.convertResult(auditResult, registry, packageName, version) log.Info(). Str("scanner", ScannerName). @@ -138,6 +131,44 @@ func (s *Scanner) Scan(ctx context.Context, registry, packageName, version strin return result, nil } +// wrapperTarball is the archive's name inside the wrapper project. +const wrapperTarball = "artifact.tgz" + +// writeWrapper makes dir a project whose only dependency is the archive. +func writeWrapper(dir, packageName, archive string) error { + src, err := os.Open(archive) // #nosec G304 -- path from the cache, not user input + if err != nil { + return err + } + defer func() { _ = src.Close() }() + root, err := os.OpenRoot(dir) + if err != nil { + return err + } + defer func() { _ = root.Close() }() + dst, err := root.Create(wrapperTarball) + if err != nil { + return err + } + if _, err = io.Copy(dst, src); err != nil { + _ = dst.Close() + return err + } + if err = dst.Close(); err != nil { + return err + } + manifest, err := json.Marshal(map[string]interface{}{ + "name": "gohoarder-audit", + "version": "1.0.0", + "private": true, + "dependencies": map[string]string{packageName: "file:./" + wrapperTarball}, + }) + if err != nil { + return err + } + return root.WriteFile("package.json", manifest, 0o600) +} + // Health checks if npm is available func (s *Scanner) Health(ctx context.Context) error { cmd := exec.CommandContext(ctx, "npm", "--version") @@ -147,18 +178,11 @@ func (s *Scanner) Health(ctx context.Context) error { return nil } -// extractTgz extracts a .tgz file -func (s *Scanner) extractTgz(tgzPath, destDir string) error { - cmd := exec.Command("tar", "-xzf", tgzPath, "-C", destDir) - return cmd.Run() -} - -// emptyResult returns an empty scan result - -// scanErrorResult returns a result marked as scan-error so the manager merge -// and CheckVulnerabilities can fail closed. Use this when the scan could not -// complete and we therefore have no signal about vulnerabilities. -func (s *Scanner) scanErrorResult(registry, packageName, version, reason string) *metadata.ScanResult { +// scanErrorResult returns a result marked scan-error. The manager leaves it out of the merge +// and counts it as an infrastructure failure when the context ended or the tool output shows +// the network was unreachable. +func (s *Scanner) scanErrorResult(ctx context.Context, registry, packageName, version, reason, toolOutput string) *metadata.ScanResult { + infra := ctx.Err() != nil || scanerr.NetworkFailure(toolOutput) return &metadata.ScanResult{ ID: uuid.New().String(), Registry: registry, @@ -169,9 +193,7 @@ func (s *Scanner) scanErrorResult(registry, packageName, version, reason string) Status: metadata.ScanStatusError, VulnerabilityCount: 0, Vulnerabilities: []metadata.Vulnerability{}, - Details: map[string]interface{}{ - "error": reason, - }, + Details: scanerr.ErrorDetails(reason, infra), } } @@ -180,37 +202,35 @@ func (s *Scanner) convertResult(auditResult *NpmAuditResult, registry, packageNa vulnerabilities := make([]metadata.Vulnerability, 0) severityCounts := make(map[string]int) - // Process vulnerabilities from the audit result - for _, vuln := range auditResult.Vulnerabilities { - // Normalize severity - normalizedSeverity := metadata.NormalizeSeverity(vuln.Severity) - severityCounts[normalizedSeverity]++ - - // Get references - refs := make([]string, 0) - if vuln.URL != "" { - refs = append(refs, vuln.URL) - } - for _, ref := range vuln.References { - if ref.URL != "" { - refs = append(refs, ref.URL) + // Each advisory is listed once, under the package it affects. A string in `via` only says + // that the package is affected through another one, whose own entry lists the advisory. + seen := make(map[int]bool) + names := make([]string, 0, len(auditResult.Vulnerabilities)) + for name := range auditResult.Vulnerabilities { + names = append(names, name) + } + sort.Strings(names) + for _, name := range names { + for _, via := range auditResult.Vulnerabilities[name].Via { + adv := via.Advisory + if adv == nil || seen[adv.Source] { + continue } + seen[adv.Source] = true + normalizedSeverity := metadata.NormalizeSeverity(adv.Severity) + severityCounts[normalizedSeverity]++ + refs := make([]string, 0, 1) + if adv.URL != "" { + refs = append(refs, adv.URL) + } + vulnerabilities = append(vulnerabilities, metadata.Vulnerability{ + ID: advisoryID(adv), + Severity: normalizedSeverity, + Title: adv.Title, + Description: fmt.Sprintf("%s: %s (affected %s)", adv.Name, adv.Title, adv.Range), + References: refs, + }) } - - // Get fixed version - fixedIn := "" - if vuln.FixAvailable != nil { - fixedIn = fmt.Sprintf("%v", vuln.FixAvailable) - } - - vulnerabilities = append(vulnerabilities, metadata.Vulnerability{ - ID: vuln.Via, - Severity: normalizedSeverity, - Title: vuln.Name, - Description: vuln.Name, - References: refs, - FixedIn: fixedIn, - }) } status := metadata.ScanStatusClean @@ -234,38 +254,62 @@ func (s *Scanner) convertResult(auditResult *NpmAuditResult, registry, packageNa } } -// NpmAuditResult represents npm audit JSON output +// advisoryID is the GHSA id from the advisory URL, or the npm advisory number. +func advisoryID(adv *NpmAdvisory) string { + if i := strings.LastIndex(adv.URL, "/"); i >= 0 && i+1 < len(adv.URL) { + return adv.URL[i+1:] + } + return fmt.Sprintf("npm:%d", adv.Source) +} + +func parse(output []byte) (*NpmAuditResult, error) { + var res NpmAuditResult + if err := json.Unmarshal(output, &res); err != nil { + return nil, err + } + return &res, nil +} + +// NpmAuditResult represents `npm audit --json` output (auditReportVersion 2), or its error document. type NpmAuditResult struct { - Vulnerabilities map[string]NpmVulnerability `json:"vulnerabilities"` - Metadata NpmAuditMetadata `json:"metadata"` - AuditReportVersion int `json:"auditReportVersion"` + Vulnerabilities map[string]NpmVulnerability `json:"vulnerabilities"` + Error *NpmAuditError `json:"error"` } +// NpmAuditError is the document npm prints in place of a report, e.g. ENOLOCK. +type NpmAuditError struct { + Code string `json:"code"` + Summary string `json:"summary"` +} + +// NpmVulnerability is one affected package. type NpmVulnerability struct { - Name string `json:"name"` - Severity string `json:"severity"` - Via string `json:"via"` - Effects []string `json:"effects"` - Range string `json:"range"` - FixAvailable interface{} `json:"fixAvailable"` - URL string `json:"url"` - References []NpmReference `json:"references"` + Name string `json:"name"` + Severity string `json:"severity"` + Via []NpmVia `json:"via"` } -type NpmReference struct { - URL string `json:"url"` +// NpmVia is a package name (affected through that package) or an advisory. +type NpmVia struct { + Advisory *NpmAdvisory + Package string } -type NpmAuditMetadata struct { - Vulnerabilities NpmVulnCounts `json:"vulnerabilities"` - Dependencies int `json:"dependencies"` +// UnmarshalJSON accepts both shapes of an element of `via`. +func (v *NpmVia) UnmarshalJSON(data []byte) error { + if len(data) > 0 && data[0] == '"' { + return json.Unmarshal(data, &v.Package) + } + v.Advisory = &NpmAdvisory{} + return json.Unmarshal(data, v.Advisory) } -type NpmVulnCounts struct { - Info int `json:"info"` - Low int `json:"low"` - Moderate int `json:"moderate"` - High int `json:"high"` - Critical int `json:"critical"` - Total int `json:"total"` +// NpmAdvisory is a security advisory attached to a package. +type NpmAdvisory struct { + Name string `json:"name"` + Title string `json:"title"` + URL string `json:"url"` + Severity string `json:"severity"` + Range string `json:"range"` + Source int `json:"source"` } diff --git a/pkg/scanner/npmaudit/npmaudit_test.go b/pkg/scanner/npmaudit/npmaudit_test.go new file mode 100644 index 0000000..9f21301 --- /dev/null +++ b/pkg/scanner/npmaudit/npmaudit_test.go @@ -0,0 +1,204 @@ +package npmaudit + +import ( + "context" + "encoding/json" + "fmt" + "os" + "path/filepath" + "sort" + "testing" + + "github.com/lukaszraczylo/gohoarder/pkg/config" + "github.com/lukaszraczylo/gohoarder/pkg/metadata" + "github.com/lukaszraczylo/gohoarder/pkg/scanner/scanerr" + "github.com/lukaszraczylo/gohoarder/pkg/scanner/scannertest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// The fixtures are real `npm audit --json` output from npm 11.12.1 (see FINDINGS GH-25). +func fixture(name string) string { return filepath.Join("testdata", name) } + +func readFixture(t *testing.T, name string) []byte { + t.Helper() + data, err := os.ReadFile(fixture(name)) + require.NoError(t, err) + return data +} + +func severities(res *metadata.ScanResult) map[string]string { + out := map[string]string{} + for _, v := range res.Vulnerabilities { + out[v.ID] = v.Severity + } + return out +} + +func TestParseKeepsBothViaShapes(t *testing.T) { + // `via` is an array of package names for a transitive finding and an array of advisory + // objects for a direct one; mkdirp-0.5.1.json has both, the dev-tree file many of each. + for _, name := range []string{"dayjs-1.11.13.json", "minimist-0.0.8.json", "mkdirp-0.5.1.json", "request-2.88.2.json", "mkdirp-0.5.1-dev-tree.json"} { + t.Run(name, func(t *testing.T) { + _, err := parse(readFixture(t, name)) + require.NoError(t, err) + }) + } +} + +func TestConvertMapsAdvisories(t *testing.T) { + cases := []struct { + want map[string]string + fixture string + }{ + {fixture: "dayjs-1.11.13.json", want: map[string]string{}}, + {fixture: "minimist-0.0.8.json", want: map[string]string{"GHSA-vh95-rmgr-6w4m": "MODERATE", "GHSA-xvch-5gv4-984h": "CRITICAL"}}, + // mkdirp has no advisory of its own: its entry only points at minimist. + {fixture: "mkdirp-0.5.1.json", want: map[string]string{"GHSA-vh95-rmgr-6w4m": "MODERATE", "GHSA-xvch-5gv4-984h": "CRITICAL"}}, + {fixture: "request-2.88.2.json", want: map[string]string{ + "GHSA-fjxv-7rqg-78g4": "CRITICAL", "GHSA-hmw2-7cc7-3qxx": "HIGH", "GHSA-6rw7-vpxm-498p": "MODERATE", + "GHSA-4mjr-xmp4-gh2g": "MODERATE", "GHSA-p8p7-x288-28g6": "MODERATE", "GHSA-72xf-g2v4-qvf3": "MODERATE", + "GHSA-w5hq-g745-h8pq": "MODERATE", + }}, + } + for _, tc := range cases { + t.Run(tc.fixture, func(t *testing.T) { + audit, err := parse(readFixture(t, tc.fixture)) + require.NoError(t, err) + + res := New(config.NpmAuditConfig{}).convertResult(audit, "npm", "p", "1") + + assert.Equal(t, tc.want, severities(res)) + assert.Equal(t, len(tc.want), res.VulnerabilityCount) + if len(tc.want) == 0 { + assert.Equal(t, metadata.ScanStatusClean, res.Status) + } else { + assert.Equal(t, metadata.ScanStatusVulnerable, res.Status) + } + }) + } +} + +func TestConvertCarriesTitleAndReference(t *testing.T) { + audit, err := parse(readFixture(t, "minimist-0.0.8.json")) + require.NoError(t, err) + + res := New(config.NpmAuditConfig{}).convertResult(audit, "npm", "minimist", "0.0.8") + + ids := make([]string, 0) + for _, v := range res.Vulnerabilities { + ids = append(ids, v.ID) + assert.Equal(t, "Prototype Pollution in minimist", v.Title) + assert.Equal(t, []string{"https://github.com/advisories/" + v.ID}, v.References) + } + sort.Strings(ids) + assert.Equal(t, []string{"GHSA-vh95-rmgr-6w4m", "GHSA-xvch-5gv4-984h"}, ids) +} + +// npmScript fakes npm: `install` exits installExit, `audit` prints stdout and exits 1. +func npmScript(t *testing.T, auditFixture string, installExit int, installStderr string) (recDir string) { + t.Helper() + recDir = t.TempDir() + audit := "cat " + fmt.Sprintf("%q", mustAbs(t, auditFixture)) + if auditFixture == "" { + audit = "printf '%s' 'not json'" + } + scannertest.Script(t, "npm", fmt.Sprintf(` +case "$1" in +install) cat package.json > %[1]q/package.json; echo "$@" > %[1]q/install; printf '%%s' %[2]q >&2; exit %[3]d ;; +audit) echo "$@" > %[1]q/audit; %[4]s; exit 1 ;; +esac`, recDir, installStderr, installExit, audit)) + return recDir +} + +func mustAbs(t *testing.T, name string) string { + t.Helper() + if name == "" { + return "" + } + abs, err := filepath.Abs(fixture(name)) + require.NoError(t, err) + return abs +} + +func artifact(t *testing.T) string { + t.Helper() + p := filepath.Join(t.TempDir(), "pkg.tgz") + require.NoError(t, os.WriteFile(p, []byte("tgz"), 0o600)) + return p +} + +func TestScanAuditsThePackageItselfWithoutItsDevTree(t *testing.T) { + rec := npmScript(t, "minimist-0.0.8.json", 0, "") + + res, err := New(config.NpmAuditConfig{}).Scan(context.Background(), "npm", "minimist", "0.0.8", artifact(t)) + + require.NoError(t, err) + assert.Equal(t, metadata.ScanStatusVulnerable, res.Status) + assert.Len(t, res.Vulnerabilities, 2) + + pkgJSON, err := os.ReadFile(filepath.Join(rec, "package.json")) // #nosec G304 -- test temp dir + require.NoError(t, err) + var wrapper struct { + Dependencies map[string]string `json:"dependencies"` + } + require.NoError(t, json.Unmarshal(pkgJSON, &wrapper)) + assert.Equal(t, map[string]string{"minimist": "file:./artifact.tgz"}, wrapper.Dependencies, + "the tarball is a dependency of a wrapper project, so its own advisories are audited and its devDependencies are never resolved") + + audit, err := os.ReadFile(filepath.Join(rec, "audit")) // #nosec G304 -- test temp dir + require.NoError(t, err) + assert.Contains(t, string(audit), "--omit=dev") +} + +func TestScanCleanPackage(t *testing.T) { + npmScript(t, "dayjs-1.11.13.json", 0, "") + + res, err := New(config.NpmAuditConfig{}).Scan(context.Background(), "npm", "dayjs", "1.11.13", artifact(t)) + + require.NoError(t, err) + assert.Equal(t, metadata.ScanStatusClean, res.Status) +} + +func TestScanFailuresAreErrorResultsWithACause(t *testing.T) { + cases := []struct { + name string + fixture string + installOut string + installRC int + infra bool + }{ + {"network down", "", "npm error code ENOTFOUND", 1, true}, + {"unresolvable tree", "", "npm error code ERESOLVE", 1, false}, + {"unparseable audit", "", "", 0, false}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + npmScript(t, tc.fixture, tc.installRC, tc.installOut) + + res, err := New(config.NpmAuditConfig{}).Scan(context.Background(), "npm", "p", "1", artifact(t)) + + require.NoError(t, err) + assert.Equal(t, metadata.ScanStatusError, res.Status) + assert.Equal(t, tc.infra, res.Details[scanerr.DetailInfrastructure]) + }) + } +} + +func TestScanAuditErrorDocumentIsAnErrorResult(t *testing.T) { + doc := filepath.Join(t.TempDir(), "enolock.json") + require.NoError(t, os.WriteFile(doc, []byte(`{"error":{"code":"ENOLOCK","summary":"This command requires an existing lockfile.","detail":""}}`), 0o600)) + scannertest.Script(t, "npm", fmt.Sprintf(`case "$1" in audit) cat %q; exit 1 ;; esac`, doc)) + + res, err := New(config.NpmAuditConfig{}).Scan(context.Background(), "npm", "p", "1", artifact(t)) + + require.NoError(t, err) + assert.Equal(t, metadata.ScanStatusError, res.Status) + assert.Contains(t, res.Details["error"], "ENOLOCK") +} + +func TestScanSkipsOtherRegistries(t *testing.T) { + res, err := New(config.NpmAuditConfig{}).Scan(context.Background(), "pypi", "p", "1", "/x") + require.NoError(t, err) + assert.Equal(t, metadata.ScanStatusClean, res.Status) +} diff --git a/pkg/scanner/npmaudit/testdata/dayjs-1.11.13.json b/pkg/scanner/npmaudit/testdata/dayjs-1.11.13.json new file mode 100644 index 0000000..d9c1b96 --- /dev/null +++ b/pkg/scanner/npmaudit/testdata/dayjs-1.11.13.json @@ -0,0 +1,22 @@ +{ + "auditReportVersion": 2, + "vulnerabilities": {}, + "metadata": { + "vulnerabilities": { + "info": 0, + "low": 0, + "moderate": 0, + "high": 0, + "critical": 0, + "total": 0 + }, + "dependencies": { + "prod": 2, + "dev": 0, + "optional": 0, + "peer": 0, + "peerOptional": 0, + "total": 1 + } + } +} diff --git a/pkg/scanner/npmaudit/testdata/minimist-0.0.8.json b/pkg/scanner/npmaudit/testdata/minimist-0.0.8.json new file mode 100644 index 0000000..4dbc42b --- /dev/null +++ b/pkg/scanner/npmaudit/testdata/minimist-0.0.8.json @@ -0,0 +1,68 @@ +{ + "auditReportVersion": 2, + "vulnerabilities": { + "minimist": { + "name": "minimist", + "severity": "critical", + "isDirect": true, + "via": [ + { + "source": 1096466, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-vh95-rmgr-6w4m", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 5.6, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L" + }, + "range": "<0.2.1" + }, + { + "source": 1097677, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-xvch-5gv4-984h", + "severity": "critical", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 9.8, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<0.2.4" + } + ], + "effects": [], + "range": "<=0.2.3", + "nodes": [ + "node_modules/minimist" + ], + "fixAvailable": false + } + }, + "metadata": { + "vulnerabilities": { + "info": 0, + "low": 0, + "moderate": 0, + "high": 0, + "critical": 1, + "total": 1 + }, + "dependencies": { + "prod": 2, + "dev": 0, + "optional": 0, + "peer": 0, + "peerOptional": 0, + "total": 1 + } + } +} diff --git a/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1-dev-tree.json b/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1-dev-tree.json new file mode 100644 index 0000000..c7a5b01 --- /dev/null +++ b/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1-dev-tree.json @@ -0,0 +1,1033 @@ +{ + "auditReportVersion": 2, + "vulnerabilities": { + "boom": { + "name": "boom", + "severity": "high", + "isDirect": false, + "via": [ + "hoek" + ], + "effects": [ + "cryptiles", + "hawk" + ], + "range": "*", + "nodes": [ + "node_modules/boom" + ], + "fixAvailable": true + }, + "coveralls": { + "name": "coveralls", + "severity": "critical", + "isDirect": false, + "via": [ + "js-yaml", + "minimist", + "request" + ], + "effects": [ + "tap" + ], + "range": "*", + "nodes": [ + "node_modules/coveralls" + ], + "fixAvailable": true + }, + "cross-spawn": { + "name": "cross-spawn", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1104663, + "name": "cross-spawn", + "dependency": "cross-spawn", + "title": "Regular Expression Denial of Service (ReDoS) in cross-spawn", + "url": "https://github.com/advisories/GHSA-3xgq-45jj-v275", + "severity": "high", + "cwe": [ + "CWE-1333" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<6.0.6" + } + ], + "effects": [ + "foreground-child" + ], + "range": "<6.0.6", + "nodes": [ + "node_modules/cross-spawn" + ], + "fixAvailable": true + }, + "cryptiles": { + "name": "cryptiles", + "severity": "high", + "isDirect": false, + "via": [ + "boom" + ], + "effects": [ + "hawk" + ], + "range": "*", + "nodes": [ + "node_modules/cryptiles" + ], + "fixAvailable": true + }, + "diff": { + "name": "diff", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1102333, + "name": "diff", + "dependency": "diff", + "title": "Regular Expression Denial of Service (ReDoS)", + "url": "https://github.com/advisories/GHSA-h6ch-v84p-w6p9", + "severity": "high", + "cwe": [ + "CWE-400" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<3.5.0" + }, + { + "source": 1112703, + "name": "diff", + "dependency": "diff", + "title": "jsdiff has a Denial of Service vulnerability in parsePatch and applyPatch", + "url": "https://github.com/advisories/GHSA-73rr-hh4g-fpgx", + "severity": "low", + "cwe": [ + "CWE-400", + "CWE-1333" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<3.5.1" + } + ], + "effects": [ + "tap-mocha-reporter" + ], + "range": "<=3.5.0", + "nodes": [ + "node_modules/diff" + ], + "fixAvailable": true + }, + "fileset": { + "name": "fileset", + "severity": "high", + "isDirect": false, + "via": [ + "minimatch" + ], + "effects": [ + "istanbul" + ], + "range": "0.1.0 - 0.2.1", + "nodes": [ + "node_modules/fileset" + ], + "fixAvailable": true + }, + "foreground-child": { + "name": "foreground-child", + "severity": "high", + "isDirect": false, + "via": [ + "cross-spawn" + ], + "effects": [], + "range": "1.5.2 - 1.5.6", + "nodes": [ + "node_modules/foreground-child" + ], + "fixAvailable": true + }, + "form-data": { + "name": "form-data", + "severity": "critical", + "isDirect": false, + "via": [ + { + "source": 1109540, + "name": "form-data", + "dependency": "form-data", + "title": "form-data uses unsafe random function in form-data for choosing boundary", + "url": "https://github.com/advisories/GHSA-fjxv-7rqg-78g4", + "severity": "critical", + "cwe": [ + "CWE-330" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<2.5.4" + }, + { + "source": 1120745, + "name": "form-data", + "dependency": "form-data", + "title": "form-data: CRLF injection in form-data via unescaped multipart field names and filenames", + "url": "https://github.com/advisories/GHSA-hmw2-7cc7-3qxx", + "severity": "high", + "cwe": [ + "CWE-93" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N" + }, + "range": "<2.5.6" + } + ], + "effects": [ + "request" + ], + "range": "<=2.5.5", + "nodes": [ + "node_modules/form-data" + ], + "fixAvailable": true + }, + "hawk": { + "name": "hawk", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1095062, + "name": "hawk", + "dependency": "hawk", + "title": "Uncontrolled Resource Consumption in Hawk", + "url": "https://github.com/advisories/GHSA-44pw-h2cw-w3vq", + "severity": "high", + "cwe": [ + "CWE-400", + "CWE-1333" + ], + "cvss": { + "score": 7.4, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:N/I:N/A:H" + }, + "range": "<9.0.1" + }, + "boom", + "cryptiles", + "hoek", + "sntp" + ], + "effects": [ + "request" + ], + "range": "<=9.0.0", + "nodes": [ + "node_modules/hawk" + ], + "fixAvailable": true + }, + "hoek": { + "name": "hoek", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1105092, + "name": "hoek", + "dependency": "hoek", + "title": "hoek subject to prototype pollution via the clone function.", + "url": "https://github.com/advisories/GHSA-c429-5p7v-vgjp", + "severity": "high", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 8.1, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<=6.1.3" + }, + { + "source": 1105121, + "name": "hoek", + "dependency": "hoek", + "title": "Prototype Pollution in hoek", + "url": "https://github.com/advisories/GHSA-jp4x-w63m-7wgm", + "severity": "high", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 8.8, + "vectorString": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<4.2.1" + } + ], + "effects": [ + "boom", + "hawk", + "sntp" + ], + "range": "*", + "nodes": [ + "node_modules/hoek" + ], + "fixAvailable": true + }, + "istanbul": { + "name": "istanbul", + "severity": "high", + "isDirect": false, + "via": [ + "fileset" + ], + "effects": [ + "nyc" + ], + "range": "<=0.4.4", + "nodes": [ + "node_modules/istanbul" + ], + "fixAvailable": true + }, + "js-yaml": { + "name": "js-yaml", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1085724, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "Denial of Service in js-yaml", + "url": "https://github.com/advisories/GHSA-2pr6-76vf-7546", + "severity": "moderate", + "cwe": [ + "CWE-400" + ], + "cvss": { + "score": 5.9, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<3.13.0" + }, + { + "source": 1095058, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "Code Injection in js-yaml", + "url": "https://github.com/advisories/GHSA-8j8c-7jfh-h6hx", + "severity": "high", + "cwe": [ + "CWE-94" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<3.13.1" + }, + { + "source": 1112714, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "js-yaml has prototype pollution in merge (<<)", + "url": "https://github.com/advisories/GHSA-mh29-5h37-fv8m", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 5.3, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N" + }, + "range": "<3.14.2" + }, + { + "source": 1121859, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "JS-YAML: Quadratic-complexity DoS in merge key handling via repeated aliases", + "url": "https://github.com/advisories/GHSA-h67p-54hq-rp68", + "severity": "moderate", + "cwe": [ + "CWE-407" + ], + "cvss": { + "score": 5.3, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L" + }, + "range": "<3.15.0" + }, + { + "source": 1123912, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "js-yaml: YAML merge-key chains can force quadratic CPU consumption", + "url": "https://github.com/advisories/GHSA-52cp-r559-cp3m", + "severity": "high", + "cwe": [ + "CWE-400", + "CWE-407" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": ">=3.0.0 <3.15.0" + }, + { + "source": 1138114, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "JS-YAML: Quadratic CPU consumption in !!omap resolution (3.x and 4.x) — CVE-2026-59870 fix not backported", + "url": "https://github.com/advisories/GHSA-5p4m-2wfm-xmqj", + "severity": "high", + "cwe": [ + "CWE-407" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": ">=3.0.0 <3.15.1" + }, + { + "source": 1193726, + "name": "js-yaml", + "dependency": "js-yaml", + "title": "js-yaml: maxTotalMergeKeys does not limit CPU use for empty merge sources", + "url": "https://github.com/advisories/GHSA-2883-xcg3-v3hh", + "severity": "high", + "cwe": [ + "CWE-400", + "CWE-407" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": ">=3.0.0 <3.15.2" + } + ], + "effects": [ + "coveralls" + ], + "range": "<=3.15.1", + "nodes": [ + "node_modules/coveralls/node_modules/js-yaml" + ], + "fixAvailable": true + }, + "lodash": { + "name": "lodash", + "severity": "critical", + "isDirect": false, + "via": [ + { + "source": 1106900, + "name": "lodash", + "dependency": "lodash", + "title": "Prototype Pollution in lodash", + "url": "https://github.com/advisories/GHSA-fvqr-27wr-82fm", + "severity": "moderate", + "cwe": [ + "CWE-471", + "CWE-1321" + ], + "cvss": { + "score": 6.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:H/A:N" + }, + "range": "<4.17.5" + }, + { + "source": 1106913, + "name": "lodash", + "dependency": "lodash", + "title": "Command Injection in lodash", + "url": "https://github.com/advisories/GHSA-35jh-r3h4-6jhm", + "severity": "high", + "cwe": [ + "CWE-77", + "CWE-94" + ], + "cvss": { + "score": 7.2, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<4.17.21" + }, + { + "source": 1106914, + "name": "lodash", + "dependency": "lodash", + "title": "Prototype Pollution in lodash", + "url": "https://github.com/advisories/GHSA-4xc9-xhrj-v574", + "severity": "high", + "cwe": [ + "CWE-400" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<4.17.11" + }, + { + "source": 1106918, + "name": "lodash", + "dependency": "lodash", + "title": "Prototype Pollution in lodash", + "url": "https://github.com/advisories/GHSA-jf85-cpcp-j695", + "severity": "critical", + "cwe": [ + "CWE-20", + "CWE-1321" + ], + "cvss": { + "score": 9.1, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H" + }, + "range": "<4.17.12" + }, + { + "source": 1106920, + "name": "lodash", + "dependency": "lodash", + "title": "Prototype Pollution in lodash", + "url": "https://github.com/advisories/GHSA-p6mc-m468-83gw", + "severity": "high", + "cwe": [ + "CWE-770", + "CWE-1321" + ], + "cvss": { + "score": 7.4, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:H" + }, + "range": ">=3.7.0 <4.17.19" + } + ], + "effects": [ + "nyc" + ], + "range": "<=4.17.20", + "nodes": [ + "node_modules/lodash" + ], + "fixAvailable": true + }, + "minimatch": { + "name": "minimatch", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1093710, + "name": "minimatch", + "dependency": "minimatch", + "title": "Regular Expression Denial of Service in minimatch", + "url": "https://github.com/advisories/GHSA-hxm2-r34f-qmc5", + "severity": "high", + "cwe": [ + "CWE-400" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<3.0.2" + }, + { + "source": 1096485, + "name": "minimatch", + "dependency": "minimatch", + "title": "minimatch ReDoS vulnerability", + "url": "https://github.com/advisories/GHSA-f8q6-p94x-37v3", + "severity": "high", + "cwe": [ + "CWE-400", + "CWE-1333" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<3.0.5" + }, + { + "source": 1113459, + "name": "minimatch", + "dependency": "minimatch", + "title": "minimatch has a ReDoS via repeated wildcards with non-matching literal in pattern", + "url": "https://github.com/advisories/GHSA-3ppc-4f35-3m26", + "severity": "high", + "cwe": [ + "CWE-1333" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<3.1.3" + }, + { + "source": 1113538, + "name": "minimatch", + "dependency": "minimatch", + "title": "minimatch has ReDoS: matchOne() combinatorial backtracking via multiple non-adjacent GLOBSTAR segments", + "url": "https://github.com/advisories/GHSA-7r86-cg39-jmmj", + "severity": "high", + "cwe": [ + "CWE-407" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<3.1.3" + }, + { + "source": 1113546, + "name": "minimatch", + "dependency": "minimatch", + "title": "minimatch ReDoS: nested *() extglobs generate catastrophically backtracking regular expressions", + "url": "https://github.com/advisories/GHSA-23c5-xmqv-rm74", + "severity": "high", + "cwe": [ + "CWE-1333" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": "<3.1.4" + } + ], + "effects": [ + "fileset" + ], + "range": "<=3.1.3", + "nodes": [ + "node_modules/fileset/node_modules/minimatch" + ], + "fixAvailable": true + }, + "minimist": { + "name": "minimist", + "severity": "critical", + "isDirect": true, + "via": [ + { + "source": 1096465, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-vh95-rmgr-6w4m", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 5.6, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L" + }, + "range": ">=1.0.0 <1.2.3" + }, + { + "source": 1096466, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-vh95-rmgr-6w4m", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 5.6, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L" + }, + "range": "<0.2.1" + }, + { + "source": 1097677, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-xvch-5gv4-984h", + "severity": "critical", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 9.8, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<0.2.4" + }, + { + "source": 1097678, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-xvch-5gv4-984h", + "severity": "critical", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 9.8, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" + }, + "range": ">=1.0.0 <1.2.6" + } + ], + "effects": [ + "coveralls" + ], + "range": "<=0.2.3 || 1.0.0 - 1.2.5", + "nodes": [ + "node_modules/coveralls/node_modules/minimist", + "node_modules/minimist" + ], + "fixAvailable": { + "name": "minimist", + "version": "1.2.8", + "isSemVerMajor": true + } + }, + "mock-fs": { + "name": "mock-fs", + "severity": "high", + "isDirect": true, + "via": [ + "semver" + ], + "effects": [], + "range": "2.5.0 - 3.3.0 || 3.8.0 - 3.12.1", + "nodes": [ + "node_modules/mock-fs" + ], + "fixAvailable": { + "name": "mock-fs", + "version": "5.5.0", + "isSemVerMajor": true + } + }, + "nyc": { + "name": "nyc", + "severity": "high", + "isDirect": false, + "via": [ + "istanbul", + "lodash" + ], + "effects": [ + "tap" + ], + "range": "<=5.0.1 || 6.2.0-alpha - 6.6.1", + "nodes": [ + "node_modules/nyc" + ], + "fixAvailable": true + }, + "qs": { + "name": "qs", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1113719, + "name": "qs", + "dependency": "qs", + "title": "qs's arrayLimit bypass in its bracket notation allows DoS via memory exhaustion", + "url": "https://github.com/advisories/GHSA-6rw7-vpxm-498p", + "severity": "moderate", + "cwe": [ + "CWE-20" + ], + "cvss": { + "score": 3.7, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L" + }, + "range": "<6.14.1" + }, + { + "source": 1158507, + "name": "qs", + "dependency": "qs", + "title": "qs: Denial of Service via Attacker Controlled isBuffer", + "url": "https://github.com/advisories/GHSA-4mjr-xmp4-gh2g", + "severity": "moderate", + "cwe": [ + "CWE-248", + "CWE-703" + ], + "cvss": { + "score": 5.3, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L" + }, + "range": ">=2.2.5 <6.16.0" + } + ], + "effects": [ + "request" + ], + "range": "<=6.15.4", + "nodes": [ + "node_modules/qs" + ], + "fixAvailable": true + }, + "request": { + "name": "request", + "severity": "critical", + "isDirect": false, + "via": [ + { + "source": 1096727, + "name": "request", + "dependency": "request", + "title": "Server-Side Request Forgery in Request", + "url": "https://github.com/advisories/GHSA-p8p7-x288-28g6", + "severity": "moderate", + "cwe": [ + "CWE-918" + ], + "cvss": { + "score": 6.1, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N" + }, + "range": "<=2.88.2" + }, + "form-data", + "hawk", + "qs", + "tough-cookie", + "tunnel-agent", + "uuid" + ], + "effects": [ + "coveralls" + ], + "range": "*", + "nodes": [ + "node_modules/request" + ], + "fixAvailable": true + }, + "semver": { + "name": "semver", + "severity": "high", + "isDirect": false, + "via": [ + { + "source": 1112918, + "name": "semver", + "dependency": "semver", + "title": "semver vulnerable to Regular Expression Denial of Service", + "url": "https://github.com/advisories/GHSA-c2qf-rxjj-qqgw", + "severity": "high", + "cwe": [ + "CWE-1333" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H" + }, + "range": ">=2.0.0-alpha <5.7.2" + } + ], + "effects": [ + "mock-fs" + ], + "range": "2.0.0-alpha - 5.7.1", + "nodes": [ + "node_modules/semver" + ], + "fixAvailable": { + "name": "mock-fs", + "version": "5.5.0", + "isSemVerMajor": true + } + }, + "sntp": { + "name": "sntp", + "severity": "high", + "isDirect": false, + "via": [ + "hoek" + ], + "effects": [ + "hawk" + ], + "range": "0.0.0 || >=0.1.1", + "nodes": [ + "node_modules/sntp" + ], + "fixAvailable": true + }, + "tap": { + "name": "tap", + "severity": "moderate", + "isDirect": true, + "via": [ + "coveralls", + "nyc" + ], + "effects": [], + "range": "1.1.0 - 11.1.2 || 13.0.0-rc.0 - 13.0.0", + "nodes": [ + "node_modules/tap" + ], + "fixAvailable": true + }, + "tap-mocha-reporter": { + "name": "tap-mocha-reporter", + "severity": "high", + "isDirect": false, + "via": [ + "diff" + ], + "effects": [], + "range": "0.0.4 - 5.0.0", + "nodes": [ + "node_modules/tap-mocha-reporter" + ], + "fixAvailable": true + }, + "tough-cookie": { + "name": "tough-cookie", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1097682, + "name": "tough-cookie", + "dependency": "tough-cookie", + "title": "tough-cookie Prototype Pollution vulnerability", + "url": "https://github.com/advisories/GHSA-72xf-g2v4-qvf3", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 6.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N" + }, + "range": "<4.1.3" + } + ], + "effects": [ + "request" + ], + "range": "<4.1.3", + "nodes": [ + "node_modules/tough-cookie" + ], + "fixAvailable": true + }, + "tunnel-agent": { + "name": "tunnel-agent", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1085744, + "name": "tunnel-agent", + "dependency": "tunnel-agent", + "title": "Memory Exposure in tunnel-agent", + "url": "https://github.com/advisories/GHSA-xc7v-wxcw-j472", + "severity": "moderate", + "cwe": [ + "CWE-200" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<0.6.0" + } + ], + "effects": [ + "request" + ], + "range": "<0.6.0", + "nodes": [ + "node_modules/tunnel-agent" + ], + "fixAvailable": true + }, + "uuid": { + "name": "uuid", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1119441, + "name": "uuid", + "dependency": "uuid", + "title": "uuid: Missing buffer bounds check in v3/v5/v6 when buf is provided", + "url": "https://github.com/advisories/GHSA-w5hq-g745-h8pq", + "severity": "moderate", + "cwe": [ + "CWE-787", + "CWE-1285" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N" + }, + "range": "<11.1.1" + } + ], + "effects": [ + "request" + ], + "range": "<11.1.1", + "nodes": [ + "node_modules/uuid" + ], + "fixAvailable": true + } + }, + "metadata": { + "vulnerabilities": { + "info": 0, + "low": 0, + "moderate": 5, + "high": 16, + "critical": 5, + "total": 26 + }, + "dependencies": { + "prod": 2, + "dev": 179, + "optional": 6, + "peer": 0, + "peerOptional": 0, + "total": 180 + } + } +} diff --git a/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1.json b/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1.json new file mode 100644 index 0000000..9f85afd --- /dev/null +++ b/pkg/scanner/npmaudit/testdata/mkdirp-0.5.1.json @@ -0,0 +1,84 @@ +{ + "auditReportVersion": 2, + "vulnerabilities": { + "minimist": { + "name": "minimist", + "severity": "critical", + "isDirect": false, + "via": [ + { + "source": 1096466, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-vh95-rmgr-6w4m", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 5.6, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:L/A:L" + }, + "range": "<0.2.1" + }, + { + "source": 1097677, + "name": "minimist", + "dependency": "minimist", + "title": "Prototype Pollution in minimist", + "url": "https://github.com/advisories/GHSA-xvch-5gv4-984h", + "severity": "critical", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 9.8, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H" + }, + "range": "<0.2.4" + } + ], + "effects": [ + "mkdirp" + ], + "range": "<=0.2.3", + "nodes": [ + "node_modules/minimist" + ], + "fixAvailable": false + }, + "mkdirp": { + "name": "mkdirp", + "severity": "critical", + "isDirect": true, + "via": [ + "minimist" + ], + "effects": [], + "range": "0.4.1 - 0.5.1", + "nodes": [ + "node_modules/mkdirp" + ], + "fixAvailable": false + } + }, + "metadata": { + "vulnerabilities": { + "info": 0, + "low": 0, + "moderate": 0, + "high": 0, + "critical": 2, + "total": 2 + }, + "dependencies": { + "prod": 3, + "dev": 0, + "optional": 0, + "peer": 0, + "peerOptional": 0, + "total": 2 + } + } +} diff --git a/pkg/scanner/npmaudit/testdata/request-2.88.2.json b/pkg/scanner/npmaudit/testdata/request-2.88.2.json new file mode 100644 index 0000000..395af89 --- /dev/null +++ b/pkg/scanner/npmaudit/testdata/request-2.88.2.json @@ -0,0 +1,214 @@ +{ + "auditReportVersion": 2, + "vulnerabilities": { + "form-data": { + "name": "form-data", + "severity": "critical", + "isDirect": false, + "via": [ + { + "source": 1109540, + "name": "form-data", + "dependency": "form-data", + "title": "form-data uses unsafe random function in form-data for choosing boundary", + "url": "https://github.com/advisories/GHSA-fjxv-7rqg-78g4", + "severity": "critical", + "cwe": [ + "CWE-330" + ], + "cvss": { + "score": 0, + "vectorString": null + }, + "range": "<2.5.4" + }, + { + "source": 1120745, + "name": "form-data", + "dependency": "form-data", + "title": "form-data: CRLF injection in form-data via unescaped multipart field names and filenames", + "url": "https://github.com/advisories/GHSA-hmw2-7cc7-3qxx", + "severity": "high", + "cwe": [ + "CWE-93" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N" + }, + "range": "<2.5.6" + } + ], + "effects": [ + "request" + ], + "range": "<=2.5.5", + "nodes": [ + "node_modules/form-data" + ], + "fixAvailable": false + }, + "qs": { + "name": "qs", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1113719, + "name": "qs", + "dependency": "qs", + "title": "qs's arrayLimit bypass in its bracket notation allows DoS via memory exhaustion", + "url": "https://github.com/advisories/GHSA-6rw7-vpxm-498p", + "severity": "moderate", + "cwe": [ + "CWE-20" + ], + "cvss": { + "score": 3.7, + "vectorString": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L" + }, + "range": "<6.14.1" + }, + { + "source": 1158507, + "name": "qs", + "dependency": "qs", + "title": "qs: Denial of Service via Attacker Controlled isBuffer", + "url": "https://github.com/advisories/GHSA-4mjr-xmp4-gh2g", + "severity": "moderate", + "cwe": [ + "CWE-248", + "CWE-703" + ], + "cvss": { + "score": 5.3, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L" + }, + "range": ">=2.2.5 <6.16.0" + } + ], + "effects": [ + "request" + ], + "range": "<=6.15.4", + "nodes": [ + "node_modules/qs" + ], + "fixAvailable": false + }, + "request": { + "name": "request", + "severity": "critical", + "isDirect": true, + "via": [ + { + "source": 1096727, + "name": "request", + "dependency": "request", + "title": "Server-Side Request Forgery in Request", + "url": "https://github.com/advisories/GHSA-p8p7-x288-28g6", + "severity": "moderate", + "cwe": [ + "CWE-918" + ], + "cvss": { + "score": 6.1, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N" + }, + "range": "<=2.88.2" + }, + "form-data", + "qs", + "tough-cookie", + "uuid" + ], + "effects": [], + "range": "*", + "nodes": [ + "node_modules/request" + ], + "fixAvailable": false + }, + "tough-cookie": { + "name": "tough-cookie", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1097682, + "name": "tough-cookie", + "dependency": "tough-cookie", + "title": "tough-cookie Prototype Pollution vulnerability", + "url": "https://github.com/advisories/GHSA-72xf-g2v4-qvf3", + "severity": "moderate", + "cwe": [ + "CWE-1321" + ], + "cvss": { + "score": 6.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:L/A:N" + }, + "range": "<4.1.3" + } + ], + "effects": [ + "request" + ], + "range": "<4.1.3", + "nodes": [ + "node_modules/tough-cookie" + ], + "fixAvailable": false + }, + "uuid": { + "name": "uuid", + "severity": "moderate", + "isDirect": false, + "via": [ + { + "source": 1119441, + "name": "uuid", + "dependency": "uuid", + "title": "uuid: Missing buffer bounds check in v3/v5/v6 when buf is provided", + "url": "https://github.com/advisories/GHSA-w5hq-g745-h8pq", + "severity": "moderate", + "cwe": [ + "CWE-787", + "CWE-1285" + ], + "cvss": { + "score": 7.5, + "vectorString": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:N" + }, + "range": "<11.1.1" + } + ], + "effects": [ + "request" + ], + "range": "<11.1.1", + "nodes": [ + "node_modules/uuid" + ], + "fixAvailable": false + } + }, + "metadata": { + "vulnerabilities": { + "info": 0, + "low": 0, + "moderate": 3, + "high": 0, + "critical": 2, + "total": 5 + }, + "dependencies": { + "prod": 48, + "dev": 0, + "optional": 0, + "peer": 0, + "peerOptional": 0, + "total": 47 + } + } +}