Skip to content

Phase 3 — Targets & registries - #5

Merged
tyler-rich merged 1 commit into
mainfrom
phase/P3
Jul 3, 2026
Merged

Phase 3 — Targets & registries#5
tyler-rich merged 1 commit into
mainfrom
phase/P3

Conversation

@tyler-rich

Copy link
Copy Markdown
Owner

Summary

Phase 3 (PLAN §12) adds the full set of scan targets and credential management on top of the Phase 2 image-scanning core. Everything is gated behind the existing RBAC/CSRF/audit machinery, and stored secrets stay write-only and field-encrypted, decrypted only at scan time into tmpfs and shredded afterward.

What changed

Scanners

  • Trivy repo target with branch/commit/tag selection and private-repo auth.
  • Grype filesystem (dir:) and SBOM (sbom:) targets.
  • Syft SBOM generation as an opt-in per-scan pass, stored as a downloadable artifact.
  • Scanner interface reworked to dispatch by target type with an optional environment overlay.

Credentials & data model (new registries, git_credentials, docker_environments tables + migration 0004)

  • Registry credentials with transient tmpfs docker-config materialization (auths for static creds/tokens, credHelpers for ECR/GCR/ACR), shredded after the subprocess exits.
  • Git-provider credentials: GitHub/GitLab via env tokens, generic host via HTTPS credential embedding — with URL-userinfo redaction added to the logging filter and applied to stored scan errors.
  • Secrets are AES-256-GCM field-encrypted, AAD-bound per field, write-only over the API (masked reads).

APIs

  • Admin CRUD for registries (+ real registry-v2 connectivity test), git credentials, and Docker environments; operator read so scans can select a credential.
  • Docker-environment image enumeration via the read-only socket proxy, gated on an explicit residual-risk acknowledgment.
  • Extended scan create for the new target types, plus a multipart SBOM upload endpoint.
  • Filesystem scanning gated behind SCRYE_FILESYSTEM_SCAN_ROOTS (off by default) so arbitrary host paths can't be read.

Frontend

  • Settings area (Registries / Git providers / Docker environments) and an extended New scan page covering all target types, credential selection, branch/ref, SBOM upload, and SBOM generation.

Testing

  • Backend: 146 pytest tests pass (new coverage for credential materialization/shred, secret store AAD, target/command building, Docker-proxy parsing, and the new API routers incl. write-only masking and RBAC). ruff + black clean; migration matches models; /healthz boots healthy.
  • Frontend: tsc build, ESLint, and Prettier all clean.

See docs/PLAN.md § Deviations for changes made in this phase.


Generated by Claude Code

…meration

Phase 3 adds the full set of scan targets and credential management on top of
the Phase 2 image scanning core.

Scanners
- Trivy `repo` target with branch/commit/tag selection and private-repo auth.
- Grype filesystem (`dir:`) and SBOM (`sbom:`) targets.
- Syft SBOM generation as an opt-in per-scan pass, stored as an artifact.
- Scanner interface reworked to dispatch by target type with an env overlay.

Credentials (write-only, field-encrypted; decrypted only at scan time)
- Registry credentials with transient tmpfs docker-config materialization
  (auths / credHelpers) that is shredded after the subprocess exits.
- Git-provider credentials: GitHub/GitLab env tokens; generic HTTPS embedding
  with URL-userinfo redaction added to the logging filter and stored errors.
- New models/migration for registries, git_credentials, docker_environments.

APIs
- Admin CRUD for registries (+ connectivity test), git credentials, and Docker
  environments; operator read for target selection.
- Docker-environment image enumeration via the read-only socket proxy, gated on
  an explicit residual-risk acknowledgment.
- Extended scan create for the new targets plus a multipart SBOM upload endpoint.
- Filesystem scanning gated behind SCRYE_FILESYSTEM_SCAN_ROOTS (off by default).

Frontend
- Settings area (registries / git providers / Docker environments) and an
  extended New scan page covering all target types and credential selection.

Docs, tests, and deviations updated; ruff/black/eslint/prettier clean.
See docs/PLAN.md § Deviations for Phase 3 changes.
@tyler-rich
tyler-rich merged commit 0dc2dc7 into main Jul 3, 2026
2 checks passed
tyler-rich added a commit that referenced this pull request Jul 3, 2026
…8xmikc

