Skip to content

Commit

Permalink
Merge pull request #30 from future-architect/fix_error_while_parse_yu…
Browse files Browse the repository at this point in the history
…m_check_update_obsoleting_line

Fix error while parsing yum check-update #24
  • Loading branch information
kotakanbe committed Apr 14, 2016
2 parents 929d561 + cd9cbd7 commit 9d64f03
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scan/redhat.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func (o *redhat) scanUnsecurePackagesUsingYumCheckUpdate() (CvePacksList, error)
if err != nil {
return nil, fmt.Errorf("Failed to parse %s. err: %s", cmd, err)
}
o.log.Debugf("%s", pp.Sprintf("%s", packInfoList))
o.log.Debugf("%s", pp.Sprintf("%v", packInfoList))

// Collect CVE-IDs in changelog
type PackInfoCveIDs struct {
Expand Down Expand Up @@ -409,9 +409,12 @@ func (o *redhat) parseYumCheckUpdateLines(stdout string) (results models.Package
continue
}
if needToParse {
if strings.HasPrefix(line, "Obsoleting") {
continue
}
candidate, err := o.parseYumCheckUpdateLine(line)
if err != nil {
return models.PackageInfoList{}, err
return results, err
}

installed, found := o.Packages.FindByName(candidate.Name)
Expand Down
30 changes: 29 additions & 1 deletion scan/redhat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,11 @@ Loading mirror speeds from cached hostfile
audit-libs.x86_64 2.3.7-5.el6 base
bash.x86_64 4.1.2-33.el6_7.1 updates
`
Obsoleting Packages
python-libs.i686 2.6.6-64.el6 rhui-REGION-rhel-server-releases
python-ordereddict.noarch 1.1-3.el6ev installed
`

r.Packages = []models.PackageInfo{
{
Name: "audit-libs",
Expand All @@ -568,6 +572,16 @@ bash.x86_64 4.1.2-33.el6_7.1 updates
Version: "4.1.1",
Release: "33",
},
{
Name: "python-libs",
Version: "2.6.0",
Release: "1.1-0",
},
{
Name: "python-ordereddict",
Version: "1.0",
Release: "1",
},
}
var tests = []struct {
in string
Expand All @@ -590,6 +604,20 @@ bash.x86_64 4.1.2-33.el6_7.1 updates
NewVersion: "4.1.2",
NewRelease: "33.el6_7.1",
},
{
Name: "python-libs",
Version: "2.6.0",
Release: "1.1-0",
NewVersion: "2.6.6",
NewRelease: "64.el6",
},
{
Name: "python-ordereddict",
Version: "1.0",
Release: "1",
NewVersion: "1.1",
NewRelease: "3.el6ev",
},
},
},
}
Expand Down

0 comments on commit 9d64f03

Please sign in to comment.