Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/rekor_types/_internal/intoto.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

53 statements  

1# generated by datamodel-codegen: 

2# filename: intoto_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 Algorithm(str, Enum): 

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

15 

16 SHA256 = "sha256" 

17 

18 

19class Hash(BaseModel): 

20 """Specifies the hash algorithm and value encompassing the entire signed envelope; this is computed by the rekor server, client-provided values are ignored""" 

21 

22 model_config = ConfigDict( 

23 populate_by_name=True, 

24 ) 

25 algorithm: Algorithm = Field( 

26 ..., 

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

28 ) 

29 value: StrictStr = Field(..., description="The hash value for the archive") 

30 

31 

32class PayloadHash(BaseModel): 

33 """Specifies the hash algorithm and value covering the payload within the DSSE envelope; this is computed by the rekor server, client-provided values are ignored""" 

34 

35 model_config = ConfigDict( 

36 populate_by_name=True, 

37 ) 

38 algorithm: Algorithm = Field( 

39 ..., 

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

41 ) 

42 value: StrictStr = Field(..., description="The hash value for the envelope's payload") 

43 

44 

45class Content(BaseModel): 

46 model_config = ConfigDict( 

47 populate_by_name=True, 

48 ) 

49 envelope: Optional[StrictStr] = Field(default=None, description="envelope") 

50 hash: Optional[Hash] = Field( 

51 default=None, 

52 description="Specifies the hash algorithm and value encompassing the entire signed envelope; this is computed by the rekor server, client-provided values are ignored", 

53 ) 

54 payload_hash: Optional[PayloadHash] = Field( 

55 default=None, 

56 alias="payloadHash", 

57 description="Specifies the hash algorithm and value covering the payload within the DSSE envelope; this is computed by the rekor server, client-provided values are ignored", 

58 ) 

59 

60 

61class IntotoV001Schema(BaseModel): 

62 """Schema for intoto object""" 

63 

64 model_config = ConfigDict( 

65 populate_by_name=True, 

66 ) 

67 content: Content 

68 public_key: str = Field( 

69 ..., 

70 alias="publicKey", 

71 description="The public key that can verify the signature", 

72 ) 

73 

74 

75class Signature(BaseModel): 

76 """a signature of the envelope's payload along with the public key for the signature""" 

77 

78 model_config = ConfigDict( 

79 populate_by_name=True, 

80 ) 

81 keyid: Optional[StrictStr] = Field( 

82 default=None, 

83 description="optional id of the key used to create the signature", 

84 ) 

85 sig: str = Field(..., description="signature of the payload") 

86 public_key: str = Field( 

87 ..., 

88 alias="publicKey", 

89 description="public key that corresponds to this signature", 

90 ) 

91 

92 

93class Envelope(BaseModel): 

94 """dsse envelope""" 

95 

96 model_config = ConfigDict( 

97 populate_by_name=True, 

98 ) 

99 payload: Optional[str] = Field(default=None, description="payload of the envelope") 

100 payload_type: StrictStr = Field( 

101 ..., 

102 alias="payloadType", 

103 description="type describing the payload", 

104 ) 

105 signatures: List[Signature] = Field( 

106 ..., 

107 description="collection of all signatures of the envelope's payload", 

108 min_length=1, 

109 ) 

110 

111 

112class Hash1(BaseModel): 

113 """Specifies the hash algorithm and value encompassing the entire signed envelope""" 

114 

115 model_config = ConfigDict( 

116 populate_by_name=True, 

117 ) 

118 algorithm: Algorithm = Field( 

119 ..., 

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

121 ) 

122 value: StrictStr = Field(..., description="The hash value for the archive") 

123 

124 

125class PayloadHash1(BaseModel): 

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

127 

128 model_config = ConfigDict( 

129 populate_by_name=True, 

130 ) 

131 algorithm: Algorithm = Field( 

132 ..., 

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

134 ) 

135 value: StrictStr = Field(..., description="The hash value of the payload") 

136 

137 

138class Content1(BaseModel): 

139 model_config = ConfigDict( 

140 populate_by_name=True, 

141 ) 

142 envelope: Envelope = Field(..., description="dsse envelope") 

143 hash: Optional[Hash1] = Field( 

144 default=None, 

145 description="Specifies the hash algorithm and value encompassing the entire signed envelope", 

146 ) 

147 payload_hash: Optional[PayloadHash1] = Field( 

148 default=None, 

149 alias="payloadHash", 

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

151 ) 

152 

153 

154class IntotoV002Schema(BaseModel): 

155 """Schema for intoto object""" 

156 

157 model_config = ConfigDict( 

158 populate_by_name=True, 

159 ) 

160 content: Content1 

161 

162 

163class IntotoSchema(RootModel[Union[IntotoV001Schema, IntotoV002Schema]]): 

164 model_config = ConfigDict( 

165 populate_by_name=True, 

166 ) 

167 root: Union[IntotoV001Schema, IntotoV002Schema] = Field( 

168 ..., 

169 description="Intoto for Rekord objects", 

170 title="Intoto Schema", 

171 )