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

Improve writing ROLIE feed documents

* Add signature and two time has as link rel attributes to each rolie entry
   for provider and aggregator. Thus following CSAF 2.0 csd02. 
resolve #74
This commit is contained in:
Sascha L. Teichmann 2022-06-14 09:50:36 +02:00 committed by GitHub
parent 22b945a3c3
commit 589547fa94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 12 deletions

View file

@ -166,10 +166,12 @@ func (w *worker) writeROLIE(label string, summaries []summary) error {
Titel: s.summary.Title,
Published: csaf.TimeStamp(s.summary.InitialReleaseDate),
Updated: csaf.TimeStamp(s.summary.CurrentReleaseDate),
Link: []csaf.Link{{
Rel: "self",
HRef: csafURL,
}},
Link: []csaf.Link{
{Rel: "self", HRef: csafURL},
{Rel: "hash", HRef: csafURL + ".sha256"},
{Rel: "hash", HRef: csafURL + ".sha512"},
{Rel: "signature", HRef: csafURL + ".asc"},
},
Format: format,
Content: csaf.Content{
Type: "application/json",

View file

@ -88,7 +88,7 @@ func (w *worker) handleROLIE(
log.Printf("Loading ROLIE feed failed: %v.", err)
continue
}
files := resolveURLs(rfeed.Files(), feedBaseURL)
files := resolveURLs(rfeed.Files("self"), feedBaseURL)
if err := process(feed.TLPLabel, files); err != nil {
return err
}

View file

@ -545,7 +545,7 @@ func (p *processor) processROLIEFeed(feed string) error {
}
// Extract the CSAF files from feed.
files := rfeed.Files()
files := rfeed.Files("self")
if err := p.integrity(files, base, rolieMask, p.badProviderMetadata.add); err != nil &&
err != errContinue {

View file

@ -255,10 +255,12 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
e.Titel = ex.Title
e.Published = csaf.TimeStamp(ex.InitialReleaseDate)
e.Updated = csaf.TimeStamp(ex.CurrentReleaseDate)
e.Link = []csaf.Link{{
Rel: "self",
HRef: csafURL,
}}
e.Link = []csaf.Link{
{Rel: "self", HRef: csafURL},
{Rel: "hash", HRef: csafURL + ".sha256"},
{Rel: "hash", HRef: csafURL + ".sha512"},
{Rel: "signature", HRef: csafURL + ".asc"},
}
e.Format = csaf.Format{
Schema: "https://docs.oasis-open.org/csaf/csaf/v2.0/csaf_json_schema.json",
Version: "2.0",

View file

@ -104,11 +104,13 @@ func (rf *ROLIEFeed) EntryByID(id string) *Entry {
}
// Files extracts the files from the feed.
func (rf *ROLIEFeed) Files() []string {
func (rf *ROLIEFeed) Files(filter string) []string {
var files []string
for _, f := range rf.Feed.Entry {
for i := range f.Link {
files = append(files, f.Link[i].HRef)
if link := &f.Link[i]; link.Rel == filter {
files = append(files, link.HRef)
}
}
}
return files