Skip to content

feat(security): sigstore cosign container provenance and image signing (#112) - #213

Merged
dan-petty merged 5 commits into
release/v0.2.18from
feat/112-sigstore-cosign-container-provenance
Sep 16, 2026
Merged

dan-petty merged 5 commits into
release/v0.2.18from
feat/112-sigstore-cosign-container-provenance

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

Summary

  • Implements Sigstore Cosign container image signing and verification (devops docker sign and devops 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).
  • Adds FastMCP tools docker_sign and docker_verify for supply-chain automation.
  • Fixes GHCR container image cleanup process in .github/workflows/cleanup-devcontainer.yml to dynamically prune all merged/closed PR tags while protecting active open PRs and releases.
  • Adds pre-publish PR open verification in .github/workflows/ci.yml to prevent in-flight CI runs from pushing obsolete devcontainer images after PR merge/closure.

@dan-petty
dan-petty marked this pull request as ready for review September 16, 2026 04:48
Copilot AI lite review requested due to automatic review settings September 16, 2026 04:48

Copilot AI 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.

🟡 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-managed devops 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/ci performs 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-managed devops gh/run_gh path. 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_METRICS record. That makes latency and failures invisible to the repository's required command observability, unlike instrumented commands such as valkey and the explicit AGENTS.md telemetry rule.
@app.command("sign")
def docker_sign(

src/devops_cli/commands/docker.py:621

  • verify_image can raise CosignError when a keyring: public key is missing because _resolve_signing_key is shared by signing and verification, but this handler catches only CosignVerificationError. devops docker verify --key keyring:missing will therefore escape as an unhandled exception; import and catch CosignError here 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 TimeoutExpired path: a slow registry produces an uncaught exception rather than the CosignVerificationError that docker_verify is prepared to render. Normalize this timeout before returning from verify_image.
                timeout=self.timeout,

src/devops_cli/docker/cosign.py:46

  • This helper is also used by verify_image, where keyring:<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_verify catches only DependencyError and CosignVerificationError, so devops docker verify ... --key keyring:missing escapes 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_cmd takes the keyed path even if req.keyless remains 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_TOKEN is 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=True before 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=False while key is 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.

Comment thread .github/workflows/ci.yml Resolved
Comment thread src/devops_cli/ai/mcp/server.py Resolved
Comment thread src/devops_cli/docker/cosign.py Resolved
Comment thread src/devops_cli/docker/cosign.py Resolved
Comment thread src/devops_cli/docker/cosign.py Resolved
Comment thread src/devops_cli/docker/cosign.py Resolved
Comment thread src/devops_cli/exceptions/docker.py Resolved
Comment thread src/devops_cli/models/docker.py Resolved
@dan-petty dan-petty mentioned this pull request Sep 16, 2026
11 tasks done
@dan-petty
dan-petty merged commit d7a8cc4 into release/v0.2.18 Sep 16, 2026
4 checks passed
@dan-petty
dan-petty deleted the feat/112-sigstore-cosign-container-provenance branch September 16, 2026 11:57
dan-petty added a commit that referenced this pull request Sep 16, 2026
* 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%
@dan-petty dan-petty mentioned this pull request Sep 16, 2026
7 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants