mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 05:40:11 +01:00
Empty rolie (#357)
* Create ROLIE feed if summaries are empty * Formatting, Remove sorting of 0 elements * Handle minimum entry length error as warning in checker * Use empty array instead of creating an empty array to reference * Change schema to allow for empty entry arrays * Use https://raw.githubusercontent.com/oasis-tcs/csaf/81b2663697958bc5f85d14372712a40028fb8338/csaf_2.0/json_schema/ROLIE_feed_json_schema.json as schema for ROLIE feeds * Change label name from empty to undefined * Change default of create_service_document for csaf_provider to true * Config * Count entries in csaf-checker, warn if there are none. * Add Comments to csaf/rolie.go's CountEntries function * Delete index.txt and changes.csv in aggregator if there are no entries. * Create an empty ROLIE feed document when setting up folders during create * nit: set update time stamp in structure init. * Instantiate label checker only once. * Ignore domain not having roles. * provider: Create empty entry section in ROLIE feed. * Stop check for domain if PMD check fails * Add missing continue statement * Report missing ROLIE feed entries in ROLIE feed, not Provider Metadata * Do not ommit empty entries in ROLIE feeds. * Fixed error handling problem introduced by faulty merge. Removed unused errStop handling while there. --------- Co-authored-by: JanHoefelmeyer <hoefelmeyer.jan@gmail.com> Co-authored-by: Sascha L. Teichmann <sascha.teichmann@intevation.de> Co-authored-by: JanHoefelmeyer <Jan Höfelmeyer jhoefelmeyer@intevation.de>
This commit is contained in:
parent
540d02d367
commit
b61912410a
8 changed files with 194 additions and 43 deletions
|
|
@ -86,8 +86,6 @@ type reporter interface {
|
|||
var (
|
||||
// errContinue indicates that the current check should continue.
|
||||
errContinue = errors.New("continue")
|
||||
// errStop indicates that the current check should stop.
|
||||
errStop = errors.New("stop")
|
||||
)
|
||||
|
||||
type whereType byte
|
||||
|
|
@ -262,10 +260,9 @@ func (p *processor) run(domains []string) (*Report, error) {
|
|||
continue
|
||||
}
|
||||
if err := p.checkDomain(d); err != nil {
|
||||
if err == errContinue || err == errStop {
|
||||
continue
|
||||
}
|
||||
return nil, err
|
||||
log.Printf("Failed to find valid provider-metadata.json for domain %s: %v. "+
|
||||
"Continuing with next domain.", d, err)
|
||||
continue
|
||||
}
|
||||
domain := &Domain{Name: d}
|
||||
|
||||
|
|
@ -354,17 +351,17 @@ func (p *processor) domainChecks(domain string) []func(*processor, string) error
|
|||
return checks
|
||||
}
|
||||
|
||||
// checkDomain runs a set of domain specific checks on a given
|
||||
// domain.
|
||||
func (p *processor) checkDomain(domain string) error {
|
||||
|
||||
for _, check := range p.domainChecks(domain) {
|
||||
if err := check(p, domain); err != nil && err != errContinue {
|
||||
if err == errStop {
|
||||
return nil
|
||||
if err := check(p, domain); err != nil {
|
||||
if err == errContinue {
|
||||
continue
|
||||
}
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -503,12 +500,15 @@ func (p *processor) rolieFeedEntries(feed string) ([]csaf.AdvisoryFile, error) {
|
|||
var rolieDoc any
|
||||
err = json.NewDecoder(bytes.NewReader(all)).Decode(&rolieDoc)
|
||||
return rfeed, rolieDoc, err
|
||||
|
||||
}()
|
||||
if err != nil {
|
||||
p.badProviderMetadata.error("Loading ROLIE feed failed: %v.", err)
|
||||
return nil, errContinue
|
||||
}
|
||||
|
||||
if rfeed.CountEntries() == 0 {
|
||||
p.badROLIEFeed.warn("No entries in %s", feed)
|
||||
}
|
||||
errors, err := csaf.ValidateROLIE(rolieDoc)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
@ -1208,8 +1208,6 @@ func (p *processor) checkProviderMetadata(domain string) bool {
|
|||
}
|
||||
|
||||
if !lpmd.Valid() {
|
||||
p.badProviderMetadata.error("No valid provider-metadata.json found.")
|
||||
p.badProviderMetadata.error("STOPPING here - cannot perform other checks.")
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue