Skip to content

Commit c31db82

Browse files
authored
_cli: files always take precedence over digests (#1152)
* _cli: files always take precedence over digests Signed-off-by: William Woodruff <william@trailofbits.com> * CHANGELOG: record changes Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent 8153906 commit c31db82

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ All versions prior to 0.9.0 are untracked.
1414
operations, including routine local TUF repository refreshes
1515
([#1143](https://github.com/sigstore/sigstore-python/pull/1143))
1616

17+
### Fixed
18+
19+
* CLI: The `sigstore verify` subcommands now always check for a matching
20+
input file, rather than unconditionally falling back to matching on a
21+
valid `sha256:...` digest pattern
22+
([#1152](https://github.com/sigstore/sigstore-python/pull/1152))
23+
1724
## [3.3.0]
1825

1926
### Added

sigstore/_cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,16 +167,19 @@ def _add_shared_verify_input_options(group: argparse._ArgumentGroup) -> None:
167167
)
168168

169169
def file_or_digest(arg: str) -> Hashed | Path:
170-
if arg.startswith("sha256:"):
170+
path = Path(arg)
171+
if path.is_file():
172+
return path
173+
elif arg.startswith("sha256"):
171174
digest = bytes.fromhex(arg[len("sha256:") :])
172175
if len(digest) != 32:
173-
raise ValueError()
176+
raise ValueError
174177
return Hashed(
175178
digest=digest,
176179
algorithm=HashAlgorithm.SHA2_256,
177180
)
178181
else:
179-
return Path(arg)
182+
raise ValueError
180183

181184
group.add_argument(
182185
"files_or_digest",

0 commit comments

Comments
 (0)