@@ -26,6 +26,13 @@ class Verifier
26
26
*/
27
27
protected $ now ;
28
28
29
+ /**
30
+ * List of verification failures.
31
+ *
32
+ * @var array
33
+ */
34
+ protected $ failures = [];
35
+
29
36
/**
30
37
* Verifier constructor.
31
38
*
@@ -168,8 +175,17 @@ public function verifyMessage($signed_message) {
168
175
*/
169
176
public function verifyChecksumList ($ signed_checksum_list , $ working_directory )
170
177
{
171
- $ checksum_list_raw = $ this ->verifyMessage ($ signed_checksum_list );
172
- return $ this ->verifyTrustedChecksumList ($ checksum_list_raw , $ working_directory );
178
+ try {
179
+ $ checksum_list_raw = $ this ->verifyMessage ($ signed_checksum_list );
180
+ }
181
+ catch (VerifierException $ exception ) {
182
+ $ this ->failures [] = $ exception ->getMessage ();
183
+ }
184
+ $ count = $ this ->verifyTrustedChecksumList ($ checksum_list_raw , $ working_directory );
185
+ if ($ this ->failures ) {
186
+ throw new VerifierException ('Checksum list could not be verified. ' , $ this ->failures );
187
+ }
188
+ return $ count ;
173
189
}
174
190
175
191
protected function verifyTrustedChecksumList ($ checksum_list_raw , $ working_directory ) {
@@ -183,15 +199,18 @@ protected function verifyTrustedChecksumList($checksum_list_raw, $working_direct
183
199
{
184
200
$ actual_hash = @hash_file (strtolower ($ file_checksum ->algorithm ), $ working_directory . DIRECTORY_SEPARATOR . $ file_checksum ->filename );
185
201
if ($ actual_hash === false ) {
186
- throw new VerifierException ("File \"$ file_checksum ->filename \" in the checksum list could not be read. " );
202
+ $ this ->failures [] = sprintf ('File "%s" in the checksum list could not be read. ' , $ file_checksum ->filename );
203
+ continue ;
187
204
}
188
205
if (empty ($ actual_hash ) || strlen ($ actual_hash ) < 64 ) {
189
- throw new VerifierException ("Failure computing hash for file \"$ file_checksum ->filename \" in the checksum list. " );
206
+ $ this ->failures [] = sprintf ('Failure computing hash for file "%s" in the checksum list. ' , $ file_checksum ->filename );
207
+ continue ;
190
208
}
191
209
192
210
if (strcmp ($ actual_hash , $ file_checksum ->hex_hash ) !== 0 )
193
211
{
194
- throw new VerifierException ("File \"$ file_checksum ->filename \" does not pass checksum verification. " );
212
+ $ this ->failures [] = sprintf ('File "%s" does not pass checksum verification. ' , $ file_checksum ->filename );
213
+ continue ;
195
214
}
196
215
197
216
$ verified_count ++;
@@ -237,12 +256,14 @@ protected function parseChecksumList($checksum_list_raw, $list_is_trusted)
237
256
}
238
257
239
258
if (substr ($ line , 0 , 1 ) === '\\' ) {
240
- throw new VerifierException ('Filenames with problematic characters are not yet supported. ' );
259
+ $ this ->failures [] = sprintf ('Filenames "%s" with problematic characters are not yet supported. ' , $ line );
260
+ continue ;
241
261
}
242
262
243
263
$ algo = substr ($ line , 0 , strpos ($ line , ' ' ));
244
264
if (empty ($ this ->HASH_ALGO_BASE64_LENGTHS [$ algo ])) {
245
- throw new VerifierException ("Algorithm \"$ algo \" is unsupported for checksum verification. " );
265
+ $ this ->failures [] = sprintf ('Algorithm "%s" is unsupported for checksum verification. ' , $ algo );
266
+ continue ;
246
267
}
247
268
248
269
$ filename_start = strpos ($ line , '( ' ) + 1 ;
0 commit comments