@@ -84,10 +84,8 @@ type reporter interface {
84
84
report (* processor , * Domain )
85
85
}
86
86
87
- var (
88
- // errContinue indicates that the current check should continue.
89
- errContinue = errors .New ("continue" )
90
- )
87
+ // errContinue indicates that the current check should continue.
88
+ var errContinue = errors .New ("continue" )
91
89
92
90
type whereType byte
93
91
@@ -167,7 +165,6 @@ func (m *topicMessages) hasErrors() bool {
167
165
168
166
// newProcessor returns an initialized processor.
169
167
func newProcessor (cfg * config ) (* processor , error ) {
170
-
171
168
var validator csaf.RemoteValidator
172
169
173
170
if cfg .RemoteValidator != "" {
@@ -240,7 +237,6 @@ func (p *processor) reset() {
240
237
// Then it calls the report method on each report from the given "reporters" parameter for each domain.
241
238
// It returns a pointer to the report and nil, otherwise an error.
242
239
func (p * processor ) run (domains []string ) (* Report , error ) {
243
-
244
240
report := Report {
245
241
Date : ReportTime {Time : time .Now ().UTC ()},
246
242
Version : util .SemVersion ,
@@ -297,7 +293,6 @@ func (p *processor) run(domains []string) (*Report, error) {
297
293
298
294
// fillMeta fills the report with extra informations from provider metadata.
299
295
func (p * processor ) fillMeta (domain * Domain ) error {
300
-
301
296
if p .pmd == nil {
302
297
return nil
303
298
}
@@ -323,7 +318,6 @@ func (p *processor) fillMeta(domain *Domain) error {
323
318
// domainChecks compiles a list of checks which should be performed
324
319
// for a given domain.
325
320
func (p * processor ) domainChecks (domain string ) []func (* processor , string ) error {
326
-
327
321
// If we have a direct domain url we dont need to
328
322
// perform certain checks.
329
323
direct := strings .HasPrefix (domain , "https://" )
@@ -393,7 +387,6 @@ func (p *processor) markChecked(s string, mask whereType) bool {
393
387
}
394
388
395
389
func (p * processor ) checkRedirect (r * http.Request , via []* http.Request ) error {
396
-
397
390
url := r .URL .String ()
398
391
p .checkTLS (url )
399
392
if p .redirects == nil {
@@ -495,7 +488,6 @@ func (p *processor) usedAuthorizedClient() bool {
495
488
496
489
// rolieFeedEntries loads the references to the advisory files for a given feed.
497
490
func (p * processor ) rolieFeedEntries (feed string ) ([]csaf.AdvisoryFile , error ) {
498
-
499
491
client := p .httpClient ()
500
492
res , err := client .Get (feed )
501
493
p .badDirListings .use ()
@@ -546,7 +538,6 @@ func (p *processor) rolieFeedEntries(feed string) ([]csaf.AdvisoryFile, error) {
546
538
var files []csaf.AdvisoryFile
547
539
548
540
rfeed .Entries (func (entry * csaf.Entry ) {
549
-
550
541
// Filter if we have date checking.
551
542
if accept := p .cfg .Range ; accept != nil {
552
543
if t := time .Time (entry .Updated ); ! t .IsZero () && ! accept .Contains (t ) {
@@ -759,14 +750,20 @@ func (p *processor) integrity(
759
750
// Check hashes
760
751
p .badIntegrities .use ()
761
752
762
- for _ , x := range [] struct {
753
+ type hash struct {
763
754
ext string
764
755
url func () string
765
756
hash []byte
766
- }{
767
- {"SHA256" , f .SHA256URL , s256 .Sum (nil )},
768
- {"SHA512" , f .SHA512URL , s512 .Sum (nil )},
769
- } {
757
+ }
758
+ hashes := []hash {}
759
+ if f .SHA256URL () != "" {
760
+ hashes = append (hashes , hash {"SHA256" , f .SHA256URL , s256 .Sum (nil )})
761
+ }
762
+ if f .SHA512URL () != "" {
763
+ hashes = append (hashes , hash {"SHA512" , f .SHA512URL , s512 .Sum (nil )})
764
+ }
765
+
766
+ for _ , x := range hashes {
770
767
hu , err := url .Parse (x .url ())
771
768
if err != nil {
772
769
lg (ErrorType , "Bad URL %s: %v" , x .url (), err )
@@ -918,7 +915,6 @@ func (p *processor) checkIndex(base string, mask whereType) error {
918
915
// of the fields' values and if they are sorted properly. Then it passes the files to the
919
916
// "integrity" functions. It returns error if some test fails, otherwise nil.
920
917
func (p * processor ) checkChanges (base string , mask whereType ) error {
921
-
922
918
bu , err := url .Parse (base )
923
919
if err != nil {
924
920
return err
@@ -978,8 +974,7 @@ func (p *processor) checkChanges(base string, mask whereType) error {
978
974
}
979
975
path := r [pathColumn ]
980
976
981
- times , files =
982
- append (times , t ),
977
+ times , files = append (times , t ),
983
978
append (files , csaf.DirectoryAdvisoryFile {Path : path })
984
979
}
985
980
return times , files , nil
@@ -1152,7 +1147,6 @@ func (p *processor) checkMissing(string) error {
1152
1147
// checkInvalid goes over all found adivisories URLs and checks
1153
1148
// if file name conforms to standard.
1154
1149
func (p * processor ) checkInvalid (string ) error {
1155
-
1156
1150
p .badDirListings .use ()
1157
1151
var invalids []string
1158
1152
@@ -1174,7 +1168,6 @@ func (p *processor) checkInvalid(string) error {
1174
1168
// checkListing goes over all found adivisories URLs and checks
1175
1169
// if their parent directory is listable.
1176
1170
func (p * processor ) checkListing (string ) error {
1177
-
1178
1171
p .badDirListings .use ()
1179
1172
1180
1173
pgs := pages {}
@@ -1209,7 +1202,6 @@ func (p *processor) checkListing(string) error {
1209
1202
// checkWhitePermissions checks if the TLP:WHITE advisories are
1210
1203
// available with unprotected access.
1211
1204
func (p * processor ) checkWhitePermissions (string ) error {
1212
-
1213
1205
var ids []string
1214
1206
for id , open := range p .labelChecker .whiteAdvisories {
1215
1207
if ! open {
@@ -1235,7 +1227,6 @@ func (p *processor) checkWhitePermissions(string) error {
1235
1227
// According to the result, the respective error messages added to
1236
1228
// badProviderMetadata.
1237
1229
func (p * processor ) checkProviderMetadata (domain string ) bool {
1238
-
1239
1230
p .badProviderMetadata .use ()
1240
1231
1241
1232
client := p .httpClient ()
@@ -1282,7 +1273,6 @@ func (p *processor) checkSecurity(domain string, legacy bool) (int, string) {
1282
1273
1283
1274
// checkSecurityFolder checks the security.txt in a given folder.
1284
1275
func (p * processor ) checkSecurityFolder (folder string ) string {
1285
-
1286
1276
client := p .httpClient ()
1287
1277
path := folder + "security.txt"
1288
1278
res , err := client .Get (path )
@@ -1349,7 +1339,6 @@ func (p *processor) checkSecurityFolder(folder string) string {
1349
1339
// and serves the "provider-metadata.json".
1350
1340
// It returns an empty string if all checks are passed, otherwise the errormessage.
1351
1341
func (p * processor ) checkDNS (domain string ) string {
1352
-
1353
1342
client := p .httpClient ()
1354
1343
path := "https://csaf.data.security." + domain
1355
1344
res , err := client .Get (path )
@@ -1359,7 +1348,6 @@ func (p *processor) checkDNS(domain string) string {
1359
1348
if res .StatusCode != http .StatusOK {
1360
1349
return fmt .Sprintf ("Fetching %s failed. Status code %d (%s)" ,
1361
1350
path , res .StatusCode , res .Status )
1362
-
1363
1351
}
1364
1352
hash := sha256 .New ()
1365
1353
defer res .Body .Close ()
@@ -1378,7 +1366,6 @@ func (p *processor) checkDNS(domain string) string {
1378
1366
// available under the /.well-known/csaf/ directory. Returns the errormessage if
1379
1367
// an error was encountered, or an empty string otherwise
1380
1368
func (p * processor ) checkWellknown (domain string ) string {
1381
-
1382
1369
client := p .httpClient ()
1383
1370
path := "https://" + domain + "/.well-known/csaf/provider-metadata.json"
1384
1371
@@ -1408,7 +1395,6 @@ func (p *processor) checkWellknown(domain string) string {
1408
1395
// The function returns nil, unless errors outside the checks were found.
1409
1396
// In that case, errors are returned.
1410
1397
func (p * processor ) checkWellknownSecurityDNS (domain string ) error {
1411
-
1412
1398
warningsW := p .checkWellknown (domain )
1413
1399
// Security check for well known (default) and legacy location
1414
1400
warningsS , sDMessage := p .checkSecurity (domain , false )
@@ -1461,7 +1447,6 @@ func (p *processor) checkWellknownSecurityDNS(domain string) error {
1461
1447
// As a result of these a respective error messages are passed to badPGP method
1462
1448
// in case of errors. It returns nil if all checks are passed.
1463
1449
func (p * processor ) checkPGPKeys (_ string ) error {
1464
-
1465
1450
p .badPGPs .use ()
1466
1451
1467
1452
src , err := p .expr .Eval ("$.public_openpgp_keys" , p .pmd )
@@ -1520,7 +1505,6 @@ func (p *processor) checkPGPKeys(_ string) error {
1520
1505
defer res .Body .Close ()
1521
1506
return crypto .NewKeyFromArmoredReader (res .Body )
1522
1507
}()
1523
-
1524
1508
if err != nil {
1525
1509
p .badPGPs .error ("Reading public OpenPGP key %s failed: %v" , u , err )
1526
1510
continue
0 commit comments