mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Add fetch of service category document from pmd url
This commit is contained in:
parent
d7fb52b735
commit
380ccfdf5a
2 changed files with 17 additions and 8 deletions
|
|
@ -1006,6 +1006,8 @@ func (p *processor) checkCSAFs(_ string) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
// check for service category document
|
||||
p.serviceCheck(feeds)
|
||||
}
|
||||
|
||||
// No rolie feeds -> try directory_urls.
|
||||
|
|
|
|||
|
|
@ -265,23 +265,30 @@ func containsAllKeys[K comparable, V any](m1, m2 map[K]V) bool {
|
|||
return true
|
||||
}
|
||||
|
||||
func (p *processor) serviceCheck(url string, feeds [][]csaf.Feed) error {
|
||||
func (p *processor) serviceCheck(feeds [][]csaf.Feed) error {
|
||||
// service category document should be next to the pmd
|
||||
pmdURL, err := url.Parse(p.pmdURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
baseURL, err := util.BaseURL(pmdURL)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
urls := baseURL + "service.json"
|
||||
|
||||
// load service document
|
||||
p.badROLIEservice.use()
|
||||
if url == "" {
|
||||
p.badROLIEservice.warn("No ROLIE service document found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
client := p.httpClient()
|
||||
res, err := client.Get(url)
|
||||
res, err := client.Get(urls)
|
||||
if err != nil {
|
||||
p.badROLIEservice.error("Cannot fetch rolie service document %s: %v", url, err)
|
||||
p.badROLIEservice.error("Cannot fetch rolie service document %s: %v", urls, err)
|
||||
return errContinue
|
||||
}
|
||||
if res.StatusCode != http.StatusOK {
|
||||
p.badROLIEservice.warn("Fetching %s failed. Status code %d (%s)",
|
||||
url, res.StatusCode, res.Status)
|
||||
urls, res.StatusCode, res.Status)
|
||||
return errContinue
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue