Skip to content

feat: restore Trivy scanning via Socket-built distribution - #100

Merged
lelia merged 10 commits into
mainfrom
restore-trivy-socket-dist
Aug 5, 2026
Merged

feat: restore Trivy scanning via Socket-built distribution#100
lelia merged 10 commits into
mainfrom
restore-trivy-socket-dist

Conversation

@lelia

@lelia lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

What

Restores Trivy-backed scanning and overhauls the publish pipeline — the scope grew deliberately as part of the major-release batch:

  1. Trivy restored via Socket-built distribution: main/heavy/app_tests images pull ghcr.io/socketdev/trivy:0.73.0@sha256:e3d9d5f1… (rebuilt from unmodified upstream source, digest-pinned, TRIVY_IMAGE override available). app_tests was still pulling aquasec/trivy:0.69.3 from Docker Hub by mutable tag — converted.
  2. OSS toolchain refresh: TruffleHog 3.96.0, OpenGrep v1.26.0, uv 0.12.1, gosec v2.28.0, Go 1.26.5, Socket CLI 2.5.8. Runtime bases (python/node) deliberately deferred to their own PR.
  3. Docker Hub creds scoped to the publish environment: merge-manifests binds the environment; build-test-push uses secrets: inherit with the reusable pipeline binding publish in push mode only (PR builds bind none). Repo-level DOCKERHUB_* secrets stay until the first publish validates the path, then get deleted.
  4. latest/latest-heavy aliases reintroduced (flavor: latest=true): safe now that version tags are registry-immutable (^\d+\.\d+\.\d+(-heavy)?$ rule applied on Docker Hub). Dispatch re-publish documented as recovery-only.
  5. Tests: smoke checks verify trivy presence + version-pin agreement + a functional trivy config scan in every image; new integration Test 4 runs the trivy connector end-to-end (--dockerfiles fixture) and explicitly fails on the connector's silent "Trivy not found" fallback.
  6. app_tests resurrected: the image had never built since the layout migration (stale source COPYs, wrong build context, dereferenced npm symlinks, dead venv against a corrupt uv.lock) — all repaired; lockfile regenerated.
  7. CI: unconditional GHCR login (+packages: read in callers) for the private base image; documented zizmor exception for secrets-inherit.
  8. Docs: repo-wide removal of the "temporarily without Trivy" messaging; 0.69.4–0.69.6 warnings retained for native installs; APT generic fix; pinning guidance updated for the new alias.

No Python changes — the trivy connector is config-driven and needed none.

Reviewer notes

  • Local builds need pull access to ghcr.io/socketdev/trivy; without it: docker build --build-arg TRIVY_IMAGE=aquasec/trivy:0.73.0 .
  • Release plan: separate self-contained 3.0.0 release PR (version refs + CHANGELOG only) after this merges; the tag-triggered publish is the live validation of the environment-secrets path and the new tag scheme.

Note

High Risk
Re-enables container scanning and changes release tagging (latest) plus credential scoping for production image publishes; incorrect pins or publish config could affect every consumer of the pre-built images.

Overview
Restores Trivy in the main, heavy, and app_tests images by sourcing a digest-pinned ghcr.io/socketdev/trivy base (TRIVY_IMAGE) instead of aquasec/trivy, with Dependabot no longer bumping Trivy independently. Tool pins move forward (e.g. TruffleHog, OpenGrep, uv, OpenGrep/gosec/Go in app tests) and docs/action.yml drop the “Trivy temporarily unavailable” wording while keeping native-install warnings for compromised 0.69.4–0.69.6 tags.

Publish and PR CI scope Docker Hub credentials to the publish environment (secrets: inherit, environment only on push), always log into GHCR with packages: read for the private Trivy base, and re-enable floating latest / latest-heavy alongside immutable semver tags. Smoke/integration tests now assert Trivy is present, matches the Dockerfile pin, and runs trivy config; app_tests builds from app_tests/ context with a fixed Dockerfile (npm symlinks, lockfile, removed stale runner COPYs).

Reviewed by Cursor Bugbot for commit 3b72bc4. Configure here.

Trivy returns to the main, heavy, and app_tests images as a Socket-built
distribution: rebuilt from unmodified upstream source (v0.73.0) by Socket's
own release pipeline and pinned by digest (TRIVY_IMAGE build arg; override
available for builds without registry access).

