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

Add filename conformity check

* Add util function to check a filename for confirming to csaf-v2.0-csd02.
* Add code to reject bad filenames in provider, checker, aggregator and uploader.
This commit is contained in:
Sascha L. Teichmann 2022-05-20 18:57:27 +02:00 committed by GitHub
parent f6fa366ee5
commit 17f22855ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 99 additions and 9 deletions

View file

@ -22,6 +22,7 @@ import (
"log"
"net/http"
"net/url"
"path/filepath"
"regexp"
"sort"
"strconv"
@ -204,6 +205,7 @@ func (p *processor) checkDomain(domain string) error {
(*processor).checkSecurity,
(*processor).checkCSAFs,
(*processor).checkMissing,
(*processor).checkInvalid,
(*processor).checkListing,
(*processor).checkWellknownMetadataReporter,
(*processor).checkDNSPathReporter,
@ -724,7 +726,29 @@ func (p *processor) checkMissing(string) error {
return nil
}
// checkListing wents over all found adivisories URLs and checks,
// checkInvalid wents over all found adivisories URLs and checks
// if file name confirms to standard.
func (p *processor) checkInvalid(string) error {
p.badDirListings.use()
var invalids []string
for f := range p.alreadyChecked {
if !util.ConfirmingFileName(filepath.Base(f)) {
invalids = append(invalids, f)
}
}
if len(invalids) > 0 {
sort.Strings(invalids)
p.badDirListings.add("advisories with invalid file names: %s",
strings.Join(invalids, ", "))
}
return nil
}
// checkListing wents over all found adivisories URLs and checks
// if their parent directory is listable.
func (p *processor) checkListing(string) error {