Skip to content

test(lsp): cover SCA engine lookups, retry classification, diagnostic counts and mapping fallbacks - #333

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

0x73746F66 merged 2 commits into
mainfrom
fix/295-lsp-helper-tests

Conversation

@0x73746F66

@0x73746F66 0x73746F66 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #295

What

Stdlib table tests in two files.

internal/lsp/sca_engine_queries_test.go (over seedEngine from sca_test.go)

  1. Engine queries: PackagesFor known/unknown path; VerdictFor for a vulnerable and a clean package, an unknown version and an empty coordinate; IsManifest; ManifestPaths sorted; IntroducedBy returns the sorted direct parents in the same directory group, nothing for a package whose only parent is transitive, a direct package, a group without a graph or an unknown directory; AnchorFor resolves through anchor.Find (1-based line) and refuses a path never parsed.
  2. SourceForKind default source for an unmapped kind; severityToLSP case/space handling and the LowAsHint branch for low, info, empty and unknown severities; kindToTool for OCI, empty, mapped and custom kinds.

internal/lsp/sca_helpers_test.go
2. flattenPackages path order; buildPurls index alignment, de-duplication, empty purls never requested; countVulnerable.
3. isTransientSCAErr: nil; 429/500/wrapped 503 retryable; 400/403 terminal; NotFoundError terminal; wrapped deadline retryable; wrapped cancel terminal; transport error retryable; decode error terminal. backoffFor floor and cap.
4. CountBySeverity and DescribeCounts.

Test-only.

Verified

go test ./internal/lsp/ (new tests) and go vet ./internal/lsp/ pass; 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(lsp): cover SCA retry classification, backoff, diagnostic counts and purl helpers test(lsp): cover SCA engine lookups, retry classification, diagnostic counts and mapping fallbacks 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 change in internal/lsp. The new tests build on the package's existing fixture (seedEngine) and the real types (scan.DepGraph, vdb.CliAPIError, protocol severities) rather than introducing local doubles or a second helper, and they exercise the production functions directly (isTransientSCAErr, backoffFor, buildPurls, CountBySeverity/DescribeCounts, severityToLSP, kindToTool). Nothing duplicates an existing Vulnetix test utility or shared package. No changes needed.

@0x73746F66
0x73746F66 force-pushed the fix/295-lsp-helper-tests branch 2 times, most recently from 654af40 to 4f0bd23 Compare November 12, 2026 15:51
@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 force-pushed the fix/295-lsp-helper-tests branch 2 times, most recently from db0de63 to 0f5b2de Compare November 12, 2026 17:30
@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 force-pushed the fix/295-lsp-helper-tests branch 2 times, most recently from b37e98d to 484cd1d Compare November 12, 2026 18:58
@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 force-pushed the fix/295-lsp-helper-tests branch 2 times, most recently from 4ed5b63 to d9337d9 Compare November 12, 2026 21:00

@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.

… and purl helpers

isTransientSCAErr over 429/5xx/4xx, not-found, deadline, cancellation,
transport and decode errors; backoffFor's floor and cap; CountBySeverity
and DescribeCounts; flattenPackages path order; buildPurls index
alignment and de-duplication; countVulnerable.

Refs #295
…llbacks

PackagesFor, VerdictFor, IsManifest, ManifestPaths, IntroducedBy (direct
parents in the same directory only, none for a direct or transitive-only
parent, none without a graph) and AnchorFor over the seeded engine; the
SourceForKind, severityToLSP and kindToTool fallbacks.

Closes #295
@0x73746F66
0x73746F66 force-pushed the fix/295-lsp-helper-tests branch from d9337d9 to 4a651f8 Compare November 13, 2026 12:04
@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 06babb1 into main Nov 13, 2026
30 of 33 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/lsp sca-engine queries, retry classification and diagnostics aggregators

1 participant