mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Add another layer aound the ROLIE feed documents.
This commit is contained in:
parent
9e13831a6f
commit
4fc6bc5509
3 changed files with 20 additions and 13 deletions
|
|
@ -490,7 +490,7 @@ func (p *processor) processROLIEFeed(feed string) error {
|
|||
|
||||
// Extract the CSAF files from feed.
|
||||
var files []string
|
||||
for _, f := range rfeed.Entry {
|
||||
for _, f := range rfeed.Feed.Entry {
|
||||
for i := range f.Link {
|
||||
files = append(files, f.Link[i].HRef)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,16 +226,18 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
|
|||
// Create new if does not exists.
|
||||
if rolie == nil {
|
||||
rolie = &csaf.ROLIEFeed{
|
||||
Feed: csaf.FeedData{
|
||||
ID: "csaf-feed-tlp-" + ts,
|
||||
Title: "CSAF feed (TLP:" + string(tlpLabel) + ")",
|
||||
Link: []csaf.Link{{
|
||||
Rel: "rel",
|
||||
HRef: string(feedURL),
|
||||
}},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
rolie.Updated = csaf.TimeStamp(time.Now())
|
||||
rolie.Feed.Updated = csaf.TimeStamp(time.Now())
|
||||
|
||||
year := strconv.Itoa(ex.initialReleaseDate.Year())
|
||||
|
||||
|
|
@ -245,7 +247,7 @@ func (c *controller) upload(r *http.Request) (interface{}, error) {
|
|||
e := rolie.EntryByID(ex.id)
|
||||
if e == nil {
|
||||
e = &csaf.Entry{ID: ex.id}
|
||||
rolie.Entry = append(rolie.Entry, e)
|
||||
rolie.Feed.Entry = append(rolie.Feed.Entry, e)
|
||||
}
|
||||
|
||||
e.Titel = ex.title
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ type Entry struct {
|
|||
Format Format `json:"format"`
|
||||
}
|
||||
|
||||
// ROLIEFeed is a ROLIE feed.
|
||||
type ROLIEFeed struct {
|
||||
// FeedData is the contetn of the ROLIE feed.
|
||||
type FeedData struct {
|
||||
ID string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Link []Link `json:"link,omitempty"`
|
||||
|
|
@ -68,6 +68,11 @@ type ROLIEFeed struct {
|
|||
Entry []*Entry `json:"entry,omitempty"`
|
||||
}
|
||||
|
||||
// ROLIEFeed is a ROLIE feed.
|
||||
type ROLIEFeed struct {
|
||||
Feed FeedData `json:"feed"`
|
||||
}
|
||||
|
||||
// LoadROLIEFeed loads a ROLIE feed from a reader.
|
||||
func LoadROLIEFeed(r io.Reader) (*ROLIEFeed, error) {
|
||||
dec := json.NewDecoder(r)
|
||||
|
|
@ -90,7 +95,7 @@ func (rf *ROLIEFeed) WriteTo(w io.Writer) (int64, error) {
|
|||
// EntryByID looks up an entry by its ID.
|
||||
// Returns nil if no such entry was found.
|
||||
func (rf *ROLIEFeed) EntryByID(id string) *Entry {
|
||||
for _, entry := range rf.Entry {
|
||||
for _, entry := range rf.Feed.Entry {
|
||||
if entry.ID == id {
|
||||
return entry
|
||||
}
|
||||
|
|
@ -101,7 +106,7 @@ func (rf *ROLIEFeed) EntryByID(id string) *Entry {
|
|||
// SortEntriesByUpdated sorts all the entries in the feed
|
||||
// by their update times.
|
||||
func (rf *ROLIEFeed) SortEntriesByUpdated() {
|
||||
entries := rf.Entry
|
||||
entries := rf.Feed.Entry
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
return time.Time(entries[j].Updated).Before(time.Time(entries[i].Updated))
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue