Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/rekor_types/_internal/dsse.py: 98%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

40 statements  

1# generated by datamodel-codegen: 

2# filename: dsse_schema.json 

3# version: 0.26.3 

4 

5from __future__ import annotations 

6 

7from enum import Enum 

8from typing import List, Optional, Union 

9 

10from pydantic import BaseModel, ConfigDict, Field, RootModel, StrictStr 

11 

12 

13class ProposedContent(BaseModel): 

14 model_config = ConfigDict( 

15 populate_by_name=True, 

16 ) 

17 envelope: StrictStr = Field( 

18 ..., 

19 description="DSSE envelope specified as a stringified JSON object", 

20 ) 

21 verifiers: List[str] = Field( 

22 ..., 

23 description="collection of all verification material (e.g. public keys or certificates) used to verify signatures over envelope's payload, specified as base64-encoded strings", 

24 min_length=1, 

25 ) 

26 

27 

28class Signature(BaseModel): 

29 """a signature of the envelope's payload along with the verification material for the signature""" 

30 

31 model_config = ConfigDict( 

32 populate_by_name=True, 

33 ) 

34 signature: StrictStr = Field(..., description="base64 encoded signature of the payload") 

35 verifier: str = Field( 

36 ..., 

37 description="verification material that was used to verify the corresponding signature, specified as a base64 encoded string", 

38 ) 

39 

40 

41class Algorithm(str, Enum): 

42 """The hashing function used to compute the hash value""" 

43 

44 SHA256 = "sha256" 

45 

46 

47class EnvelopeHash(BaseModel): 

48 """Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor""" 

49 

50 model_config = ConfigDict( 

51 populate_by_name=True, 

52 ) 

53 algorithm: Algorithm = Field( 

54 ..., 

55 description="The hashing function used to compute the hash value", 

56 ) 

57 value: StrictStr = Field( 

58 ..., 

59 description="The value of the computed digest over the entire envelope", 

60 ) 

61 

62 

63class PayloadHash(BaseModel): 

64 """Specifies the hash algorithm and value covering the payload within the DSSE envelope""" 

65 

66 model_config = ConfigDict( 

67 populate_by_name=True, 

68 ) 

69 algorithm: Algorithm = Field( 

70 ..., 

71 description="The hashing function used to compute the hash value", 

72 ) 

73 value: StrictStr = Field( 

74 ..., 

75 description="The value of the computed digest over the payload within the envelope", 

76 ) 

77 

78 

79class DsseV001Schema1(BaseModel): 

80 """Schema for DSSE envelopes""" 

81 

82 model_config = ConfigDict( 

83 populate_by_name=True, 

84 ) 

85 proposed_content: ProposedContent = Field(..., alias="proposedContent") 

86 signatures: Optional[List[Signature]] = Field( 

87 default=None, 

88 description="extracted collection of all signatures of the envelope's payload; elements will be sorted by lexicographical order of the base64 encoded signature strings", 

89 min_length=1, 

90 ) 

91 envelope_hash: Optional[EnvelopeHash] = Field( 

92 default=None, 

93 alias="envelopeHash", 

94 description="Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor", 

95 ) 

96 payload_hash: Optional[PayloadHash] = Field( 

97 default=None, 

98 alias="payloadHash", 

99 description="Specifies the hash algorithm and value covering the payload within the DSSE envelope", 

100 ) 

101 

102 

103class EnvelopeHash1(EnvelopeHash): 

104 """Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor""" 

105 

106 

107class PayloadHash1(PayloadHash): 

108 """Specifies the hash algorithm and value covering the payload within the DSSE envelope""" 

109 

110 

111class DsseV001Schema2(BaseModel): 

112 """Schema for DSSE envelopes""" 

113 

114 model_config = ConfigDict( 

115 populate_by_name=True, 

116 ) 

117 proposed_content: Optional[ProposedContent] = Field(default=None, alias="proposedContent") 

118 signatures: List[Signature] = Field( 

119 ..., 

120 description="extracted collection of all signatures of the envelope's payload; elements will be sorted by lexicographical order of the base64 encoded signature strings", 

121 min_length=1, 

122 ) 

123 envelope_hash: EnvelopeHash1 = Field( 

124 ..., 

125 alias="envelopeHash", 

126 description="Specifies the hash algorithm and value encompassing the entire envelope sent to Rekor", 

127 ) 

128 payload_hash: PayloadHash1 = Field( 

129 ..., 

130 alias="payloadHash", 

131 description="Specifies the hash algorithm and value covering the payload within the DSSE envelope", 

132 ) 

133 

134 

135class DsseSchema(RootModel[Union[DsseV001Schema1, DsseV001Schema2]]): 

136 model_config = ConfigDict( 

137 populate_by_name=True, 

138 ) 

139 root: Union[DsseV001Schema1, DsseV001Schema2] = Field( 

140 ..., 

141 description="log entry schema for dsse envelopes", 

142 title="DSSE Schema", 

143 )