Skip to content

fix: close the open code-scanning and dependency findings [#41] - #50

Merged
manjudr merged 3 commits into
developmentfrom
fix/41-close-code-scanning-alerts
Sep 18, 2026
Merged

manjudr merged 3 commits into
developmentfrom
fix/41-close-code-scanning-alerts

Conversation

@nisargabd

@nisargabd nisargabd commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

1. Zip slip — pkg/plugin/manager.go (CodeQL go/zipslip, HIGH)
unzip() joined an attacker-controlled zip entry name into the destination path with no bounds check, so an entry like ../../etc/x could write outside the extraction directory. Now rejected. Ships with a regression test that was verified to fail without the guard.

2. otel dependency CVEs — go.mod (Trivy, MEDIUM + LOW)
CVE-2026-81871 (otlplog/otlploggrpc v0.19.0) and CVE-2026-81870 (otlptrace, otlptracegrpc, otel/sdk). Bumps the whole otel release train together — v1.45.0 stable, v0.21.0 log — rather than only the four flagged modules, because the two lines release in lockstep.

This forces a code change in pkg/telemetry/audit.go and core/module/handler/stdHandler.go: otel/log v0.21.0 removes its own Value/KeyValue types in favour of the shared go.opentelemetry.io/otel/attribute ones (opentelemetry-go PR 8490). Same keys, same values, same OTLP output — no behaviour change. A narrower bump isn't possible; otlploggrpc@v0.21.0 requires otel/log@v0.21.0, so module resolution pulls the new API in regardless.

Worth noting this is not theoretical cleanup: scanning the currently published ghcr.io/openagrinet/network-adapter:0.0.1 against today's vulnerability database still reports CVE-2026-81870 in the shipped binary. An image built from this branch reports zero.

3. Coverage — test files only
cover-diff grades the whole of every file a PR touches, not just the changed lines, so these fixes were blocked by coverage debt predating them. Covers what was genuinely untested: manager.go's CatalogPublisher, CatalogBlobStore, Crawler, Mapper, ProviderStep and SchemaVersionMediator were all at 0%, and stdHandler.go's plugin-loader argument validation was thinly covered.

Why

Closes the findings tracked in #41. Two items in that issue are deliberately not fixed in code, with reasoning:

  • go/incorrect-integer-conversion x2 (catalogcrawler.go:153,158) — dismissed as false positive. CodeQL flags int64→int narrowing without knowing the target architecture. This repo only ships amd64/arm64, where Go's int is 64 bits — identical width to int64, so the conversion cannot narrow or wrap. A guard against it would be a branch that can never execute, which is dead code and permanently uncoverable. Full reasoning is recorded on the dismissed alerts themselves: code-scanning alert 48 and alert 49.
  • CVE-2026-85091 (zlib, container image) — a wolfi-base base-image issue, not application code. Confirmed already absent from a fresh wolfi-base:latest pull, so no change or ignore-file is needed.

Testing

  • gofmt, go vet clean on every touched package.
  • Full suite green: go test across all packages, plus the pre-push hook's full run.
  • New zip-slip test confirmed to fail with the guard removed and pass with it restored — it catches the real bug, not just the happy path.
  • trivy fs . on the bumped go.mod: 0 vulnerabilities, down from 4.
  • trivy image on an image built from this branch: 0 vulnerabilities, base layer and Go binary both clean.
  • govulncheck ./...: 0 reachable vulnerabilities.
  • make cover-diff locally: 86% of changed lines covered, min 80% (was 75%). manager.go 76%→90%, stdHandler.go 74%→81%.
  • otel migration verified against the upstream changelog for the full v1.43→v1.45 / v0.19→v0.21 range: the only other breaking changes are WithEndpointURL path handling (HTTP exporters only — this repo uses gRPC exclusively and never calls it) and the sdk/metric cardinality limit (already active, repo was already on sdk/metric v1.44.0). Neither applies.

One incidental change: stdHandler.go picks up a gofmt pass. It was already unformatted on development and the pre-commit hook checks any file a commit touches — whitespace only, no logic in those lines.

Closes #41

unzip() joined an attacker-controlled zip entry name straight into the
destination path with no bounds check, so a "../" entry could write
outside dest (CodeQL go/zipslip).
@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

📊 Test Coverage: ✅ Passed — 83% of changed lines covered, min 80%

@github-actions

github-actions Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

🛡️ Trivy security scan (CRITICAL,HIGH,MEDIUM,LOW)

View full run

Go dependencies

No findings at CRITICAL,HIGH,MEDIUM,LOW.

Container image

No findings at CRITICAL,HIGH,MEDIUM,LOW.

@nisargabd nisargabd changed the title fix: close open code-scanning alerts [#41] fix: close the open code-scanning and dependency findings [#41] Sep 18, 2026
@nisargabd
nisargabd force-pushed the fix/41-close-code-scanning-alerts branch from 4639e33 to c559309 Compare September 18, 2026 10:13
CVE-2026-81871 (otlploggrpc v0.19.0, MEDIUM) and CVE-2026-81870
(otlptrace, otlptracegrpc, otel/sdk, LOW) were failing trivy-gate on
every PR. Bumps the whole otel release train together -- v1.45.0 for the
stable line, v0.21.0 for the log line -- rather than only the four
flagged modules, because the two lines are released in lockstep.

otel/log v0.21.0 drops its own Value/KeyValue types in favour of the
shared go.opentelemetry.io/otel/attribute ones (upstream
open-telemetry/opentelemetry-go#8490), so the audit-log call sites move
to attribute.String/StringValue/KeyValue. Same keys, same values, same
OTLP output -- no behaviour change.

A narrower bump is not possible: otlploggrpc v0.21.0 requires otel/log
v0.21.0, so module resolution pulls the new API in regardless.

stdHandler.go also picks up a gofmt pass: it was already unformatted on
development, and the pre-commit hook checks any file the commit touches.
Whitespace only, no logic in those lines.
cover-diff grades the whole of every file a PR touches, not just the
changed lines, so the security fixes in manager.go and stdHandler.go
were being blocked by coverage debt that predates them: 76% and 74%
against an 80% floor.

Covers what was genuinely untested rather than padding the number.
manager.go's CatalogPublisher, CatalogBlobStore, Crawler, Mapper,
ProviderStep and SchemaVersionMediator were all at 0% despite being
the same provider-lookup shape as Publisher and Cache next to them;
each now has the success, provider-error and plugin-missing cases the
neighbouring accessors already had. stdHandler.go's LoadKeyManager,
loadManifestLoader, loadPayloadStore, LoadPolicyChecker and
loadPayloadTransformerStep get their argument-validation branches
covered, including the registry that satisfies RegistryLookup but not
RegistryMetadataLookup.

manager.go 76% -> 90%, stdHandler.go 74% -> 81%, changed-file total
75% -> 86%. Test files only; no production code touched.
@nisargabd
nisargabd force-pushed the fix/41-close-code-scanning-alerts branch from c559309 to 1a815d9 Compare September 18, 2026 10:24
@manjudr

manjudr commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@manjudr
manjudr merged commit 3bd63f4 into development Sep 18, 2026
4 checks passed
@manjudr
manjudr deleted the fix/41-close-code-scanning-alerts branch September 18, 2026 12:01
@nisargabd nisargabd linked an issue Sep 21, 2026 that may be closed by this pull request
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.

Fix open code scanning alerts

2 participants