mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Add ROLIE category document check for existence
This commit is contained in:
parent
051de5194d
commit
d91af558ce
3 changed files with 36 additions and 2 deletions
|
|
@ -69,6 +69,7 @@ type processor struct {
|
|||
badDirListings topicMessages
|
||||
badROLIEfeed topicMessages
|
||||
badROLIEservice topicMessages
|
||||
badROLIEcategory topicMessages
|
||||
|
||||
expr *util.PathEval
|
||||
}
|
||||
|
|
@ -236,6 +237,7 @@ func (p *processor) clean() {
|
|||
p.badDirListings.reset()
|
||||
p.badROLIEfeed.reset()
|
||||
p.badROLIEservice.reset()
|
||||
p.badROLIEcategory.reset()
|
||||
p.labelChecker = nil
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -358,8 +358,18 @@ func (r *rolieServiceReporter) report(p *processor, domain *Domain) {
|
|||
// documents by certain criteria
|
||||
// and sets the "message" field value
|
||||
// of the "Requirement" struct as a result of that.
|
||||
func (r *rolieCategoryReporter) report(_ *processor, _ *Domain) {
|
||||
// TODO
|
||||
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.")
|
||||
return
|
||||
}
|
||||
if len(p.badROLIEcategory) == 0 {
|
||||
req.message(InfoType, "All checked ROLIE category documents exist.")
|
||||
return
|
||||
}
|
||||
req.Messages = p.badROLIEcategory
|
||||
|
||||
}
|
||||
|
||||
func (r *integrityReporter) report(p *processor, domain *Domain) {
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ package main
|
|||
import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/csaf-poc/csaf_distribution/v2/csaf"
|
||||
"github.com/csaf-poc/csaf_distribution/v2/util"
|
||||
|
|
@ -159,6 +160,7 @@ func (p *processor) processROLIEFeeds(feeds [][]csaf.Feed) error {
|
|||
}
|
||||
|
||||
label := tlpLabel(feed.TLPLabel)
|
||||
p.categoryCheck(feedBase, label)
|
||||
|
||||
p.labelChecker = &rolieLabelChecker{
|
||||
feedURL: feedURL.String(),
|
||||
|
|
@ -265,6 +267,26 @@ func containsAllKeys[K comparable, V any](m1, m2 map[K]V) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (p *processor) categoryCheck(folderURL string, label csaf.TLPLabel) error {
|
||||
labelname := strings.ToLower(string(label))
|
||||
urlrc := folderURL + "category-" + labelname + ".json"
|
||||
|
||||
p.badROLIEcategory.use()
|
||||
client := p.httpClient()
|
||||
res, err := client.Get(urlrc)
|
||||
if err != nil {
|
||||
p.badROLIEcategory.error("Cannot fetch rolie category document %s: %v", urlrc, err)
|
||||
return errContinue
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
p.badROLIEcategory.warn("Fetching %s failed. Status code %d (%s)",
|
||||
urlrc, res.StatusCode, res.Status)
|
||||
return errContinue
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *processor) serviceCheck(feeds [][]csaf.Feed) error {
|
||||
// service category document should be next to the pmd
|
||||
pmdURL, err := url.Parse(p.pmdURL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue