Repository navigation
feat(security): sigstore cosign container provenance and image signing (#112) - #213
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved critical and moderate findings remain in workflow safeguards, secret handling, and Cosign error paths.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds Sigstore Cosign container signing and verification to the Docker CLI and FastMCP, along with GHCR cleanup and CI publication safeguards.
Changes:
- Adds keyless/keyed signing, verification, keyring integration, models, and exceptions.
- Adds tests, MCP tools, and documentation.
- Updates container cleanup and publication workflows.
File summaries
| File | Reviewed scope |
|---|---|
tests/test_fastmcp_contracts.py |
MCP command contract tests |
tests/test_docker_cosign.py |
Cosign runner and CLI tests |
src/devops_cli/models/docker.py |
Signing and verification models |
src/devops_cli/exceptions/docker.py |
Cosign exception types |
src/devops_cli/docker/cosign.py |
Cosign execution and key handling |
src/devops_cli/commands/docker.py |
Docker signing and verification commands |
src/devops_cli/ai/mcp/server.py |
FastMCP signing tools |
README.md |
CLI command matrix |
docs/MCP_TOOLS.md |
MCP documentation |
docs/ERRORS.md |
Error catalog |
docs/commands/docker.md |
Docker command reference |
docs/CLI_REFERENCE.md |
Generated CLI reference |
docs/agent/tasks/task-112-sigstore-cosign-container-provenance.md |
Task tracking and acceptance criteria |
.github/workflows/cleanup-devcontainer.yml |
Dynamic PR image cleanup |
.github/workflows/ci.yml |
Pre-publication PR state check |
Review details
Suppressed comments (12)
.github/workflows/ci.yml:112
- This new workflow invokes bare
gh pr view, contrary to the automated-workflow convention in AGENTS.md:51 and 305-307 that GitHub operations go through rate-manageddevops gh/run_gh. Use the managed client or an equivalent rate-limited API action rather than bypassing repository quota controls.
PR_STATE=$(gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json state --jq .state 2>/dev/null || echo "OPEN")
.github/workflows/ci.yml:119
- This status is checked only before
devcontainers/ciperforms the build. If the PR closes while that potentially long build is running, the step still sees the earlier OPEN output and pushes the PR tag, so the pre-publish check does not prevent in-flight obsolete publishes as described. Build without pushing, then perform a final state check immediately before a separate push (or otherwise cancel closed-PR runs).
- name: Build & Publish PR DevContainer Image
if: github.event_name == 'pull_request' && steps.pr_status.outputs.state == 'OPEN'
.github/workflows/cleanup-devcontainer.yml:62
- This new workflow invokes bare
gh pr list, but AGENTS.md:51 and 305-307 require automated GitHub operations to use the rate-manageddevops gh/run_ghpath. Route the lookup through the repository's managed wrapper (or an equivalent rate-limited API action) so pagination, caching, and quota safeguards are preserved.
if OPEN_PRS=$(gh pr list --repo "${{ github.repository }}" --state open --json number --jq '.[].number | "pr-\(.)"' 2>/dev/null); then
src/devops_cli/commands/docker.py:476
- These new subcommands execute a networked signing/verification operation without an OpenTelemetry span or
GLOBAL_METRICSrecord. That makes latency and failures invisible to the repository's required command observability, unlike instrumented commands such asvalkeyand the explicit AGENTS.md telemetry rule.
@app.command("sign")
def docker_sign(
src/devops_cli/commands/docker.py:621
verify_imagecan raiseCosignErrorwhen akeyring:public key is missing because_resolve_signing_keyis shared by signing and verification, but this handler catches onlyCosignVerificationError.devops docker verify --key keyring:missingwill therefore escape as an unhandled exception; import and catchCosignErrorhere or raise a verification-specific error during key resolution.
except (DependencyError, CosignVerificationError) as exc:
src/devops_cli/docker/cosign.py:197
- The verification timeout has the same unhandled
TimeoutExpiredpath: a slow registry produces an uncaught exception rather than theCosignVerificationErrorthatdocker_verifyis prepared to render. Normalize this timeout before returning fromverify_image.
timeout=self.timeout,
src/devops_cli/docker/cosign.py:46
- This helper is also used by
verify_image, wherekeyring:<name>refers to a public verification key, not necessarily a private signing key. The current message is misleading for verification failures; use neutral wording such as “Key secret … not found in OS Keyring.”
raise CosignError(f"Private key secret '{secret_name}' not found in OS Keyring")
src/devops_cli/docker/cosign.py:46
- This helper is shared by signing and verification, but a missing keyring entry always raises
CosignError.docker_verifycatches onlyDependencyErrorandCosignVerificationError, sodevops docker verify ... --key keyring:missingescapes as an unhandled exception instead of a normal verification error. Use an operation-specific exception or translate this error in the verify path.
secret_name = key_ref.removeprefix("keyring:")
key_content = get_keyring_secret(secret_name)
if not key_content:
raise CosignError(f"Private key secret '{secret_name}' not found in OS Keyring")
src/devops_cli/docker/cosign.py:160
- When a key is supplied,
build_cosign_sign_cmdtakes the keyed path even ifreq.keylessremains true. The live result reports the wrong signing mode, so automation cannot reliably distinguish keyless from keyed provenance.
keyless=req.keyless,
src/devops_cli/docker/cosign.py:70
- Cosign's current identity-token environment variable is
SIGSTORE_ID_TOKEN, and the CLI also exposes--identity-token;COSIGN_IDENTITY_TOKENis not defined by the upstream cosign environment package. As a result, both token forms supplied here are ignored and keyless signing can fall back to interactive authentication instead of using the requested OIDC identity.
env["COSIGN_IDENTITY_TOKEN"] = token_val
else:
env["COSIGN_IDENTITY_TOKEN"] = oidc_token
src/devops_cli/models/docker.py:174
- A verification result defaults to
verified=Truebefore any Cosign operation has succeeded. Any caller that constructs this result for an unverified, partial, or error state can accidentally expose a successful verification status; this should fail closed and be set true only after a successful verification.
verified: bool = Field(
default=True, description="Whether signature or attestation verified successfully"
)
src/devops_cli/models/docker.py:114
- The keyed mode can be selected with
keyless=Falsewhilekeyis unset. That combination produces neither a key argument nor the keyless confirmation bypass, so Cosign may prompt interactively or fail after the command has started instead of returning a deterministic validation error. Reject keyed requests without a key before invoking the subprocess.
key: str | None = Field(default=None, description="Path to private key or keyring:<name>")
keyless: bool = Field(default=True, description="Sign keylessly using OIDC/Fulcio")
- Files reviewed: 15/15 changed files
- Comments generated: 11
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
* feat(release): v0.2.18 * fix(security): harden secret sanitizer boundaries and safe path exclusions (#116) (#203) * fix(security): harden secret sanitizer boundaries and safe path exclusions (#116) * fix(release): default release PRs to draft mode * fix(security): harden secret boundaries, remove extension lookahead, and update task status (#116) * fix(security): remediate devsecops findings and add native rate management (#204) * test * fix(security): remediate devsecops findings and add native rate management * docs(task): update task-204 status to in review and link PR #204 * fix(security): permit token masking in filesystem path arguments * fix(security): remediate review findings, exclude home in sandbox, and relocate MockProvider (#205) (#206) * fix(security): remediate review findings, exclude home in sandbox, and relocate MockProvider (#205) * docs(task): update task-205 status to in review and link PR #206 * test(sandbox): provide explicit tmp_path workspace_dir in test_docker_sandbox_wait_timeout * fix(rag): support both gitignore and gitwildmatch pathspec factories * feat(sandbox): multi-tier networking options and decommission task.md (#207) (#208) * feat(sandbox): multi-tier networking options and decommission task.md index (#207) * docs(agent): transition task 207 to in-review with PR #208 * test(projects): update test fixtures to eliminate task.md references * fix(security): replace concrete RFC 1918 and internal homelab endpoints with standard documentation values * fix(sandbox): harden network containment, secret output masking, and rate limiter caching * fix(sandbox): remediate egress containment, dns resolution, and output masking findings (#207) * fix(security): stream sandbox container output directly to sys streams avoiding logger sink cleartext alerts (#207) * docs(agents): mandate working pull requests from oldest to newest (FIFO) * docs(roadmap): add v0.2.23 reactive workstation command center and interactive TUI * docs(agents): mandate root-cause remediation, roadmap synthesis, and interaction improvement * fix(docs): escape placeholder angle brackets and prune completed roadmap matrix items * fix(security): stream sandbox output via centralized output writers to resolve codeql cleartext alerts * fix(k8s): uncap ollama memory limits and elevate daemonset/deployment thresholds (#209) (#210) * fix(k8s): uncap ollama memory limits and elevate daemonset/deployment thresholds (#209) * fix(k8s): add CoreDNS resource configs and tighten test assertions (#209) * fix(github): enforce gh request throttling, disk quota persistence, and diff-only project sync (#211) (#212) * fix(github): enforce window-budgeted rate pacing, disk quota persistence, and diff-only project sync (#211) * docs(agent): record PR #212 in task 211 tracking * fix(github): enforce low-quota circuit breakers, preamble-tolerant JSON parsing, and casing-safe project diffing (#211) * fix(github): replace quota thresholds with logical exponential backoff (#211) * test(github): patch run_gh instead of run_subprocess in reconcile tests (#211) * fix(github): derive rate limit pacing from actual response values without hardcoded windows (#211) * fix(ci): stop running all of the ci tasks every time a pr is marked ready for review. * fix(ci): decouple project automation into dedicated workflow and add quota safety guards (#211) * fix(github): align rate limiter baseline velocity and add quota test coverage (#211) * refactor(ai): eliminate inline function parameter defaults in favor of defaults submodule * fix(github): enforce strict non-negative rate quotas, 25% threshold, and remediate review findings (#211) * fix(typecheck): resolve Path None guard and optional quota remaining in mypy (#211) * docs: refresh CLI and MCP references for updated commands and errors (#211) * fix(ci): enforce mandatory pre-push devops ci gate, handle unauthenticated acquire, and expand test coverage (#211) * fix(pr): align checks fallback to run_subprocess and isolate rate limiter sleep test (#211) * fix(ci): complete pre-push gate, argo drift tests, and coverage expansion (#211) * docs(agent): update task-211 documentation with linear window pacing and pre-push quality gate (#211) * fix(pr): guard pr ready against failing checks and fix project automation uv sync (#211) * docs(pr): update cli and mcp reference for pr ready --force * fix(github): address pr 212 review comments on workflows, sandbox, defaults, and rate limiter (#211) * fix(security): derive artifact version from package metadata and validate whitelist tokens (#211) * feat(security): sigstore cosign container provenance and image signing (#112) (#213) * fix(ci): prune all merged PR devcontainer images from ghcr and guard in-flight builds * feat(security): sigstore cosign container provenance and image signing (#112) * docs(agent): link PR 213 in task 112 tracking doc * fix(security): resolve review comments for cosign container provenance (#112) * ci: re-trigger validation after resolving all review threads * feat(security): falco ebpf runtime security and anomaly streamer (#113) (#214) * feat(security): falco ebpf runtime security and anomaly streamer (#113) * fix(security): resolve review comments for falco ebpf runtime security (#113) * chore: retrigger validation after resolving all review threads * feat(security): distributed threat intelligence valkey l2 cache and radar batching (#122) (#215) * feat(security): distributed threat intelligence valkey l2 cache and radar batching (#122) * fix(security): resolve review comments for threat intel valkey l2 cache and batching (#122) * chore: retrigger validation after resolving all review threads * perf(github): adjust rate limit no-delay used threshold to 30%
Summary
devops docker signanddevops docker verify) with support for keyless (Fulcio/Rekor OIDC) and keyed signing with OS Keyring integration (feat(security): sigstore cosign container provenance and image signing (devops docker sign|verify) #112).docker_signanddocker_verifyfor supply-chain automation..github/workflows/cleanup-devcontainer.ymlto dynamically prune all merged/closed PR tags while protecting active open PRs and releases..github/workflows/ci.ymlto prevent in-flight CI runs from pushing obsolete devcontainer images after PR merge/closure.