mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
when downloader is run with verbose flag the advisory validation issues are logged in detail.
This commit is contained in:
parent
0375e22747
commit
a1d609c7d8
1 changed files with 19 additions and 7 deletions
|
|
@ -191,6 +191,23 @@ func (d *downloader) loadOpenPGPKeys(
|
|||
return nil
|
||||
}
|
||||
|
||||
// logValidationIssues logs the issues reported by the advisory schema validation.
|
||||
func (d *downloader) logValidationIssues(url string, errors []string, err error) {
|
||||
if err != nil {
|
||||
log.Printf("Failed to validate %s: %v", url, err)
|
||||
return
|
||||
}
|
||||
if len(errors) > 0 {
|
||||
if d.opts.Verbose {
|
||||
log.Printf("CSAF file %s has validation errors: %s\n",
|
||||
url, strings.Join(errors, ", "))
|
||||
} else {
|
||||
log.Printf("CSAF file %s has %d validation errors.\n",
|
||||
url, len(errors))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *downloader) downloadFiles(label csaf.TLPLabel, files []csaf.AdvisoryFile) error {
|
||||
|
||||
client := d.httpClient()
|
||||
|
|
@ -307,13 +324,8 @@ func (d *downloader) downloadFiles(label csaf.TLPLabel, files []csaf.AdvisoryFil
|
|||
}
|
||||
|
||||
// Validate against CSAF schema.
|
||||
errors, err := csaf.ValidateCSAF(doc)
|
||||
if err != nil {
|
||||
log.Printf("Failed to validate %s: %v", file.URL(), err)
|
||||
continue
|
||||
}
|
||||
if len(errors) > 0 {
|
||||
log.Printf("CSAF file %s has %d validation errors.", file.URL(), len(errors))
|
||||
if errors, err := csaf.ValidateCSAF(doc); err != nil || len(errors) > 0 {
|
||||
d.logValidationIssues(file.URL(), errors, err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue