From 4a07974b540c26220b15441eb6e16852ce22ecb6 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Fri, 7 Oct 2016 08:26:36 -0400 Subject: [PATCH] Fixed bug with parsing update line on CentOS/RHEL --- scan/redhat.go | 2 +- scan/redhat_test.go | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/scan/redhat.go b/scan/redhat.go index 21411cacdb..71d37668ea 100644 --- a/scan/redhat.go +++ b/scan/redhat.go @@ -407,7 +407,7 @@ func (o *redhat) parseYumCheckUpdateLines(stdout string) (results models.Package func (o *redhat) parseYumCheckUpdateLine(line string) (models.PackageInfo, error) { fields := strings.Fields(line) - if len(fields) != 3 { + if len(fields) < 3 { return models.PackageInfo{}, fmt.Errorf("Unknown format: %s", line) } splitted := strings.Split(fields[0], ".") diff --git a/scan/redhat_test.go b/scan/redhat_test.go index 9bd87f2665..60a5df7cd4 100644 --- a/scan/redhat_test.go +++ b/scan/redhat_test.go @@ -616,6 +616,7 @@ Obsoleting Packages python-libs.i686 2.6.6-64.el6 rhui-REGION-rhel-server-releases python-ordereddict.noarch 1.1-3.el6ev installed bind-utils.x86_64 30:9.3.6-25.P1.el5_11.8 updates +pytalloc.x86_64 2.0.7-2.el6 @CentOS 6.5/6.5 ` r.Packages = []models.PackageInfo{ @@ -644,6 +645,11 @@ bind-utils.x86_64 30:9.3.6-25.P1.el5_11.8 updates Version: "1.0", Release: "1", }, + { + Name: "pytalloc", + Version: "2.0.1", + Release: "0", + }, } var tests = []struct { in string @@ -687,6 +693,13 @@ bind-utils.x86_64 30:9.3.6-25.P1.el5_11.8 updates NewVersion: "9.3.6", NewRelease: "25.P1.el5_11.8", }, + { + Name: "pytalloc", + Version: "2.0.1", + Release: "0", + NewVersion: "2.0.7", + NewRelease: "2.el6", + }, }, }, }