fix(security): resolve Phase 3 review findings #2 (git auth off-argv) and #5 (admin-only credential lists)
@tyler-rich
tyler-rich deleted the phase/P3 branch July 6, 2026 06:43
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Phase 3 — Targets & registries
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Finding #2 — generic-host git credential no longer rides in the process
argv. Trivy clones with go-git, which ignores GIT_ASKPASS/.netrc/credential
helpers, so generic (non-GitHub/GitLab) private repos previously embedded
username:token in the clone URL passed to `trivy repo` — visible via
/proc/<pid>/cmdline. Generic HTTPS hosts are now cloned into tmpfs with the
system `git` binary via a transient GIT_ASKPASS helper (mode 0700; echoes the
credential from the clone subprocess's own environment, never argv, never the
parent env, never the script file, never persisted), the requested ref is
checked out, and Trivy then scans the local checkout. The helper and checkout
are shredded/removed in a finally block on success, failure, or cancellation.
`git` is added to the runtime image. GitHub/GitLab keep Trivy's native
GITHUB_TOKEN/GITLAB_TOKEN env path (already off-argv).

Finding #5 — registry and git-credential list endpoints (full metadata) are
now admin-only; operators previously had read access to host/username/provider.
Two new operator endpoints (GET /registries/options, GET /git-credentials/
options) return only {id, name} for scan-launch selection, exposing no
credential metadata. The New Scan page uses these option endpoints.

Implements docs/reviews/phase3-finding2-resolution.md (Option 1). See
docs/PLAN.md §14 for both dated deviation entries and the two spec adaptations
(askpass 0700 not 0600 since git execs it; async run_command on the existing
tmpfs seam instead of sync subprocess).
tyler-rich added a commit that referenced this pull request Jul 9, 2026
…8xmikc

fix(security): resolve Phase 3 review findings #2 (git auth off-argv) and #5 (admin-only credential lists)
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Phase 3 — Targets & registries
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Finding #2 — generic-host git credential no longer rides in the process
argv. Trivy clones with go-git, which ignores GIT_ASKPASS/.netrc/credential
helpers, so generic (non-GitHub/GitLab) private repos previously embedded
username:token in the clone URL passed to `trivy repo` — visible via
/proc/<pid>/cmdline. Generic HTTPS hosts are now cloned into tmpfs with the
system `git` binary via a transient GIT_ASKPASS helper (mode 0700; echoes the
credential from the clone subprocess's own environment, never argv, never the
parent env, never the script file, never persisted), the requested ref is
checked out, and Trivy then scans the local checkout. The helper and checkout
are shredded/removed in a finally block on success, failure, or cancellation.
`git` is added to the runtime image. GitHub/GitLab keep Trivy's native
GITHUB_TOKEN/GITLAB_TOKEN env path (already off-argv).

Finding #5 — registry and git-credential list endpoints (full metadata) are
now admin-only; operators previously had read access to host/username/provider.
Two new operator endpoints (GET /registries/options, GET /git-credentials/
options) return only {id, name} for scan-launch selection, exposing no
credential metadata. The New Scan page uses these option endpoints.

Implements docs/reviews/phase3-finding2-resolution.md (Option 1). See
docs/PLAN.md §14 for both dated deviation entries and the two spec adaptations
(askpass 0700 not 0600 since git execs it; async run_command on the existing
tmpfs seam instead of sync subprocess).
tyler-rich added a commit that referenced this pull request Jul 9, 2026
…8xmikc

fix(security): resolve Phase 3 review findings #2 (git auth off-argv) and #5 (admin-only credential lists)
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Phase 3 — Targets & registries
tyler-rich added a commit that referenced this pull request Jul 9, 2026
Finding #2 — generic-host git credential no longer rides in the process
argv. Trivy clones with go-git, which ignores GIT_ASKPASS/.netrc/credential
helpers, so generic (non-GitHub/GitLab) private repos previously embedded
username:token in the clone URL passed to `trivy repo` — visible via
/proc/<pid>/cmdline. Generic HTTPS hosts are now cloned into tmpfs with the
system `git` binary via a transient GIT_ASKPASS helper (mode 0700; echoes the
credential from the clone subprocess's own environment, never argv, never the
parent env, never the script file, never persisted), the requested ref is
checked out, and Trivy then scans the local checkout. The helper and checkout
are shredded/removed in a finally block on success, failure, or cancellation.
`git` is added to the runtime image. GitHub/GitLab keep Trivy's native
GITHUB_TOKEN/GITLAB_TOKEN env path (already off-argv).

Finding #5 — registry and git-credential list endpoints (full metadata) are
now admin-only; operators previously had read access to host/username/provider.
Two new operator endpoints (GET /registries/options, GET /git-credentials/
options) return only {id, name} for scan-launch selection, exposing no
credential metadata. The New Scan page uses these option endpoints.

Implements docs/reviews/phase3-finding2-resolution.md (Option 1). See
docs/PLAN.md §14 for both dated deviation entries and the two spec adaptations
(askpass 0700 not 0600 since git execs it; async run_command on the existing
tmpfs seam instead of sync subprocess).
tyler-rich added a commit that referenced this pull request Jul 9, 2026
…8xmikc

fix(security): resolve Phase 3 review findings #2 (git auth off-argv) and #5 (admin-only credential lists)
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.

1 participant