Skip to content

test(license): cover the allow list, manifest extractors, module-cache resolver and CDX writer - #332

Merged
0x73746F66 merged 2 commits into
mainfrom
fix/297-license-helper-tests
Nov 13, 2026
Merged

0x73746F66 merged 2 commits into
mainfrom
fix/297-license-helper-tests

Conversation

@0x73746F66

@0x73746F66 0x73746F66 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #297

What

Stdlib tests with t.TempDir(), in two files:

internal/license/allowlist_manifest_test.go

  1. Allow list: LoadAllowListFromFile normalises known ids (mit -> MIT) and keeps unknown ones, errors on a missing file and invalid YAML; ParseAllowListCSV trims, drops empties, normalises; Contains/IsActive for nil, empty and populated lists, case-insensitive match and non-match.
  2. Manifest licences: extractManifestLicenses dispatch per basename; package.json string and {type} forms, missing licence, garbage; composer.json string and array (first wins), missing licence; Cargo.toml [package] gating, a license key outside the section ignored, license-file not taken as a licence; pyproject.toml string and {text = ...} forms and section gating; other files and unreadable paths give nil. manifestBasename.
  3. extractLicenseFromDescription over the pattern table and no match.

internal/license/modcache_cdx_test.go
3. goModCaseEncode; goModCachePath order GOMODCACHE > GOPATH/pkg/mod > ~/go/pkg/mod, and "" with no home; FindLicenseInModuleCache via the case-encoded path, with the v prefix added, falling back to the plain path, unclassifiable and missing modules, and no cache at all; FindLicenseInDir takes the first classifiable file in priority order.
4. FindingsToCDXVulnerabilities: first bom-ref per name@version wins, id/bom-ref/source, rating score/method/severity, every provenance property (spdx id, source file, is-direct true/false, path count only when > 0, introduced paths, evidence rule/result), no Affects for a package outside the BOM, empty input gives an empty slice.

Test-only.

Verified

go test -cover ./internal/license/: pass, 35.6% -> 41.6%. gofmt clean.

@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66 0x73746F66 changed the title test(license): cover the allow list, manifest licence extractors and description patterns test(license): cover the allow list, manifest extractors, module-cache resolver and CDX writer Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: test-only (internal/license). Uses the real allow list, manifest extractors, module-cache resolver and CDX writer with t.Setenv/t.TempDir(); nothing re-implemented. No changes needed.

@0x73746F66 0x73746F66 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reuse review: no reinvented Vulnetix patterns found. The change stays inside the package it covers, uses stdlib/testify helpers already used by the repo's tests, and adds no new client, auth, config-schema or shared-package duplicate (checked internal/testutils and sibling repos). Rebased onto current main locally: go vet and go test pass for every touched package. The earlier red checks (CodeQL Analyze, Install a release with verified provenance, Lockfile) were GitHub API rate-limit failures, not code failures; this will be re-run on a rebased head before merge.

…description patterns

Allow list loading (normalised ids, read and YAML errors), CSV parsing,
Contains/IsActive with nil, empty and populated lists; the package.json,
composer.json, Cargo.toml and pyproject.toml extractors including their
section gating and malformed input; manifestBasename; and the Docker Hub
description pattern table. Coverage 35.6% -> 39.0%.

Refs #297
goModCaseEncode, goModCachePath's GOMODCACHE > GOPATH > home order and
its no-home answer, FindLicenseInModuleCache (case-encoded path, added v
prefix, plain-path fallback, unclassifiable and missing), FindLicenseInDir
priority, and FindingsToCDXVulnerabilities (first bom-ref per package,
rating, every provenance and evidence property, no Affects for a package
outside the BOM). Coverage 39.0% -> 41.6%.

Closes #297
@0x73746F66
0x73746F66 force-pushed the fix/297-license-helper-tests branch from 8c5e75b to f33aefd Compare November 13, 2026 11:57
@github-actions

Copy link
Copy Markdown
Contributor

Vulnetix config plan

Manager gitops:vulnetix/cli, prune off, plan hash a8bd984f1753c68b180298051dd9e2524ab644d2ebe9e4c7c811ff4126753b5f

Object Action Changes
~ QualityGate/default update (adopt) severity: null -> "high"

0 to create, 1 to update, 0 to delete, 0 unchanged

@0x73746F66
0x73746F66 merged commit d86c81e into main Nov 13, 2026
29 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover internal/license allowlist, manifest extractors, module-cache resolver and CDX writer

1 participant