Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure verify terminates on model validation failure #352

Merged
merged 5 commits into from
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import argparse
import logging
import pathlib
import sys

from model_signing import model
from model_signing.hashing import file
Expand Down Expand Up @@ -148,13 +149,13 @@ def _get_payload_signer(args: argparse.Namespace) -> signing.Signer:
log.error(
'supported methods: ["pki", "private-key", "sigstore", "skip"]'
)
exit(-1)
sys.exit(1)


def _check_private_key_options(args: argparse.Namespace):
if args.key_path == "":
log.error("--private_key must be set to a valid private key PEM file")
exit()
sys.exit()


def _check_pki_options(args: argparse.Namespace):
Expand All @@ -166,7 +167,7 @@ def _check_pki_options(args: argparse.Namespace):
"PEM encoded signing certificate",
)
)
exit()
sys.exit()
if args.cert_chain_path == "":
log.warning("No certificate chain provided")

Expand Down
6 changes: 3 additions & 3 deletions src/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,13 @@ def _get_verifier(args: argparse.Namespace) -> signing.Verifier:
log.error(
'supported methods: ["pki", "private-key", "sigstore", "skip"]'
)
exit(-1)
sys.exit(1)


def _check_private_key_flags(args: argparse.Namespace):
if args.key == "":
log.error("--public_key must be defined")
exit()
sys.exit()


def _check_pki_flags(args: argparse.Namespace):
Expand Down Expand Up @@ -169,7 +169,7 @@ def hasher_factory(file_path: pathlib.Path) -> file.FileHasher:
)
except verifying.VerificationError as err:
log.error(f"verification failed: {err}")
sys.exit(-1)
sys.exit(1)

log.info("all checks passed")

Expand Down
Loading