Skip to content

Commit

Permalink
Merge pull request #156 from future-architect/add-testcase-153
Browse files Browse the repository at this point in the history
Add testcases for #153
  • Loading branch information
kotakanbe authored Aug 23, 2016
2 parents 30f7527 + d8dc365 commit a224f0b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion scan/debian.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ func (o *debian) scanPackageCveIDs(pack models.PackageInfo) ([]string, error) {
return nil, nil

}
// No error will be returned. Only logging.
return o.getCveIDParsingChangelog(r.Stdout, pack.Name, pack.Version)
}

Expand All @@ -579,7 +580,7 @@ func (o *debian) getCveIDParsingChangelog(changelog string,
return
}

//TODO report as unable to parse changelog.
// Only logging the error.
o.log.Error(err)
return []string{}, nil
}
Expand Down
10 changes: 5 additions & 5 deletions scan/debian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestParseScannedPackagesLineDebian(t *testing.T) {

}

func TestgetCveIDParsingChangelog(t *testing.T) {
func TestGetCveIDParsingChangelog(t *testing.T) {

var tests = []struct {
in []string
Expand Down Expand Up @@ -86,12 +86,11 @@ systemd (227-1) unstable; urgency=medium`,
"CVE-2015-3210",
},
},

{
// ver
[]string{
"libpcre3",
"2:8.38-1ubuntu1",
"2:8.35-7.1ubuntu1",
`pcre3 (2:8.38-2) unstable; urgency=low
pcre3 (2:8.38-1) unstable; urgency=low
pcre3 (2:8.35-8) unstable; urgency=low
Expand All @@ -110,7 +109,6 @@ pcre3 (2:8.35-7) unstable; urgency=medium`,
"CVE-2015-3210",
},
},

{
// ver-ubuntu3
[]string{
Expand Down Expand Up @@ -151,7 +149,7 @@ sysvinit (2.88dsf-57) unstable; urgency=low`,
util-linux (2.27.1-3) unstable; urgency=medium
CVE-2015-2325: heap buffer overflow in compile_branch(). (Closes: #781795)
CVE-2015-2326: heap buffer overflow in pcre_compile2(). (Closes: #783285)
CVE-2015-3210: heap buffer overflow in pcre_compile2() /
CVE-2015-3210: CVE-2016-1000000heap buffer overflow in pcre_compile2() /
util-linux (2.27.1-2) unstable; urgency=medium
util-linux (2.27.1-1ubuntu4) xenial; urgency=medium
util-linux (2.27.1-1ubuntu3) xenial; urgency=medium
Expand All @@ -178,6 +176,7 @@ util-linux (2.26.2-6) unstable; urgency=medium`,
"CVE-2015-2325",
"CVE-2015-2326",
"CVE-2015-3210",
"CVE-2016-1000000",
},
},
}
Expand All @@ -187,6 +186,7 @@ util-linux (2.26.2-6) unstable; urgency=medium`,
actual, _ := d.getCveIDParsingChangelog(tt.in[2], tt.in[0], tt.in[1])
if len(actual) != len(tt.expected) {
t.Errorf("Len of return array are'nt same. expected %#v, actual %#v", tt.expected, actual)
t.Errorf(pp.Sprintf("%s", tt.in))
continue
}
for i := range tt.expected {
Expand Down
4 changes: 2 additions & 2 deletions scan/redhat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ func TestParseYumUpdateinfoLineToGetCveIDs(t *testing.T) {
[]string{"CVE-2015-0278"},
},
{
": 1195457 - nodejs-0.10.35 causes undefined symbolsCVE-2015-0278, CVE-2015-0278, CVE-2015-0277",
": 1195457 - nodejs-0.10.35 causes undefined symbolsCVE-2015-0278, CVE-2015-0278, CVE-2015-02770000000 ",
[]string{
"CVE-2015-0278",
"CVE-2015-0278",
"CVE-2015-0277",
"CVE-2015-02770000000",
},
},
}
Expand Down

0 comments on commit a224f0b

Please sign in to comment.