1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
use alien_error::AlienErrorData;
use serde::{Deserialize, Serialize};
/// Why a statement, signer list, setting, ledger or workload was refused.
///
/// Every variant is a refusal an enforcer reports back to whoever sent the
/// input, so none of them is internal.
#[derive(Debug, Clone, AlienErrorData, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub enum ErrorData {
/// A key is not a valid ECDSA P-256 key in the expected encoding.
#[error(
code = "SIGNING_KEY_INVALID",
message = "Invalid signing key: {reason}",
retryable = "false",
internal = "false",
http_status_code = 400
)]
KeyInvalid {
/// What is wrong with the key.
reason: String,
},
/// The bytes are not a well-formed signed statement.
#[error(
code = "SIGNING_STATEMENT_MALFORMED",
message = "Malformed statement: {reason}",
retryable = "false",
internal = "false",
http_status_code = 400
)]
StatementMalformed {
/// What is wrong with the statement.
reason: String,
},
/// The statement is of another kind than the one expected.
#[error(
code = "SIGNING_WRONG_KIND",
message = "Expected a '{expected}' statement, got '{actual}'",
retryable = "false",
internal = "false",
http_status_code = 403
)]
WrongKind {
/// Kind the caller asked for.
expected: String,
/// Kind the statement declares.
actual: String,
},
/// The statement names another project.
#[error(
code = "SIGNING_WRONG_PROJECT",
message = "The statement is for project '{actual}', not '{expected}'",
retryable = "false",
internal = "false",
http_status_code = 403
)]
WrongProject {
/// Project of the pinned signer list.
expected: String,
/// Project the statement names.
actual: String,
},
/// The statement names another install, or none where one is required.
#[error(
code = "SIGNING_WRONG_INSTALL",
message = "The statement is for install '{actual}', not '{expected}'",
retryable = "false",
internal = "false",
http_status_code = 403
)]
WrongInstall {
/// This install, or `none` for project-wide kinds.
expected: String,
/// Install the statement names, or `none`.
actual: String,
},
/// A release is for another channel than the one setup pinned.
#[error(
code = "SIGNING_WRONG_CHANNEL",
message = "The release is for channel '{actual}', but this install follows '{expected}'",
retryable = "false",
internal = "false",
http_status_code = 403
)]
WrongChannel {
/// Channel setup pinned.
expected: String,
/// Channel the release names.
actual: String,
},
/// A signature does not verify, or names a signer that may not sign.
#[error(
code = "SIGNING_SIGNATURE_REFUSED",
message = "Signature by '{signer}' refused: {reason}",
retryable = "false",
internal = "false",
http_status_code = 403
)]
SignatureRefused {
/// Signer id the signature names.
signer: String,
/// Why it was refused.
reason: String,
},
/// The statement carries no signature that counts.
#[error(
code = "SIGNING_UNSIGNED",
message = "The statement is not signed by a key holding the '{role}' role",
retryable = "false",
internal = "false",
http_status_code = 403
)]
Unsigned {
/// Role the statement's kind requires.
role: String,
},
/// The statement's `notAfter` has passed.
#[error(
code = "SIGNING_EXPIRED",
message = "The statement expired at {not_after}",
retryable = "false",
internal = "false",
http_status_code = 403
)]
Expired {
/// When it stopped being valid, RFC 3339.
not_after: String,
},
/// The statement's digest is on the signer list's deny-list.
#[error(
code = "SIGNING_DENIED",
message = "The statement {digest} is on the signer list's deny-list",
retryable = "false",
internal = "false",
http_status_code = 403
)]
Denied {
/// Digest of the statement payload.
digest: String,
},
/// A signer list does not extend the trusted chain.
#[error(
code = "SIGNING_SIGNER_LIST_REFUSED",
message = "Signer list version {version} refused: {reason}",
retryable = "false",
internal = "false",
http_status_code = 403
)]
SignerListRefused {
/// Version the refused list claims.
version: u64,
/// Why it was refused.
reason: String,
},
/// The statement was signed against a signer list version the enforcer
/// has not been given.
#[error(
code = "SIGNING_SIGNER_LIST_MISSING",
message = "The statement needs signer list version {needed}, but only version {current} is trusted",
retryable = "true",
internal = "false",
http_status_code = 409
)]
SignerListMissing {
/// Version the statement names.
needed: u64,
/// Highest version the enforcer trusts.
current: u64,
},
/// The signing settings setup wrote are malformed or contradict where
/// they were found.
#[error(
code = "SIGNING_SETTINGS_INVALID",
message = "Invalid signing settings: {reason}",
retryable = "false",
internal = "false",
http_status_code = 400
)]
SettingsInvalid {
/// What is wrong with the settings.
reason: String,
},
/// Whether this install is protected can't be decided from what the
/// enforcer could read, so it runs nothing new.
#[error(
code = "SIGNING_SETTINGS_UNDECIDED",
message = "Can't tell whether this install is protected: {reason}",
retryable = "true",
internal = "false",
http_status_code = 503
)]
SettingsUndecided {
/// What the enforcer saw.
reason: String,
},
/// The install accepted signed state under one trust root and now finds
/// another, or none. Only a local operator command resets it.
#[error(
code = "SIGNING_TRUST_ROOT_CHANGED",
message = "This install accepted state under {accepted} and now finds {found}; it runs nothing new until an operator resets it",
retryable = "false",
internal = "false",
http_status_code = 409
)]
TrustRootChanged {
/// The fingerprint or install id the install accepted state under.
accepted: String,
/// What it finds now, or `none`.
found: String,
},
/// The install's ledger is missing, malformed or forks from what this
/// enforcer holds.
#[error(
code = "SIGNING_LEDGER_REFUSED",
message = "The install's ledger was refused: {reason}",
retryable = "false",
internal = "false",
http_status_code = 409
)]
LedgerRefused {
/// Why.
reason: String,
},
/// A workload asked for something its signed release does not allow.
#[error(
code = "SIGNING_WORKLOAD_REFUSED",
message = "Workload '{workload}' refused: {reason}",
retryable = "false",
internal = "false",
http_status_code = 403
)]
WorkloadRefused {
/// Workload name.
workload: String,
/// Why it was refused.
reason: String,
},
/// A statement body breaks a rule of its kind.
#[error(
code = "SIGNING_BODY_REFUSED",
message = "The '{kind}' statement was refused: {reason}",
retryable = "false",
internal = "false",
http_status_code = 403
)]
BodyRefused {
/// Statement kind.
kind: String,
/// Why it was refused.
reason: String,
},
}
/// Result type of this crate.
pub type Result<T> = alien_error::Result<T, ErrorData>;