Skip to content

armgit / Soup

Public Imported from GitHub
0

Fine-tune LLMs from one YAML. Layer streaming trains an 8B model on a 4 GB laptop GPU.

feat(attest): add Sigstore keyless signing (#179) (#1115)

AmixDigital2815990a4d9d
diff --git a/changelog.d/0.75.1/1115.added.md b/changelog.d/0.75.1/1115.added.md
new file mode 100644
index 00000000..e9016891
--- /dev/null
+++ b/changelog.d/0.75.1/1115.added.md
@@ -0,0 +1,5 @@
+- **In-toto/SLSA attestations can now use Sigstore keyless OIDC signing (#179 by @Amix29 in #1115).**
+ `soup attest emit --sign sigstore` writes a modern Sigstore Bundle into the
+ existing `.sig` sidecar, and verification requires an out-of-band certificate
+ identity and OIDC issuer; install `soup-cli[sigstore]` to sign or verify. An
+ explicit Sigstore request can no longer degrade to unsigned.
diff --git a/docs/adapters-and-governance.md b/docs/adapters-and-governance.md
index 2cac4eb4..06744cd8 100644
--- a/docs/adapters-and-governance.md
+++ b/docs/adapters-and-governance.md
@@ -413,21 +413,38 @@ soup attest emit \
```
Stages are a closed allowlist: `extract` / `train` / `eval` / `export` / `publish`.
-Subject SHA must be 64-hex (sha256). The default `--sign unsigned` backend ships now;
-the **`ed25519` backend is live** (`pip install soup-cli[sign]`):
+Subject SHA must be 64-hex (sha256). The default `--sign unsigned` backend
+remains offline-only tamper metadata. The **`ed25519` backend is live** with
+`pip install soup-cli[sign]`; **Sigstore is live** with
+`pip install soup-cli[sigstore]`:
```bash
+# offline key signing
soup attest emit --stage train --subject adapter-v1 --sha aaaa...64hex \
- --sign ed25519 --key signing.pem --output att.json # writes att.json.sig
-soup attest verify att.json --signature att.json.sig # exit 0 valid
+ --sign ed25519 --key signing.pem --output att.json
soup attest verify att.json --signature att.json.sig --public-key trusted.pub
+
+# keyless OIDC / Fulcio / Rekor
+soup attest emit --stage train --subject adapter-v1 --sha aaaa...64hex \
+ --sign sigstore --output att.json # add --interactive-oidc only for browser auth
+soup attest verify att.json --signature att.json.sig \
+ --cert-identity 'https://github.com/acme/repo/.github/workflows/release.yml@refs/heads/main' \
+ --cert-oidc-issuer 'https://token.actions.githubusercontent.com'
```
-`verify` re-canonicalises the statement JSON (so it's platform/newline-independent)
-and checks the ed25519 signature — exit 3 on tamper, key mismatch, or a sidecar with
-no public key. A valid signature proves the signer *asserted* the statement; it does
-not re-verify the subject digest against an artifact. Sigstore keyless signing remains
-infra-blocked (needs an OIDC identity provider + Fulcio/Rekor network).
+Both signing backends use the same `<output>.sig` JSON sidecar. For Sigstore it
+contains the complete modern Bundle (certificate, signature, and transparency
+proof). `verify` re-canonicalises the statement JSON and requires both the
+Sigstore certificate identity and OIDC issuer out of band; either value without
+the other is refused. Sigstore emission requires `--output` so the public Rekor
+entry can never outlive a discarded local bundle; browser OIDC is explicit opt-in.
+Verification exits 3 on tamper or policy mismatch, and exits 1 when Sigstore
+verification itself is unavailable (for example TUF/network failure) so an
+operational outage is not reported as tampering. Usage/input errors exit 2.
+An explicit Sigstore signing request fails closed if OIDC/Fulcio/Rekor is
+unavailable; it is never silently downgraded to unsigned. A valid signature proves the signer
+*asserted* the statement; it does not re-verify the subject digest against an
+artifact.
## EU AI Act Annex XI/XII Auto-Doc (`soup train --annex-xi`)
diff --git a/docs/commands.md b/docs/commands.md
index ef95cd2a..4f02163a 100644
--- a/docs/commands.md
+++ b/docs/commands.md
@@ -270,8 +270,8 @@ soup adapters verify <adapter> [--strict] [--public-key <pem>] [--cert-identity
soup adapters check-safetensors <adapter> [--strict] Refuse pickle / PyTorch-classic weights
soup adapters merge ... [--license <id>] [--license-override <reason>] [--allow-unscanned] License + backdoor-scan gates (auto-detect license; scan FAIL refused)
soup adapters arithmetic "coder + 0.5*math - toxic" --adapter coder=<p> --adapter math=<p> --adapter toxic=<p> -o <out> [--allow-unscanned --allow-cross-base] Task-vector algebra over LoRA adapters (add/scale/negate; same-rank; scan + same-base gated) (v0.71.34)
-soup attest emit ... [--sign ed25519 --key <pem>] [-o att.json] in-toto/SLSA-3 attestation (+ .sig sidecar)
-soup attest verify <statement> --signature <sig> [--public-key <pem>] Verify ed25519 attestation signature
+soup attest emit ... [--sign unsigned|ed25519|sigstore] [--key <pem>] [--interactive-oidc] [-o att.json] in-toto/SLSA-3 attestation; Sigstore requires -o
+soup attest verify <statement> --signature <sig> [--public-key <pem>] [--cert-identity <san> --cert-oidc-issuer <url>] Verify ed25519/Sigstore attestation signature
soup airgap-bundle --model <m> --output <out.tar> [--repro-receipt <r.json>] Signed tarball for data-diode transfer (embeds repro-receipt)
soup train --config soup.yaml --annex-xi <out.md|out.pdf> EU AI Act Annex XI/XII doc (markdown or PDF; top_domains auto-filled)
soup train --config soup.yaml --track-energy [--energy-country USA] codecarbon offline kWh/CO2 → annex-xi (pip install soup-cli[carbon])
diff --git a/src/soup_cli/commands/attest.py b/src/soup_cli/commands/attest.py
index 28ebafb8..373eb3af 100644
--- a/src/soup_cli/commands/attest.py
+++ b/src/soup_cli/commands/attest.py
@@ -16,12 +16,15 @@ from soup_cli.utils.attest import (
render_attestation,
sign_attestation,
verify_attestation,
+ verify_sigstore_attestation,
write_attestation,
)
+from soup_cli.utils.terminal import for_terminal
console = Console()
_SIGNATURE_SUFFIX = ".sig"
+_MAX_SIGNATURE_SIDECAR_BYTES = 16 * 1024 * 1024
_EXIT_ATTACH_FAILED = 1
_EXIT_USAGE = 2
@@ -49,8 +52,8 @@ def emit_cmd(
),
sign_backend: str = typer.Option(
"unsigned", "--sign",
- help="Signature backend: unsigned (default) | ed25519. Sigstore is "
- "infra-blocked (needs OIDC + Fulcio/Rekor network).",
+ help="Signature backend: unsigned (default) | ed25519 | sigstore "
+ "(keyless OIDC + Fulcio/Rekor).",
),
key: Optional[str] = typer.Option(
None, "--key",
@@ -63,13 +66,19 @@ def emit_cmd(
None, "--attach-to-registry",
help="Attach the emitted attestation statement to a registry entry id (needs --output).",
),
+ interactive_oidc: bool = typer.Option(
+ False, "--interactive-oidc",
+ help="Allow Sigstore browser OIDC when no ambient credential exists. "
+ "Off by default so headless runners fail instead of hanging.",
+ ),
) -> None:
"""Emit a per-stage in-toto/SLSA-3 attestation.
- With ``--sign ed25519 --key <priv.pem>`` (v0.71.2 #179) the rendered
- Statement is signed with a real detached ed25519 signature; when
- ``--output`` is set a ``<output>.sig`` JSON sidecar (backend / signature /
- public_key) is written next to it. Verify with ``soup attest verify``.
+ With ``--sign ed25519 --key <priv.pem>`` the rendered Statement is
+ signed with a detached ed25519 signature. ``--sign sigstore`` uses
+ keyless OIDC + Fulcio/Rekor. With ``--output``, both backends write the
+ portable signature material to ``<output>.sig``; verify it with
+ ``soup attest verify``.
"""
try:
st = AttestationStatement(
@@ -85,24 +94,57 @@ def emit_cmd(
console.print(f"[red]Invalid attestation: {escape(str(exc))}[/]")
raise typer.Exit(2)
+ # Validate every local argument/path before a Sigstore request can create
+ # a permanent Rekor entry carrying the signer's identity.
+ normalized_backend = sign_backend.lower() if isinstance(sign_backend, str) else ""
+ if attach_to_registry is not None and output is None:
+ console.print(
+ "[red]--attach-to-registry needs --output "
+ "(nothing written to attach).[/]"
+ )
+ raise typer.Exit(_EXIT_USAGE)
+ if normalized_backend == "sigstore" and output is None:
+ console.print(
+ "[red]--sign sigstore requires --output so the Sigstore bundle is "
+ "persisted and can be verified later.[/]"
+ )
+ raise typer.Exit(_EXIT_USAGE)
+ if output is not None:
+ from soup_cli.utils.paths import enforce_under_cwd_and_no_symlink
+
+ try:
+ enforce_under_cwd_and_no_symlink(output, "--output")
+ if os.path.isdir(output):
+ raise ValueError("--output must name a file, not a directory")
+ if normalized_backend in {"ed25519", "sigstore"}:
+ sidecar_path = output + _SIGNATURE_SUFFIX
+ enforce_under_cwd_and_no_symlink(sidecar_path, "signature sidecar")
+ if os.path.isdir(sidecar_path):
+ raise ValueError(
+ "signature sidecar path must name a file, not a directory"
+ )
+ except (TypeError, ValueError) as exc:
+ console.print(f"[red]Invalid output: {for_terminal(exc)}[/]")
+ raise typer.Exit(_EXIT_USAGE) from exc
+
text = render_attestation(st)
try:
- sig = sign_attestation(text.encode("utf-8"), backend=sign_backend, key_path=key)
- except NotImplementedError as exc:
- console.print(f"[yellow]Signing infra-blocked: {escape(str(exc))}[/]")
- sig = {"signature": "", "backend": "unsigned"}
+ sig = sign_attestation(
+ text.encode("utf-8"),
+ backend=sign_backend,
+ key_path=key,
+ sigstore_interactive=interactive_oidc,
+ )
except (TypeError, ValueError) as exc:
- console.print(f"[red]Sign failed: {escape(str(exc))}[/]")
+ console.print(f"[red]Sign failed: {for_terminal(exc)}[/]")
raise typer.Exit(2)
+ except RuntimeError as exc:
+ # Explicit signing requests must never degrade to unsigned.
+ console.print(f"[red]Sign failed: {for_terminal(exc)}[/]")
+ raise typer.Exit(1)
if output is None:
- if attach_to_registry is not None:
- console.print(
- "[red]--attach-to-registry needs --output "
- "(nothing written to attach).[/]"
- )
- raise typer.Exit(_EXIT_USAGE)
console.print(text)
console.print(f"[dim]signature backend: {escape(sig['backend'])}[/]")
if sig.get("signature"):
@@ -112,10 +154,12 @@ def emit_cmd(
try:
written = write_attestation(st, output)
written_paths = [written]
- if sig.get("backend") == "ed25519" and sig.get("signature"):
+ if sig.get("backend") in {"ed25519", "sigstore"} and (
+ sig.get("signature") or sig.get("sigstore_bundle")
+ ):
written_paths.append(_write_sig_sidecar(output, sig))
- except (TypeError, ValueError) as exc:
- console.print(f"[red]Write failed: {escape(str(exc))}[/]")
+ except (TypeError, ValueError, OSError) as exc:
+ console.print(f"[red]Write failed: {for_terminal(exc)}[/]")
raise typer.Exit(2)
console.print(
f"[green]Wrote attestation[/] -> {escape(written)} "
@@ -155,12 +199,18 @@ def _write_sig_sidecar(output: str, sig: dict) -> str:
"""Atomic write of the ``<output>.sig`` JSON sidecar (cwd-contained)."""
from soup_cli.utils.paths import atomic_write_text
+ payload = {
+ "backend": sig.get("backend", ""),
+ "signature": sig.get("signature", ""),
+ "public_key": sig.get("public_key", ""),
+ }
+ if sig.get("backend") == "sigstore":
+ bundle = sig.get("sigstore_bundle", "")
+ if not isinstance(bundle, str) or not bundle.strip():
+ raise ValueError("Sigstore sidecar requires a non-empty bundle")
+ payload["sigstore_bundle"] = bundle
body = json.dumps(
- {
- "backend": sig.get("backend", ""),
- "signature": sig.get("signature", ""),
- "public_key": sig.get("public_key", ""),
- },
+ payload,
indent=2,
sort_keys=True,
)
@@ -177,24 +227,38 @@ def verify_cmd(
statement: str = typer.Argument(..., help="Path to the in-toto Statement JSON."),
signature: str = typer.Option(
..., "--signature", "-s",
- help="Path to the .sig JSON sidecar written by `attest emit --sign ed25519`.",
+ help="Path to the .sig JSON sidecar written by `attest emit --sign`.",
),
public_key: Optional[str] = typer.Option(
None, "--public-key",
help="Trusted ed25519 public-key PEM. When set, the embedded key must "
"match it (genuine authentication).",
),
+ cert_identity: Optional[str] = typer.Option(
+ None, "--cert-identity",
+ help="Trusted Sigstore certificate identity (SAN). Requires "
+ "--cert-oidc-issuer and is required for sigstore-signed attestations.",
+ ),
+ cert_oidc_issuer: Optional[str] = typer.Option(
+ None, "--cert-oidc-issuer",
+ help="Trusted OIDC issuer. Required together with --cert-identity.",
+ ),
) -> None:
- """Verify an ed25519-signed attestation (v0.71.2 #179).
+ """Verify an ed25519 or Sigstore-signed attestation.
- Exit codes: 0 = signature valid; 3 = invalid / mismatch.
+ Exit codes: 0 = signature valid; 1 = verifier unavailable; 2 = usage/input
+ error; 3 = invalid signature / policy mismatch.
"""
from soup_cli.utils.paths import enforce_under_cwd_and_no_symlink
try:
enforce_under_cwd_and_no_symlink(statement, "statement")
enforce_under_cwd_and_no_symlink(signature, "signature")
- except (ValueError, FileNotFoundError) as exc:
+ if os.lstat(signature).st_size > _MAX_SIGNATURE_SIDECAR_BYTES:
+ raise ValueError(
+ f"signature exceeds {_MAX_SIGNATURE_SIDECAR_BYTES} bytes"
+ )
+ except (OSError, ValueError, FileNotFoundError) as exc:
console.print(f"[red]{escape(str(exc))}[/]")
raise typer.Exit(2)
@@ -224,11 +288,63 @@ def verify_cmd(
backend = str(sig_doc.get("backend", ""))
sig_hex = str(sig_doc.get("signature", ""))
pub = str(sig_doc.get("public_key", ""))
+ sigstore_bundle = str(sig_doc.get("sigstore_bundle", ""))
+
+ if cert_identity is not None and not cert_oidc_issuer:
+ console.print("[red]--cert-identity requires --cert-oidc-issuer[/]")
+ raise typer.Exit(2)
+ if cert_oidc_issuer is not None and not cert_identity:
+ console.print("[red]--cert-oidc-issuer requires --cert-identity[/]")
+ raise typer.Exit(2)
+
+ if backend == "sigstore":
+ if public_key is not None:
+ console.print("[red]--public-key applies only to ed25519 signatures[/]")
+ raise typer.Exit(2)
+ if not sigstore_bundle:
+ console.print("[red]Sigstore sidecar has no bundle — cannot verify[/]")
+ raise typer.Exit(3)
+ if not cert_identity or not cert_oidc_issuer:
+ console.print(
+ "[red]Sigstore verification requires trusted --cert-identity and "
+ "--cert-oidc-issuer values supplied out of band[/]"
+ )
+ raise typer.Exit(3)
+ try:
+ verify_sigstore_attestation(
+ payload,
+ sigstore_bundle,
+ identity=cert_identity,
+ issuer=cert_oidc_issuer,
+ )
+ except RuntimeError as exc:
+ console.print(
+ f"[red]Sigstore verification unavailable: {for_terminal(exc)}[/]"
+ )
+ raise typer.Exit(1)
+ except ValueError as exc:
+ console.print(
+ f"[red]Sigstore attestation INVALID: {for_terminal(exc)}[/]"
+ )
+ raise typer.Exit(3)
+ console.print(
+ f"[green]Attestation Sigstore signature valid[/] "
+ f"[dim]({escape(os.path.basename(statement))})[/]"
+ )
+ console.print(
+ "[dim]Note: the subject digest is asserted by the signer, not "
+ "re-verified against an artifact.[/]"
+ )
+ return
+
+ if cert_identity is not None:
+ console.print("[red]--cert-identity applies only to Sigstore signatures[/]")
+ raise typer.Exit(2)
if backend != "ed25519" or not sig_hex:
console.print(
f"[yellow]Signature backend {escape(backend or 'unsigned')!r} "
- "is not ed25519 — nothing to cryptographically verify.[/]"
+ "is not cryptographically verifiable.[/]"
)
raise typer.Exit(3)
diff --git a/src/soup_cli/utils/attest.py b/src/soup_cli/utils/attest.py
index 6ef256ad..316f5f8d 100644
--- a/src/soup_cli/utils/attest.py
+++ b/src/soup_cli/utils/attest.py
@@ -1,9 +1,9 @@
"""in-toto + SLSA-3 attestation builder (v0.59.0 Part B).
-Pure-stdlib. Sigstore + ed25519 live signing is **deferred to v0.59.1**
-(mirrors v0.27.0 MII / v0.37.0 multipack / v0.50.0 GRPO Plus stub-then-live
-pattern). The schema + atomic write surface ships now so callers can lock
-the wire format.
+The statement builder itself is pure stdlib. Optional signing is layered on top:
+ed25519 uses the shared `cryptography` helper, while Sigstore uses the lazy
+sigstore-python 4.x wrapper for keyless OIDC/Fulcio/Rekor bundles. The statement
+wire format remains independent of either signing backend.
Schema shapes:
- ``_type``: ``https://in-toto.io/Statement/v1``
@@ -32,7 +32,7 @@ _MAX_NAME = 256
class SignatureBackend(str, enum.Enum):
- """Signing backend selector. ``sigstore`` + ``ed25519`` deferred to v0.59.1."""
+ """Signing backend selector for unsigned, ed25519, and Sigstore."""
UNSIGNED = "unsigned"
ED25519 = "ed25519"
@@ -148,28 +148,34 @@ def sign_attestation(
*,
backend: SignatureBackend | str = SignatureBackend.UNSIGNED,
key_path: str | None = None,
+ sigstore_interactive: bool = False,
) -> dict:
"""Sign a payload (in-toto JSON bytes) with the chosen backend.
``ed25519`` (v0.71.2 #179) produces a real detached signature over
``payload`` using a private key resolved from ``key_path`` or the
- ``SOUP_SIGNING_KEY`` env var. ``sigstore`` keyless signing stays
- infra-blocked (needs an OIDC identity provider + Fulcio/Rekor network) and
- raises ``NotImplementedError``.
+ ``SOUP_SIGNING_KEY`` env var. ``sigstore`` produces a keyless
+ Fulcio/Rekor bundle through the shared Sigstore 4.x wrapper.
Args:
payload: in-toto Statement bytes (typically ``render_attestation(...).encode()``).
- backend: ``"unsigned"`` / ``"ed25519"`` are live; ``"sigstore"`` raises.
+ backend: ``"unsigned"``, ``"ed25519"``, or ``"sigstore"``.
key_path: ed25519 private-key PEM path (``ed25519`` backend only).
+ sigstore_interactive: explicitly permit browser OIDC for Sigstore.
+ False by default so headless runners fail instead of hanging.
Returns:
- ``{"signature": "", "backend": "unsigned"}`` for the unsigned path
(the empty signature lets verifiers refuse in strict mode).
- ``{"signature": <hex>, "backend": "ed25519", "public_key": <pem>}``
for the ed25519 path.
+ - ``{"signature": "", "backend": "sigstore", "sigstore_bundle": <json>}``
+ for the keyless Sigstore path.
"""
if not isinstance(payload, (bytes, bytearray)):
raise TypeError("payload must be bytes")
+ if not isinstance(sigstore_interactive, bool):
+ raise TypeError("sigstore_interactive must be bool")
if isinstance(backend, str):
try:
backend = SignatureBackend(backend.lower())
@@ -178,6 +184,8 @@ def sign_attestation(
f"unknown signature backend: {backend!r} "
f"(use one of {[b.value for b in SignatureBackend]})"
) from exc
+ if sigstore_interactive and backend != SignatureBackend.SIGSTORE:
+ raise ValueError("--interactive-oidc requires --sign sigstore")
if backend == SignatureBackend.UNSIGNED:
return {"signature": "", "backend": "unsigned"}
if backend == SignatureBackend.ED25519:
@@ -193,10 +201,44 @@ def sign_attestation(
"backend": "ed25519",
"public_key": public_key_pem(private_key),
}
- raise NotImplementedError(
- f"signing backend {backend.value!r} is infra-blocked "
- "(needs OIDC + Fulcio/Rekor network)"
+ if backend == SignatureBackend.SIGSTORE:
+ if key_path is not None:
+ raise ValueError("key_path applies only to the ed25519 backend")
+ from soup_cli.utils.sigstore_signing import sign_payload_sigstore
+
+ bundle = sign_payload_sigstore(
+ bytes(payload),
+ interactive=sigstore_interactive,
+ )
+ if not isinstance(bundle, str) or not bundle.strip():
+ raise RuntimeError("Sigstore signing returned an empty bundle")
+ return {
+ "signature": "",
+ "backend": "sigstore",
+ "sigstore_bundle": bundle,
+ }
+ raise AssertionError(f"unhandled signature backend: {backend!r}")
+
+
+def verify_sigstore_attestation(
+ payload: bytes,
+ bundle_json: str,
+ *,
+ identity: str,
+ issuer: str,
+) -> bool:
+ """Verify a Sigstore attestation bundle against identity + issuer policy."""
+ if not isinstance(payload, (bytes, bytearray)):
+ raise TypeError("payload must be bytes")
+ from soup_cli.utils.sigstore_signing import verify_payload_sigstore
+
+ verify_payload_sigstore(
+ bytes(payload),
+ bundle_json,
+ identity=identity,
+ issuer=issuer,
)
+ return True
def verify_attestation(
diff --git a/src/soup_cli/utils/sigstore_signing.py b/src/soup_cli/utils/sigstore_signing.py
index e27ea36b..9a264a78 100644
--- a/src/soup_cli/utils/sigstore_signing.py
+++ b/src/soup_cli/utils/sigstore_signing.py
@@ -79,12 +79,20 @@ def verify_payload_sigstore(
from sigstore.verify import Verifier
from sigstore.verify.policy import Identity
except ImportError as exc:
- raise _missing_sigstore(exc) from exc
+ raise RuntimeError(str(_missing_sigstore(exc))) from exc
try:
bundle = Bundle.from_json(bundle_json)
policy = Identity(identity=identity, issuer=issuer)
+ except Exception as exc:
+ raise ValueError(f"Sigstore verification failed: {exc}") from exc
+
+ try:
verifier = Verifier.production()
+ except Exception as exc:
+ raise RuntimeError(f"Sigstore verifier unavailable: {exc}") from exc
+
+ try:
verifier.verify_artifact(payload, bundle, policy)
except Exception as exc:
raise ValueError(f"Sigstore verification failed: {exc}") from exc
diff --git a/tests/test_issue179_sigstore_attest.py b/tests/test_issue179_sigstore_attest.py
new file mode 100644
index 00000000..e2804983
--- /dev/null
+++ b/tests/test_issue179_sigstore_attest.py
@@ -0,0 +1,765 @@
+"""#179: Sigstore keyless signing for in-toto/SLSA attestations."""
+
+from __future__ import annotations
+
+import json
+import re
+from pathlib import Path
+
+import pytest
+from typer.testing import CliRunner
+
+_ANSI_RE = re.compile(r"\x1b\[[0-9;]*m")
+
+
+def _strip_ansi(text: str) -> str:
+ return _ANSI_RE.sub("", text)
+
+
+def _patch_signer(monkeypatch, bundle='{"bundle":"ok"}'):
+ from soup_cli.utils import sigstore_signing
+
+ seen = {}
+
+ def sign(payload, *, interactive=False):
+ seen["payload"] = payload
+ seen["interactive"] = interactive
+ return bundle
+
+ monkeypatch.setattr(sigstore_signing, "sign_payload_sigstore", sign)
+ return seen
+
+
+def _emit_args(output):
+ return [
+ "emit",
+ "--stage",
+ "train",
+ "--subject",
+ "adapter",
+ "--sha",
+ "a" * 64,
+ "--sign",
+ "sigstore",
+ "--output",
+ str(output),
+ ]
+
+
+def _write_verify_pair(tmp_path):
+ statement = {
+ "_type": "https://in-toto.io/Statement/v1",
+ "subject": [{"name": "x", "digest": {"sha256": "a" * 64}}],
+ "predicateType": "https://slsa.dev/provenance/v1",
+ "predicate": {},
+ }
+ statement_path = tmp_path / "att.json"
+ statement_path.write_text(
+ json.dumps(statement, indent=2, sort_keys=True),
+ encoding="utf-8",
+ )
+ sidecar_path = tmp_path / "att.json.sig"
+ sidecar_path.write_text(
+ json.dumps(
+ {
+ "backend": "sigstore",
+ "signature": "",
+ "public_key": "",
+ "sigstore_bundle": '{"bundle":"ok"}',
+ }
+ ),
+ encoding="utf-8",
+ )
+ return statement_path, sidecar_path
+
+
+class TestAttestationSigstoreBackend:
+ def test_sign_returns_portable_bundle(self, monkeypatch):
+ from soup_cli.utils.attest import sign_attestation
+
+ seen = _patch_signer(monkeypatch)
+ result = sign_attestation(b'{"hello":"world"}', backend="sigstore")
+
+ assert result == {
+ "signature": "",
+ "backend": "sigstore",
+ "sigstore_bundle": '{"bundle":"ok"}',
+ }
+ assert seen["payload"] == b'{"hello":"world"}'
+
+
+ def test_verify_wrapper_threads_identity_and_issuer(self, monkeypatch):
+ from soup_cli.utils import sigstore_signing
+ from soup_cli.utils.attest import verify_sigstore_attestation
+
+ seen = {}
+
+ def verify(payload, bundle, *, identity, issuer):
+ seen.update(
+ payload=payload,
+ bundle=bundle,
+ identity=identity,
+ issuer=issuer,
+ )
+
+ monkeypatch.setattr(sigstore_signing, "verify_payload_sigstore", verify)
+ assert verify_sigstore_attestation(
+ b"statement",
+ '{"bundle":"ok"}',
+ identity="[email protected]",
+ issuer="https://issuer.example",
+ )
+ assert seen == {
+ "payload": b"statement",
+ "bundle": '{"bundle":"ok"}',
+ "identity": "[email protected]",
+ "issuer": "https://issuer.example",
+ }
+
+
+class TestAttestSigstoreCli:
+ def test_emit_writes_bundle_sidecar(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ _patch_signer(monkeypatch)
+ output = tmp_path / "attestation.json"
+
+ result = CliRunner().invoke(app, _emit_args(output))
+ assert result.exit_code == 0, result.output
+ assert output.exists()
+ sidecar = json.loads(
+ (tmp_path / "attestation.json.sig").read_text(encoding="utf-8")
+ )
+ assert sidecar["backend"] == "sigstore"
+ assert sidecar["signature"] == ""
+ assert sidecar["public_key"] == ""
+ assert sidecar["sigstore_bundle"] == '{"bundle":"ok"}'
+
+ def test_sigstore_failure_never_downgrades_to_unsigned(
+ self, tmp_path, monkeypatch
+ ):
+ from soup_cli.commands.attest import app
+ from soup_cli.utils import sigstore_signing
+
+ monkeypatch.chdir(tmp_path)
+
+ monkeypatch.setattr(
+ sigstore_signing,
+ "sign_payload_sigstore",
+ lambda payload, *, interactive=False: (_ for _ in ()).throw(
+ RuntimeError("OIDC unavailable")
+ ),
+ )
+ output = tmp_path / "attestation.json"
+ result = CliRunner().invoke(app, _emit_args(output))
+
+ assert result.exit_code == 1
+ assert "OIDC unavailable" in result.output
+ assert not output.exists()
+ assert not (tmp_path / "attestation.json.sig").exists()
+
+ def test_verify_requires_out_of_band_identity(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ result = CliRunner().invoke(
+ app,
+ ["verify", str(statement), "--signature", str(sidecar)],
+ )
+ assert result.exit_code == 3
+ assert "--cert-identity" in result.output
+ assert "--cert-oidc-issuer" in result.output
+
+ def test_identity_without_issuer_is_usage_error(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ result = CliRunner().invoke(
+ app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--cert-identity",
+ ],
+ )
+ assert result.exit_code == 2
+ assert "--cert-identity requires --cert-oidc-issuer" in result.output
+
+ def test_issuer_without_identity_is_usage_error(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ result = CliRunner().invoke(
+ app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+ assert result.exit_code == 2
+ assert "--cert-oidc-issuer requires --cert-identity" in result.output
+
+ def test_verify_passes_identity_policy(self, tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ seen = {}
+
+ def verify(payload, bundle, *, identity, issuer=None):
+ seen.update(
+ payload=payload,
+ bundle=bundle,
+ identity=identity,
+ issuer=issuer,
+ )
+ return True
+
+ monkeypatch.setattr(attest_cmd, "verify_sigstore_attestation", verify)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+ assert result.exit_code == 0, result.output
+ assert seen["identity"] == "[email protected]"
+ assert seen["issuer"] == "https://issuer.example"
+ assert seen["bundle"] == '{"bundle":"ok"}'
+ assert b"https://in-toto.io/Statement/v1" in seen["payload"]
+
+ def test_identity_mismatch_is_invalid(self, tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+
+ def reject(*args, **kwargs):
+ raise ValueError("certificate identity mismatch")
+
+ monkeypatch.setattr(attest_cmd, "verify_sigstore_attestation", reject)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+ assert result.exit_code == 3
+ assert "identity mismatch" in result.output
+
+
+ def test_oversized_signature_sidecar_is_rejected_before_json_load(
+ self, tmp_path, monkeypatch
+ ):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ monkeypatch.setattr(attest_cmd, "_MAX_SIGNATURE_SIDECAR_BYTES", 8)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ ["verify", str(statement), "--signature", str(sidecar)],
+ )
+ assert result.exit_code == 2
+ assert "exceeds 8 bytes" in _strip_ansi(result.output)
+
+
+class TestAttestSigstoreReviewFollowups:
+ def test_empty_sigstore_bundle_is_an_error(self, monkeypatch):
+ from soup_cli.utils import sigstore_signing
+ from soup_cli.utils.attest import sign_attestation
+
+ monkeypatch.setattr(
+ sigstore_signing,
+ "sign_payload_sigstore",
+ lambda payload, *, interactive=False: "",
+ )
+ with pytest.raises(RuntimeError, match="empty bundle"):
+ sign_attestation(b"statement", backend="sigstore")
+
+ def test_emit_threads_interactive_oidc(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ seen = _patch_signer(monkeypatch)
+ output = tmp_path / "att.json"
+ args = _emit_args(output) + ["--interactive-oidc"]
+ result = CliRunner().invoke(app, args)
+
+ assert result.exit_code == 0, result.output
+ assert seen["interactive"] is True
+
+ @pytest.mark.parametrize(
+ ("sign_value", "extra_args"),
+ [
+ ("sigstore", []),
+ ("SIGSTORE", []),
+ ("Sigstore", []),
+ ("sigstore", ["--attach-to-registry", "entry-1"]),
+ ("sigstore", ["--output", "../outside.json"]),
+ ],
+ )
+ def test_invalid_local_args_refuse_before_sigstore_signing(
+ self, tmp_path, monkeypatch, sign_value, extra_args
+ ):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ called = {"sign": False}
+
+ def should_not_sign(*args, **kwargs):
+ called["sign"] = True
+ raise AssertionError("Sigstore signing ran before local validation")
+
+ monkeypatch.setattr(attest_cmd, "sign_attestation", should_not_sign)
+ args = [
+ "emit",
+ "--stage",
+ "train",
+ "--subject",
+ "adapter",
+ "--sha",
+ "a" * 64,
+ "--sign",
+ sign_value,
+ *extra_args,
+ ]
+ result = CliRunner().invoke(attest_cmd.app, args)
+
+ assert result.exit_code == 2, result.output
+ assert called["sign"] is False
+
+ @pytest.mark.requires_symlink
+ @pytest.mark.parametrize("which", ["output", "sidecar"])
+ def test_symlink_output_paths_refuse_before_sigstore_signing(
+ self, tmp_path, monkeypatch, which
+ ):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ called = {"sign": False}
+
+ def should_not_sign(*args, **kwargs):
+ called["sign"] = True
+ raise AssertionError("Sigstore signing ran before symlink validation")
+
+ monkeypatch.setattr(attest_cmd, "sign_attestation", should_not_sign)
+ output = tmp_path / "att.json"
+ target = tmp_path / "target"
+ target.write_text("target", encoding="utf-8")
+ link = output if which == "output" else tmp_path / "att.json.sig"
+ link.symlink_to(target)
+
+ result = CliRunner().invoke(
+ attest_cmd.app, _emit_args(output)
+ )
+ assert result.exit_code == 2, result.output
+ assert called["sign"] is False
+
+ @pytest.mark.parametrize("which", ["output", "sidecar"])
+ def test_directory_output_paths_refuse_before_sigstore_signing(
+ self, tmp_path, monkeypatch, which
+ ):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ called = {"sign": False}
+
+ def should_not_sign(*args, **kwargs):
+ called["sign"] = True
+ raise AssertionError("Sigstore signing ran before directory validation")
+
+ monkeypatch.setattr(attest_cmd, "sign_attestation", should_not_sign)
+ output = tmp_path / "att.json"
+ directory = output if which == "output" else tmp_path / "att.json.sig"
+ directory.mkdir()
+
+ result = CliRunner().invoke(
+ attest_cmd.app, _emit_args(output)
+ )
+ assert result.exit_code == 2, result.output
+ assert called["sign"] is False
+
+ def test_empty_bundle_cli_fails_without_writing_files(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+ from soup_cli.utils import sigstore_signing
+
+ monkeypatch.chdir(tmp_path)
+ monkeypatch.setattr(
+ sigstore_signing,
+ "sign_payload_sigstore",
+ lambda payload, *, interactive=False: "",
+ )
+ output = tmp_path / "att.json"
+ result = CliRunner().invoke(app, _emit_args(output))
+
+ assert result.exit_code == 1, result.output
+ assert "empty bundle" in result.output
+ assert not output.exists()
+ assert not (tmp_path / "att.json.sig").exists()
+
+ def test_sigstore_with_key_refuses_before_signing(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ seen = _patch_signer(monkeypatch)
+ output = tmp_path / "att.json"
+ result = CliRunner().invoke(
+ app,
+ _emit_args(output) + ["--key", "signing.pem"],
+ )
+
+ assert result.exit_code == 2, result.output
+ assert "payload" not in seen
+ assert not output.exists()
+
+ def test_public_key_is_refused_on_a_sigstore_record(self, tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ (tmp_path / "trusted.pub").write_text("unused", encoding="utf-8")
+ called = {"verify": False}
+
+ def verify(*args, **kwargs):
+ called["verify"] = True
+ return True
+
+ monkeypatch.setattr(attest_cmd, "verify_sigstore_attestation", verify)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--public-key",
+ "trusted.pub",
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+
+ assert result.exit_code == 2, result.output
+ assert called["verify"] is False
+
+ def test_verify_hands_the_verifier_the_bytes_emit_signed(self, tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ signed = _patch_signer(monkeypatch)
+ output = tmp_path / "att.json"
+ emitted = CliRunner().invoke(attest_cmd.app, _emit_args(output))
+ assert emitted.exit_code == 0, emitted.output
+
+ document = json.loads(output.read_text(encoding="utf-8"))
+ output.write_bytes(
+ (json.dumps(document, separators=(",", ":")) + "\r\n").encode("utf-8")
+ )
+ verified = {}
+
+ def verify(payload, bundle, *, identity, issuer):
+ verified["payload"] = payload
+ return True
+
+ monkeypatch.setattr(attest_cmd, "verify_sigstore_attestation", verify)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(output),
+ "--signature",
+ f"{output}.sig",
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+
+ assert result.exit_code == 0, result.output
+ assert verified["payload"] == signed["payload"]
+
+ def test_ed25519_sidecar_omits_empty_sigstore_field(self, tmp_path, monkeypatch):
+ from soup_cli.commands.attest import app
+ from soup_cli.utils.signing import generate_ed25519_private_pem
+
+ monkeypatch.chdir(tmp_path)
+ key = tmp_path / "signing.pem"
+ key.write_text(generate_ed25519_private_pem(), encoding="utf-8")
+ output = tmp_path / "att.json"
+
+ result = CliRunner().invoke(
+ app,
+ [
+ "emit",
+ "--stage",
+ "train",
+ "--subject",
+ "adapter",
+ "--sha",
+ "a" * 64,
+ "--sign",
+ "ed25519",
+ "--key",
+ str(key),
+ "--output",
+ str(output),
+ ],
+ )
+ assert result.exit_code == 0, result.output
+ sidecar = json.loads(
+ (tmp_path / "att.json.sig").read_text(encoding="utf-8")
+ )
+ assert sidecar["backend"] == "ed25519"
+ assert "sigstore_bundle" not in sidecar
+
+ @pytest.mark.parametrize(
+ "backend", ["ed25519", "SIGSTORE", "sigstore ", "", "unsigned"]
+ )
+ def test_cert_identity_rejects_every_non_sigstore_backend_with_valid_ed25519(
+ self, tmp_path, monkeypatch, backend
+ ):
+ from soup_cli.commands.attest import app
+ from soup_cli.utils.signing import generate_ed25519_private_pem
+
+ monkeypatch.chdir(tmp_path)
+ key = tmp_path / "signing.pem"
+ key.write_text(generate_ed25519_private_pem(), encoding="utf-8")
+ output = tmp_path / "att.json"
+ emit = CliRunner().invoke(
+ app,
+ [
+ "emit",
+ "--stage",
+ "train",
+ "--subject",
+ "adapter",
+ "--sha",
+ "a" * 64,
+ "--sign",
+ "ed25519",
+ "--key",
+ str(key),
+ "--output",
+ str(output),
+ ],
+ )
+ assert emit.exit_code == 0, emit.output
+
+ sidecar_path = tmp_path / "att.json.sig"
+ sidecar = json.loads(sidecar_path.read_text(encoding="utf-8"))
+ sidecar["backend"] = backend
+ sidecar_path.write_text(json.dumps(sidecar), encoding="utf-8")
+
+ result = CliRunner().invoke(
+ app,
+ [
+ "verify",
+ str(output),
+ "--signature",
+ str(sidecar_path),
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+ assert result.exit_code == 2, result.output
+ assert "applies only to Sigstore signatures" in result.output
+
+ def test_bundle_error_strips_terminal_control_bytes(self, tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ attack = "\x1b]0;SPOOFED-TITLE\x07\x1b[2J\x1b[H\x1b[32mValid: True\x1b[0m"
+
+ def reject(*args, **kwargs):
+ raise ValueError(attack)
+
+ monkeypatch.setattr(attest_cmd, "verify_sigstore_attestation", reject)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+
+ assert result.exit_code == 3, result.output
+ out = _strip_ansi(result.output)
+ assert "\x1b" not in out
+ assert "\x07" not in out
+ assert "SPOOFED-TITLE" in out
+
+ def test_missing_sigstore_extra_uses_unavailable_exit(self, tmp_path, monkeypatch):
+ import builtins
+
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ real_import = builtins.__import__
+
+ def force_missing_sigstore(name, *args, **kwargs):
+ if name == "sigstore" or name.startswith("sigstore."):
+ raise ImportError("forced missing sigstore")
+ return real_import(name, *args, **kwargs)
+
+ monkeypatch.setattr(builtins, "__import__", force_missing_sigstore)
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify",
+ str(statement),
+ "--signature",
+ str(sidecar),
+ "--cert-identity",
+ "--cert-oidc-issuer",
+ "https://issuer.example",
+ ],
+ )
+
+ assert result.exit_code == 1, result.output
+ out = _strip_ansi(result.output)
+ assert "Sigstore verification unavailable" in out
+ assert "soup-cli[sigstore]" in out
+
+ def test_interactive_oidc_refuses_non_sigstore_backend(
+ self, tmp_path, monkeypatch
+ ):
+ from soup_cli.commands.attest import app
+
+ monkeypatch.chdir(tmp_path)
+ result = CliRunner().invoke(
+ app,
+ [
+ "emit",
+ "--stage",
+ "train",
+ "--subject",
+ "adapter",
+ "--sha",
+ "a" * 64,
+ "--sign",
+ "unsigned",
+ "--interactive-oidc",
+ ],
+ )
+ assert result.exit_code == 2, result.output
+ assert "--interactive-oidc requires --sign sigstore" in result.output
+
+
+def test_verifier_production_failure_is_unavailable_not_invalid(tmp_path, monkeypatch):
+ import sys
+ from types import ModuleType
+
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ statement, sidecar = _write_verify_pair(tmp_path)
+ models = ModuleType("sigstore.models")
+ verify_mod = ModuleType("sigstore.verify")
+ policy_mod = ModuleType("sigstore.verify.policy")
+
+ class Bundle:
+ @classmethod
+ def from_json(cls, _text):
+ return cls()
+
+ class Identity:
+ def __init__(self, *, identity, issuer):
+ self.identity = identity
+ self.issuer = issuer
+
+ class Verifier:
+ @classmethod
+ def production(cls):
+ raise RuntimeError(
+ "TUF metadata unavailable\x1b]0;SPOOFED-TITLE\x07\x1b[2J"
+ )
+
+ models.Bundle = Bundle
+ verify_mod.Verifier = Verifier
+ policy_mod.Identity = Identity
+ monkeypatch.setitem(sys.modules, "sigstore.models", models)
+ monkeypatch.setitem(sys.modules, "sigstore.verify", verify_mod)
+ monkeypatch.setitem(sys.modules, "sigstore.verify.policy", policy_mod)
+
+ result = CliRunner().invoke(
+ attest_cmd.app,
+ [
+ "verify", str(statement), "--signature", str(sidecar),
+ "--cert-identity", "[email protected]",
+ "--cert-oidc-issuer", "https://issuer.example",
+ ],
+ )
+ assert result.exit_code == 1, result.output
+ out = _strip_ansi(result.output)
+ flattened = " ".join(out.split())
+ assert "verification unavailable" in flattened.lower()
+ assert "TUF metadata unavailable" in flattened
+ assert "\x1b" not in out
+ assert "\x07" not in out
+
+
+def test_emit_write_oserror_is_usage_failure(tmp_path, monkeypatch):
+ import soup_cli.commands.attest as attest_cmd
+
+ monkeypatch.chdir(tmp_path)
+ _patch_signer(monkeypatch)
+ output = tmp_path / "att.json"
+
+ def fail_write(*args, **kwargs):
+ raise OSError("disk full")
+
+ monkeypatch.setattr(attest_cmd, "write_attestation", fail_write)
+ result = CliRunner().invoke(attest_cmd.app, _emit_args(output))
+ assert result.exit_code == 2, result.output
+ cleaned = _strip_ansi(result.output)
+ assert "Write failed" in cleaned
+ assert "disk full" in cleaned
+
+
+def test_attest_docs_document_unavailable_exit():
+ docs_path = (
+ Path(__file__).resolve().parents[1] / "docs" / "adapters-and-governance.md"
+ )
+ docs = docs_path.read_text(encoding="utf-8")
+ assert "exits 1 when Sigstore" in docs
diff --git a/tests/test_v0712.py b/tests/test_v0712.py
index ffbf98fc..4d469f53 100644
--- a/tests/test_v0712.py
+++ b/tests/test_v0712.py
@@ -1,7 +1,7 @@
"""v0.71.2 — "Governance & supply-chain live" (no GPU).
-Closes (in this patch): #186, #187, #190, #191, #192 fully; #179 / #185 get the
-ed25519 half live (Sigstore keyless stays infra-blocked — needs OIDC + network).
+v0.71.2 closed #186/#187/#190/#191/#192 and shipped the ed25519 halves of
+#179/#185. Follow-up work makes the remaining Sigstore backends live.
Test organisation (one class per concern):
- TestSigningPrimitives — utils/signing.py ed25519 helpers (#179/#185 core)
@@ -412,11 +412,19 @@ class TestAttestEd25519:
sig = sign_attestation(b"x", backend="unsigned")
assert sig == {"signature": "", "backend": "unsigned"}
- def test_sign_attestation_sigstore_deferred(self):
+ def test_sign_attestation_sigstore_live_with_injected_signer(self, monkeypatch):
+ from soup_cli.utils import sigstore_signing
from soup_cli.utils.attest import sign_attestation
- with pytest.raises(NotImplementedError):
- sign_attestation(b"x", backend="sigstore")
+ monkeypatch.setattr(
+ sigstore_signing,
+ "sign_payload_sigstore",
+ lambda payload, *, interactive=False: '{"bundle":"ok"}',
+ )
+ result = sign_attestation(b"x", backend="sigstore")
+ assert result["backend"] == "sigstore"
+ assert result["signature"] == ""
+ assert result["sigstore_bundle"] == '{"bundle":"ok"}'
# ---------------------------------------------------------------------------
@@ -1133,7 +1141,7 @@ class TestReviewFollowups:
)
r = runner.invoke(app, ["verify", "stmt.json", "--signature", "stmt.json.sig"])
assert r.exit_code == 3, r.output
- assert "not ed25519" in r.output.lower()
+ assert "not cryptographically verifiable" in r.output.lower()
def test_attest_verify_no_pubkey_exit3(self, tmp_path, monkeypatch):
from typer.testing import CliRunner