Skip to content

Commit

Permalink
Make rolie or directory listing mandatory (#409)
Browse files Browse the repository at this point in the history
* Changed infos to warnings and errors for Requirements 11-17 if said Requirements were not checked.

* Made a few more infos to warnings, slightly improved some messages in the reporters.

* Add explicite errors if badROLIEFeed and badFolders were not used.

---------

Co-authored-by: JanHoefelmeyer <[email protected]>
  • Loading branch information
JanHoefelmeyer and JanHoefelmeyer authored Aug 19, 2023
1 parent 8240798 commit 5c93590
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
15 changes: 13 additions & 2 deletions cmd/csaf_checker/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ func (p *processor) checkIndex(base string, mask whereType) error {
p.badIndices.error("Fetching %s failed. Status code %d (%s)",
index, res.StatusCode, res.Status)
} else {
p.badIndices.warn("Fetching index.txt failed: %v not found.", index)
p.badIndices.error("Fetching index.txt failed: %v not found.", index)
}
return errContinue
}
Expand Down Expand Up @@ -942,7 +942,7 @@ func (p *processor) checkChanges(base string, mask whereType) error {
p.badChanges.error("Fetching %s failed. Status code %d (%s)",
changes, res.StatusCode, res.Status)
} else {
p.badChanges.warn("Fetching changes.csv failed: %v not found.", changes)
p.badChanges.error("Fetching changes.csv failed: %v not found.", changes)
}
return errContinue
}
Expand Down Expand Up @@ -1039,6 +1039,13 @@ func (p *processor) checkCSAFs(_ string) error {
}
// check for service category document
p.serviceCheck(feeds)
} else {
p.badROLIEFeed.use()
p.badROLIEFeed.error("ROLIE feed based distribution was not used.")
p.badROLIECategory.use()
p.badROLIECategory.warn("No ROLIE category document found.")
p.badROLIEService.use()
p.badROLIEService.warn("No ROLIE service document found.")
}

// No rolie feeds -> try directory_urls.
Expand Down Expand Up @@ -1083,6 +1090,10 @@ func (p *processor) checkCSAFs(_ string) error {
}
}

if !p.badFolders.used() {
p.badFolders.use()
p.badFolders.error("No checks performed on whether files are within the right folders.")
}
return nil
}

Expand Down
18 changes: 5 additions & 13 deletions cmd/csaf_checker/reporters.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ func (r *dnsPathReporter) report(p *processor, domain *Domain) {

func (r *oneFolderPerYearReport) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badFolders.used() {
req.message(InfoType, "No checks if files are in right folders were performed.")
return
}
if len(p.badFolders) == 0 {
req.message(InfoType, "All CSAF files are in the right folders.")
return
Expand All @@ -302,7 +298,7 @@ func (r *oneFolderPerYearReport) report(p *processor, domain *Domain) {
func (r *indexReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badIndices.used() {
req.message(InfoType, "No index.txt checked.")
req.message(ErrorType, "No index.txt checked.")
return
}
if len(p.badIndices) == 0 {
Expand All @@ -315,7 +311,7 @@ func (r *indexReporter) report(p *processor, domain *Domain) {
func (r *changesReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badChanges.used() {
req.message(InfoType, "No changes.csv checked.")
req.message(ErrorType, "No changes.csv checked.")
return
}
if len(p.badChanges) == 0 {
Expand All @@ -328,7 +324,7 @@ func (r *changesReporter) report(p *processor, domain *Domain) {
func (r *directoryListingsReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badDirListings.used() {
req.message(InfoType, "No directory listings checked.")
req.message(WarnType, "No directory listings checked.")
return
}
if len(p.badDirListings) == 0 {
Expand All @@ -344,10 +340,6 @@ func (r *directoryListingsReporter) report(p *processor, domain *Domain) {
// of the "Requirement" struct as a result of that.
func (r *rolieFeedReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badROLIEFeed.used() {
req.message(InfoType, "No checks on the validity of ROLIE feeds performed.")
return
}
if len(p.badROLIEFeed) == 0 {
req.message(InfoType, "All checked ROLIE feeds validated fine.")
return
Expand All @@ -362,7 +354,7 @@ func (r *rolieFeedReporter) report(p *processor, domain *Domain) {
func (r *rolieServiceReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badROLIEService.used() {
req.message(InfoType, "ROLIE service document was not checked.")
req.message(WarnType, "ROLIE service document was not checked.")
return
}
if len(p.badROLIEService) == 0 {
Expand All @@ -381,7 +373,7 @@ func (r *rolieServiceReporter) report(p *processor, domain *Domain) {
func (r *rolieCategoryReporter) report(p *processor, domain *Domain) {
req := r.requirement(domain)
if !p.badROLIECategory.used() {
req.message(InfoType, "No checks on the existence of ROLIE category documents performed.")
req.message(WarnType, "No checks on the existence of ROLIE category documents performed.")
return
}
if len(p.badROLIECategory) == 0 {
Expand Down

0 comments on commit 5c93590

Please sign in to comment.