- Dockerfiles: digest-pinned trivy stage restored; version label now truthful
- CI: GHCR login on every build mode (private base image) + packages: read
- Smoke tests: drop the removal guard; verify trivy presence, version-pin
  agreement, and a functional 'trivy config' scan (the connector's code path)
- Dependabot: trivy untracked by design — updates flow from the Socket
  release process, never independent bumps
- Docs: removed the temporarily-disabled messaging repo-wide; kept the
  0.69.4-0.69.6 warnings for native installs; fixed the APT example to the
  'generic' distribution (upstream change in trivy v0.72.0)

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 06:08 — with GitHub Actions Inactive
Batch with the Trivy restore since this warrants a major point release:
TruffleHog 3.93.8 -> 3.96.0, OpenGrep v1.16.5 -> v1.26.0, uv 0.10.11 -> 0.12.1,
gosec v2.24.7 -> v2.28.0 (app_tests), Go 1.24.1 -> 1.26.5 (app_tests),
Socket CLI 2.5.0 -> 2.5.8 (heavy). Runtime bases (python:3.12, node:22)
deliberately deferred to their own PR.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia

lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Added the OSS toolchain refresh to this PR (major point release anyway): TruffleHog → 3.96.0, OpenGrep → v1.26.0, uv → 0.12.1, gosec → v2.28.0, Go → 1.26.5 (app_tests), Socket CLI → 2.5.8 (heavy). Runtime bases (python:3.12, node:22) deliberately not bumped here — those change the shipped runtime rather than the scanner toolchain and should get their own PR. CI smoke/integration runs validate every bump in this set.

@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 06:11 — with GitHub Actions Inactive
The app_tests image predates the socket_basics layout migration: its
COPY src/... and entrypoint.sh references no longer exist anywhere in the
repo, so it could not build at all (its CI job only fires on app_tests
changes and had not run since). Drop the stale references (tools image for
now; modernizing the harness is follow-up work) and build with app_tests/
as the context so its own pyproject/uv.lock and fixtures resolve.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 07:44 — with GitHub Actions Inactive
COPY --from dereferences the node image's npm/npx symlinks into flat files
under /usr/local/bin, breaking npm's relative require of ../lib/cli.js.
Copy node + node_modules and recreate the bin symlinks properly. Another
latent issue in this previously-unbuildable image, surfaced now that it
builds again.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 15:51 — with GitHub Actions Inactive
The /scripts venv installed light-s3-client for the removed legacy runner
against an empty stub pyproject, and app_tests/uv.lock was corrupt TOML
(empty package name) that modern uv refuses to parse. Regenerate a valid
lockfile for the stub manifest, drop the pointless venv bake from the image,
and retire the last socket-security-tools fossil (WORKDIR).

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 16:10 — with GitHub Actions Inactive
lelia added 2 commits August 5, 2026 12:47
Scans a fixture Dockerfile through socket-basics --dockerfiles, exercising
config -> trivy config -> result parsing. Explicitly fails on the connector's
'Trivy not found' fallback so a missing binary can't pass vacuously.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
Docker Hub secrets move from repo-level to environment secrets on 'publish'
(deployment policy: main + v* tags; secrets already created). merge-manifests
binds the environment directly; build-test-push calls the reusable workflow
(which cannot carry environment:), so it inherits secrets and the reusable
pipeline job binds the environment conditionally in push mode only — PR-branch
test builds bind no environment. Repo-level secrets stay until a real publish
validates the path, then get deleted.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 16:47 — with GitHub Actions Inactive
@lelia

lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Two additions per discussion: (1) integration Test 4 — the trivy connector now runs end-to-end against a fixture Dockerfile (--dockerfilestrivy config → parsing), with an explicit failure on the connector's "Trivy not found" fallback so a missing binary can't pass silently; (2) Docker Hub secrets scoped to the publish environmentmerge-manifests binds the environment directly, build-test-push uses secrets: inherit with the reusable pipeline binding the environment conditionally in push mode only (PR builds bind none, so branch policy isn't violated). PR CI validates the push:false path; the first real publish validates push:true, after which the repo-level DOCKERHUB_* secrets should be deleted.

zizmor's secrets-inherit audit flags the inherit on build-test-push; it is
required here — environment-scoped secrets only resolve on the environment-
bound job inside the called same-repo workflow, never through an explicit
workflow-call mapping. Inline ignore with rationale, matching the repo's
existing template-injection exceptions.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 16:53 — with GitHub Actions Inactive
@lelia
lelia marked this pull request as ready for review August 5, 2026 17:06
@lelia
lelia requested a review from a team as a code owner August 5, 2026 17:06
latest/latest-heavy float to the newest release as onboarding convenience;
exact version tags stay immutable registry-side (Docker Hub immutable-tag
rule ^\d+\.\d+\.\d+(-heavy)?$, already applied). Dispatch re-publish is now
documented as recovery-only: re-pushing a published version tag is rejected
by the registry, by design. Pinning docs updated to match.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia

lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

Comment thread .github/workflows/publish-docker.yml
metadata-action only suffixes the auto-generated latest tag when the suffix
carries onlatest=true; without it both matrix variants publish a bare,
racing 'latest' and 'latest-heavy' is never created. Caught by Bugbot.

Signed-off-by: lelia <2418071+lelia@users.noreply.github.com>
@lelia

lelia commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@lelia
lelia temporarily deployed to socket-firewall August 5, 2026 17:29 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 3b72bc4. Configure here.

@lelia
lelia merged commit 9be36b6 into main Aug 5, 2026
20 checks passed
@lelia lelia mentioned this pull request Aug 5, 2026
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.

2 participants