Skip to content

test(cdx): cover deployment context, scope mappers, format helpers and merge gaps - #331

Merged
0x73746F66 merged 1 commit into
mainfrom
fix/298-cdx-deployment-format-tests
Nov 13, 2026
Merged

0x73746F66 merged 1 commit into
mainfrom
fix/298-cdx-deployment-format-tests

Conversation

@0x73746F66

Copy link
Copy Markdown
Member

Closes #298

What

New internal/cdx/deployment_format_test.go (stdlib, small hand-built BOMs like the existing tests):

  1. Deployment context: Empty (zero, empty tag map, each field), String (set fields only, tags sorted, empty tag values dropped, stable across calls), ApplyDeploymentContext -> DeploymentContextFromBOM round trip, re-apply replaces rather than duplicates, nil BOM / empty context are no-ops, only set fields are written; DeploymentContextFromBOM on nil BOM, nil metadata, unrelated properties and a tag property with no key.
  2. mapLocalScopeToCDX and nativeScopeToEnvironment over every scope constant plus empty/unknown; ExportCompRefs.
  3. FormatSpec, ValidSpecVersions, and every NormalizeFormat alias (case-insensitive), the raw forms and the default.
  4. mergeComponentGaps (fills only empty fields, unions hashes/authors/external refs/properties keeping existing first), mergeVulnerabilities (dedupe on id + bom-ref + affects, including repeats within the incoming list), appendPropIfMissing.

BuildDependencies is left to its existing callers' tests; the card's item 5 (lsp helpers) is out of this package as the card notes.

Verified

go test -cover ./internal/cdx/: pass, 55.9% -> 65.9%. 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 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/cdx). Exercises ApplyDeploymentContext, scope mappers and format helpers on the shared cdx.BOM (vdb-cyclonedx) model; no local model copies. 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.

…d merge gaps

Deployment context Empty/String/Apply/FromBOM including sorted tags,
re-apply replacing rather than duplicating, and nil/empty no-ops; the
local scope to CycloneDX scope and environment mappers; FormatSpec,
ValidSpecVersions and every NormalizeFormat alias; mergeComponentGaps,
mergeVulnerabilities, appendPropIfMissing and ExportCompRefs.
Coverage 55.9% -> 65.9%.

Closes #298
@0x73746F66
0x73746F66 force-pushed the fix/298-cdx-deployment-format-tests branch from aa49ed8 to 33e3e08 Compare November 13, 2026 11:50
@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 f35f3a3 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/cdx deployment context, local writers, format helpers and merge gaps

1 participant