1
0
Fork 0
mirror of https://github.com/gocsaf/csaf.git synced 2025-12-22 11:55:40 +01:00

Improve checks and messages for bad entries in files

* Ignore bad URLs in index.txt, improve messages.

resolve #158
This commit is contained in:
Sascha L. Teichmann 2022-07-21 17:11:46 +02:00 committed by GitHub
parent 6a605fdbcc
commit d1855a9c30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 12 deletions

View file

@ -756,8 +756,13 @@ func (p *processor) checkIndex(base string, mask whereType) error {
defer res.Body.Close()
var files []csaf.AdvisoryFile
scanner := bufio.NewScanner(res.Body)
for scanner.Scan() {
files = append(files, csaf.PlainAdvisoryFile(scanner.Text()))
for line := 1; scanner.Scan(); line++ {
u := scanner.Text()
if _, err := url.Parse(u); err != nil {
p.badIntegrities.error("index.txt contains invalid URL %q in line %d", u, line)
continue
}
files = append(files, csaf.PlainAdvisoryFile(u))
}
return files, scanner.Err()
}()