Skip to content

Commit

Permalink
verify/models: enforce bundle media type
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <[email protected]>
  • Loading branch information
woodruffw committed Jul 12, 2023
1 parent 145a6b0 commit daaeb4f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions sigstore/verify/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@

logger = logging.getLogger(__name__)

_KNOWN_BUNDLE_TYPES: set[str] = {
"application/vnd.dev.sigstore.bundle+json;version=0.1",
"application/vnd.dev.sigstore.bundle+json;version=0.2",
}


class VerificationResult(BaseModel):
"""
Expand Down Expand Up @@ -242,6 +247,9 @@ def from_bundle(
Effect: `input_` is consumed as part of construction.
"""
if bundle.media_type not in _KNOWN_BUNDLE_TYPES:
raise InvalidMaterials(f"unsupported bundle format: {bundle.media_type}")

certs = bundle.verification_material.x509_certificate_chain.certificates

if len(certs) == 0:
Expand Down

0 comments on commit daaeb4f

Please sign in to comment.