Skip to content

Commit f45bee3

Browse files
authored
_cli: exit with an error code when verification fails (#57)
1 parent 4a0425f commit f45bee3

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

.github/workflows/tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
python:
1414
- "3.11"
1515
- "3.12"
16+
- "3.13"
1617
runs-on: ubuntu-latest
1718
permissions:
1819
id-token: write # unit tests use the ambient OIDC credential
@@ -24,6 +25,7 @@ jobs:
2425
python-version: ${{ matrix.python }}
2526
cache: "pip"
2627
cache-dependency-path: pyproject.toml
28+
allow-prereleases: true
2729

2830
- name: test
2931
run: make test INSTALL_EXTRA=test

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- `python -m pypi_attestations verify` now exits with a non-zero exit code
13+
if the verification step fails
14+
([#57](https://github.com/trailofbits/pypi-attestations/pull/57))
15+
1016
## [0.0.12]
1117

1218
### Fixed

src/pypi_attestations/_cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ def _verify(args: argparse.Namespace) -> None:
279279
try:
280280
attestation.verify(verifier, pol, dist)
281281
except VerificationError as verification_error:
282-
_logger.error("Verification failed for %s: %s", file_path, verification_error)
283-
continue
282+
_die(f"Verification failed for {file_path}: {verification_error}")
284283

285284
_logger.info(f"OK: {attestation_path}")
286285

test/test_cli.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,16 @@ def test_verify_command(caplog: pytest.LogCaptureFixture, monkeypatch: pytest.Mo
191191

192192
caplog.clear()
193193

194-
# Failure from the Sigstore environment
195-
run_main_with_command(
196-
[
197-
"verify",
198-
"--identity",
199-
200-
artifact_path.as_posix(),
201-
]
202-
)
194+
with pytest.raises(SystemExit):
195+
# Failure from the Sigstore environment
196+
run_main_with_command(
197+
[
198+
"verify",
199+
"--identity",
200+
201+
artifact_path.as_posix(),
202+
]
203+
)
203204
assert (
204205
"Verification failed: failed to build chain: unable to get local issuer certificate"
205206
in caplog.text

0 commit comments

Comments
 (0)