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

_cli: files always take precedence over digests #1152

Merged
merged 2 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all 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: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ All versions prior to 0.9.0 are untracked.
operations, including routine local TUF repository refreshes
([#1143](https://github.com/sigstore/sigstore-python/pull/1143))

### Fixed

* CLI: The `sigstore verify` subcommands now always check for a matching
input file, rather than unconditionally falling back to matching on a
valid `sha256:...` digest pattern
([#1152](https://github.com/sigstore/sigstore-python/pull/1152))

## [3.3.0]

### Added
Expand Down
9 changes: 6 additions & 3 deletions sigstore/_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,19 @@ def _add_shared_verify_input_options(group: argparse._ArgumentGroup) -> None:
)

def file_or_digest(arg: str) -> Hashed | Path:
if arg.startswith("sha256:"):
path = Path(arg)
if path.is_file():
return path
elif arg.startswith("sha256"):
digest = bytes.fromhex(arg[len("sha256:") :])
if len(digest) != 32:
raise ValueError()
raise ValueError
return Hashed(
digest=digest,
algorithm=HashAlgorithm.SHA2_256,
)
else:
return Path(arg)
raise ValueError

group.add_argument(
"files_or_digest",
Expand Down
Loading