Skip to content

Commit

Permalink
Merge pull request #98 from future-architect/freebsd
Browse files Browse the repository at this point in the history
Enable to detect vulnerabilities on FreeBSD
  • Loading branch information
kotakanbe authored Jun 14, 2016
2 parents c209564 + 1718140 commit d9d0e62
Show file tree
Hide file tree
Showing 10 changed files with 323 additions and 181 deletions.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ type ServerInfo struct {
// Container Names or IDs
Containers []string

// userd internal
// used internal
LogMsgAnsiColor string // DebugLog Color
SudoOpt SudoOption
Container Container
Family string
}

// IsContainer returns whether this ServerInfo is about container
Expand Down
2 changes: 1 addition & 1 deletion models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ func (p PackageInfo) ToStringNewVersion() string {
return str
}

// DistroAdvisory has Amazon Linux AMI Security Advisory information.
// DistroAdvisory has Amazon Linux, RHEL, FreeBSD Security Advisory information.
type DistroAdvisory struct {
gorm.Model `json:"-"`
CveInfoID uint `json:"-"`
Expand Down
9 changes: 9 additions & 0 deletions report/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,15 @@ func distroLinks(cveInfo models.CveInfo, osFamily string) []distroLink {
},
// TODO Debian dsa
}
case "FreeBSD":
links := []distroLink{}
for _, advisory := range cveInfo.DistroAdvisories {
links = append(links, distroLink{
"FreeBSD-VuXML",
fmt.Sprintf(freeBSDVuXMLBaseURL, advisory.AdvisoryID),
})
}
return links
default:
return []distroLink{}
}
Expand Down
2 changes: 2 additions & 0 deletions report/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ const (

ubuntuSecurityBaseURL = "http://people.ubuntu.com/~ubuntu-security/cve"
debianTrackerBaseURL = "https://security-tracker.debian.org/tracker"

freeBSDVuXMLBaseURL = "https://vuxml.freebsd.org/freebsd/%s.html"
)

// ResultWriter Interface
Expand Down
4 changes: 2 additions & 2 deletions scan/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (o *debian) scanInstalledPackages() (packs []models.PackageInfo, err error)
lines := strings.Split(r.Stdout, "\n")
for _, line := range lines {
if trimmed := strings.TrimSpace(line); len(trimmed) != 0 {
name, version, err := o.parseScanedPackagesLine(trimmed)
name, version, err := o.parseScannedPackagesLine(trimmed)
if err != nil {
return nil, fmt.Errorf(
"Debian: Failed to parse package line: %s", line)
Expand All @@ -208,7 +208,7 @@ func (o *debian) scanInstalledPackages() (packs []models.PackageInfo, err error)
return
}

func (o *debian) parseScanedPackagesLine(line string) (name, version string, err error) {
func (o *debian) parseScannedPackagesLine(line string) (name, version string, err error) {
re, _ := regexp.Compile(`^([^\t']+)\t(.+)$`)
result := re.FindStringSubmatch(line)
if len(result) == 3 {
Expand Down
4 changes: 2 additions & 2 deletions scan/debian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/k0kubun/pp"
)

func TestParseScanedPackagesLineDebian(t *testing.T) {
func TestParseScannedPackagesLineDebian(t *testing.T) {

var packagetests = []struct {
in string
Expand All @@ -43,7 +43,7 @@ func TestParseScanedPackagesLineDebian(t *testing.T) {

d := newDebian(config.ServerInfo{})
for _, tt := range packagetests {
n, v, _ := d.parseScanedPackagesLine(tt.in)
n, v, _ := d.parseScannedPackagesLine(tt.in)
if n != tt.name {
t.Errorf("name: expected %s, actual %s", tt.name, n)
}
Expand Down
Loading

0 comments on commit d9d0e62

Please sign in to comment.