-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
fedora.go
89 lines (79 loc) · 2.24 KB
/
fedora.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package fedora
import (
"fmt"
"strings"
"time"
"github.com/spf13/viper"
"github.com/vulsio/goval-dictionary/models"
"github.com/vulsio/goval-dictionary/models/util"
)
// ConvertToModel Convert OVAL to models
func ConvertToModel(data *Updates) (defs []models.Definition) {
for _, update := range data.UpdateList {
if strings.Contains(update.Description, "** REJECT **") {
continue
}
cves := []models.Cve{}
for _, cveID := range update.CVEIDs {
cves = append(cves, models.Cve{
CveID: cveID,
Href: fmt.Sprintf("https://cve.mitre.org/cgi-bin/cvename.cgi?name=%s", cveID),
})
}
packs := []models.Package{}
for _, pack := range update.Packages {
packs = append(packs, models.Package{
Name: pack.Name,
Version: fmt.Sprintf("%s:%s-%s", pack.Epoch, pack.Version, pack.Release),
Arch: pack.Arch,
ModularityLabel: update.ModularityLabel,
})
}
refs := []models.Reference{}
bs := []models.Bugzilla{}
for _, ref := range update.References {
refs = append(refs, models.Reference{
Source: ref.Type,
RefID: ref.ID,
RefURL: ref.Href,
})
if ref.Type == "bugzilla" {
bs = append(bs, models.Bugzilla{
BugzillaID: ref.ID,
URL: ref.Href,
Title: ref.Title,
})
}
}
issuedAt := util.ParsedOrDefaultTime([]string{"2006-01-02 15:04:05"}, update.Issued.Date)
updatedAt := util.ParsedOrDefaultTime([]string{"2006-01-02 15:04:05"}, update.Updated.Date)
def := models.Definition{
DefinitionID: "def-" + update.ID,
Title: update.ID,
Description: update.Description,
Advisory: models.Advisory{
Severity: update.Severity,
Cves: cves,
Bugzillas: bs,
AffectedCPEList: []models.Cpe{},
Issued: issuedAt,
Updated: updatedAt,
},
Debian: nil,
AffectedPacks: packs,
References: refs,
}
if viper.GetBool("no-details") {
def.Title = ""
def.Description = ""
def.Advisory.Severity = ""
def.Advisory.Bugzillas = []models.Bugzilla{}
def.Advisory.AffectedCPEList = []models.Cpe{}
def.Advisory.Issued = time.Time{}
def.Advisory.Updated = time.Time{}
def.References = []models.Reference{}
}
defs = append(defs, def)
}
return
}