-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor everything Signed-off-by: William Woodruff <william@trailofbits.com> * update note Signed-off-by: William Woodruff <william@trailofbits.com> * re-exports Signed-off-by: William Woodruff <william@trailofbits.com> * sigstore_rekor_types -> rekor_types More accurate, shorter. Signed-off-by: William Woodruff <william@trailofbits.com> * fixups Signed-off-by: William Woodruff <william@trailofbits.com> * cleanup Signed-off-by: William Woodruff <william@trailofbits.com> * typing_extensions Signed-off-by: William Woodruff <william@trailofbits.com> * use explicit Union Signed-off-by: William Woodruff <william@trailofbits.com> --------- Signed-off-by: William Woodruff <william@trailofbits.com>
- Loading branch information
Showing
19 changed files
with
1,040 additions
and
1,125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
"""The `sigstore_rekor_types` APIs.""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from typing import Literal, Union | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr | ||
|
||
from ._internal import ( | ||
alpine, | ||
cose, | ||
dsse, | ||
hashedrekord, | ||
helm, | ||
intoto, | ||
jar, | ||
rekord, | ||
rfc3161, | ||
rpm, | ||
tuf, | ||
) | ||
|
||
if sys.version_info < (3, 9): | ||
from typing_extensions import Annotated | ||
else: | ||
from typing import Annotated | ||
|
||
__version__ = "0.0.11" | ||
|
||
|
||
class Error(BaseModel): | ||
"""A Rekor server error.""" | ||
|
||
code: StrictInt | ||
message: StrictStr | ||
|
||
|
||
class _ProposedEntryMixin(BaseModel): | ||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
api_version: StrictStr = Field( | ||
pattern=r"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$", | ||
default="0.0.1", | ||
alias="apiVersion", | ||
) | ||
|
||
|
||
class Alpine(_ProposedEntryMixin): | ||
"""Proposed entry model for an `alpine` record.""" | ||
|
||
kind: Literal["alpine"] = "alpine" | ||
spec: alpine.AlpinePackageSchema | ||
|
||
|
||
class Cose(_ProposedEntryMixin): | ||
"""Proposed entry model for a `cose` record.""" | ||
|
||
kind: Literal["cose"] = "cose" | ||
spec: cose.CoseSchema | ||
|
||
|
||
class Dsse(_ProposedEntryMixin): | ||
"""Proposed entry model for a `dsse` record.""" | ||
|
||
kind: Literal["dsse"] = "dsse" | ||
spec: dsse.DsseSchema | ||
|
||
|
||
class Hashedrekord(_ProposedEntryMixin): | ||
"""Proposed entry model for a `dsse` record.""" | ||
|
||
kind: Literal["hashedrekord"] = "hashedrekord" | ||
spec: hashedrekord.RekorSchema | ||
|
||
|
||
class Helm(_ProposedEntryMixin): | ||
"""Proposed entry model for a `dsse` record.""" | ||
|
||
kind: Literal["helm"] = "helm" | ||
spec: helm.HelmSchema | ||
|
||
|
||
class Intoto(_ProposedEntryMixin): | ||
"""Proposed entry model for a `dsse` record.""" | ||
|
||
kind: Literal["intoto"] = "intoto" | ||
spec: intoto.IntotoSchema | ||
|
||
|
||
class Jar(_ProposedEntryMixin): | ||
"""Proposed entry model for a `jar` record.""" | ||
|
||
kind: Literal["jar"] = "jar" | ||
spec: jar.JarSchema | ||
|
||
|
||
class Rekord(_ProposedEntryMixin): | ||
"""Proposed entry model for a `rekord` record.""" | ||
|
||
kind: Literal["rekord"] = "rekord" | ||
spec: rekord.RekorSchema | ||
|
||
|
||
class Rfc3161(_ProposedEntryMixin): | ||
"""Proposed entry model for a `rfc3161` record.""" | ||
|
||
kind: Literal["rfc3161"] = "rfc3161" | ||
spec: rfc3161.TimestampSchema | ||
|
||
|
||
class Rpm(_ProposedEntryMixin): | ||
"""Proposed entry model for an `rpm` record.""" | ||
|
||
kind: Literal["rpm"] = "rpm" | ||
spec: rpm.RpmSchema | ||
|
||
|
||
class Tuf(_ProposedEntryMixin): | ||
"""Proposed entry model for a `tuf` record.""" | ||
|
||
kind: Literal["tuf"] = "tuf" | ||
spec: tuf.TufSchema | ||
|
||
|
||
ProposedEntry = Annotated[ | ||
Union[Alpine, Cose, Dsse, Hashedrekord, Helm, Intoto, Jar, Rekord, Rfc3161, Rpm, Tuf], | ||
Field(discriminator="kind"), | ||
] |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# generated by datamodel-codegen: | ||
|
||
from __future__ import annotations | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, RootModel | ||
|
||
|
||
class PublicKey(BaseModel): | ||
"""The public key that can verify the package signature.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
content: str = Field( | ||
..., | ||
description="Specifies the content of the public key inline within the document", | ||
) | ||
|
||
|
||
class AlpineV001Schema(BaseModel): | ||
"""Schema for Alpine Package entries.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
public_key: PublicKey = Field( | ||
..., | ||
alias="publicKey", | ||
description="The public key that can verify the package signature", | ||
) | ||
|
||
|
||
class AlpinePackageSchema(RootModel[AlpineV001Schema]): | ||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
root: AlpineV001Schema = Field( | ||
..., | ||
description="Schema for Alpine package objects", | ||
title="Alpine Package Schema", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# generated by datamodel-codegen: | ||
|
||
from __future__ import annotations | ||
|
||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import BaseModel, ConfigDict, Field, RootModel, StrictStr | ||
|
||
|
||
class Algorithm(str, Enum): | ||
"""The hashing function used to compute the hash value.""" | ||
|
||
SHA256 = "sha256" | ||
|
||
|
||
class PayloadHash(BaseModel): | ||
"""Specifies the hash algorithm and value for the content.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
algorithm: Algorithm = Field( | ||
..., | ||
description="The hashing function used to compute the hash value", | ||
) | ||
value: StrictStr = Field(..., description="The hash value for the content") | ||
|
||
|
||
class EnvelopeHash(BaseModel): | ||
"""Specifies the hash algorithm and value for the COSE envelope.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
algorithm: Algorithm = Field( | ||
..., | ||
description="The hashing function used to compute the hash value", | ||
) | ||
value: StrictStr = Field(..., description="The hash value for the envelope") | ||
|
||
|
||
class Data(BaseModel): | ||
"""Information about the content associated with the entry.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
payload_hash: Optional[PayloadHash] = Field( | ||
default=None, | ||
alias="payloadHash", | ||
description="Specifies the hash algorithm and value for the content", | ||
) | ||
envelope_hash: Optional[EnvelopeHash] = Field( | ||
default=None, | ||
alias="envelopeHash", | ||
description="Specifies the hash algorithm and value for the COSE envelope", | ||
) | ||
aad: Optional[str] = Field( | ||
default=None, | ||
description="Specifies the additional authenticated data required to verify the signature", | ||
) | ||
|
||
|
||
class CoseV001Schema(BaseModel): | ||
"""Schema for cose object.""" | ||
|
||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
message: Optional[str] = Field(default=None, description="The COSE Sign1 Message") | ||
public_key: str = Field( | ||
..., | ||
alias="publicKey", | ||
description="The public key that can verify the signature", | ||
) | ||
data: Data = Field(..., description="Information about the content associated with the entry") | ||
|
||
|
||
class CoseSchema(RootModel[CoseV001Schema]): | ||
model_config = ConfigDict( | ||
populate_by_name=True, | ||
) | ||
root: CoseV001Schema = Field(..., description="COSE for Rekord objects", title="COSE Schema") |
Oops, something went wrong.