Skip to content

Commit 41d3fc9

Browse files
committed
_cli: require --cert-identity OR --repository
Signed-off-by: William Woodruff <william@trailofbits.com>
1 parent d8da1c3 commit 41d3fc9

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

sigstore/_cli.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,17 @@ def _verify_identity(args: argparse.Namespace) -> None:
830830
def _verify_github(args: argparse.Namespace) -> None:
831831
inner_policies: list[policy.VerificationPolicy] = []
832832

833+
# We require at least one of `--cert-identity` or `--repository`,
834+
# to minimize the risk of user confusion about what's being verified.
835+
if not (args.cert_identity or args.workflow_repository):
836+
_die(args, "--cert-identity or --repository is required")
837+
838+
# No matter what the user configures above, we require the OIDC issuer to
839+
# be GitHub Actions.
840+
inner_policies.append(
841+
policy.OIDCIssuer("https://token.actions.githubusercontent.com")
842+
)
843+
833844
if args.cert_identity:
834845
inner_policies.append(
835846
policy.Identity(
@@ -850,16 +861,6 @@ def _verify_github(args: argparse.Namespace) -> None:
850861
if args.workflow_ref:
851862
inner_policies.append(policy.GitHubWorkflowRef(args.workflow_ref))
852863

853-
if not inner_policies:
854-
_die(args, "No verification options supplied")
855-
856-
# No matter what the user configures above, we require the OIDC issuer to
857-
# be GitHub Actions. We add this below the check above, since it doesn't
858-
# constitute a sufficient policy check on its own.
859-
inner_policies.append(
860-
policy.OIDCIssuer("https://token.actions.githubusercontent.com")
861-
)
862-
863864
policy_ = policy.AllOf(inner_policies)
864865

865866
verifier, materials = _collect_verification_state(args)

0 commit comments

Comments
 (0)