Skip to content

🔧 config(security): resolve open code-scanning alerts - #18

Merged
scttbnsn merged 1 commit into
mainfrom
security/resolve-code-scanning-alerts
Jun 16, 2026
Merged

scttbnsn merged 1 commit into
mainfrom
security/resolve-code-scanning-alerts

Conversation

@scttbnsn

Copy link
Copy Markdown
Contributor

Clears the remaining code-scanning alerts (the rename-era stale ones already auto-closed on a re-scan; this handles the genuinely-current ones).

CodeQL

gosec

Both findings were already justified inline, but with //nolint:gosec — which golangci-lint honors but the standalone SARIF gosec job does not, so they kept reporting. Switched to gosec-native #nosec:

  • G306 internal/banner/gen/main.go — generated banner asset, 0644 is intended.
  • G103 internal/banner/tty_unix.go — unsafe.Pointer required by SYS_IOCTL.

gosec ./... now reports 0 issues (was 2).

Scorecard — Pinned-Dependencies (×9)

Pinned all Docker base images by digest across Dockerfile, Dockerfile.release, Dockerfile.armv7, Dockerfile.dev:

  • golang:1.26.4-alpine@sha256:f1ddd9…
  • cgr.dev/chainguard/wolfi-base:latest@sha256:34977a…
  • alpine:3.24@sha256:28bd5f…

These are multi-arch index digests, so buildx still resolves the correct per-arch layer. Tags are kept for readability and the existing Dependabot docker ecosystem will track digest bumps. This is roadmap item #37.

Verification

go build + go vet clean · golangci-lint 0 issues · gosec 0 issues · docker build of the main Dockerfile succeeds on the pinned bases (golang + wolfi-base digests pull and build).

Scorecard re-runs on push to main, so the pinned-deps alerts auto-close on merge. The 3 non-code alerts (keygen clear-text-logging false-positive — it prints the public authorized_keys line — plus Scorecard Maintained/CII-Best-Practices, which aren't code issues) are dismissed separately.

- 🐛 fix(auth): handle the authorized_keys close error (CodeQL #19,
  go/unhandled-writable-file-close). appendKeyLine now uses a named
  return and checks the deferred Close, so a flush failure on write
  surfaces instead of being reported as success.
- 🎨 style(banner): switch two gosec suppressions from //nolint:gosec to
  gosec-native #nosec — G306 on the generated banner asset
  (gen/main.go, world-readable is intended) and G103 on the ioctl
  unsafe.Pointer (tty_unix.go, required by SYS_IOCTL). Both were already
  justified; the standalone SARIF gosec job only honors #nosec, so it
  kept reporting them. gosec now reports 0 issues across the repo.
- 🔧 config(docker): pin base images by digest in all Dockerfiles
  (golang:1.26.4-alpine, cgr.dev/chainguard/wolfi-base:latest,
  alpine:3.24) to clear Scorecard Pinned-Dependencies. Multi-arch index
  digests, so buildx stays per-arch correct; tags kept for readability
  and the existing Dependabot docker ecosystem tracks digest bumps.

Verified: go build/vet clean, golangci-lint 0 issues, gosec 0 issues,
and docker build of the main Dockerfile succeeds on the pinned bases.

@biggest-littlest biggest-littlest left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good fixes. The #nosec-vs-//nolint distinction is the real root cause on the gosec ones — switching to native #nosec is correct, and gosec ./... confirms 0. enroll.go close handling is the proper fix. Digest pins use multi-arch index digests so buildx stays correct, and docker build is verified. LGTM.

@ALARGECOMPANY ALARGECOMPANY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified the reasoning: keygen alert is the public authorized_keys line (genuine FP), Scorecard pins are index digests, Dependabot docker ecosystem already tracks them. Approving.

@scttbnsn
scttbnsn merged commit b98f0e2 into main Jun 16, 2026
16 checks passed
@scttbnsn
scttbnsn deleted the security/resolve-code-scanning-alerts branch June 16, 2026 15:22
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.

3 participants