diff --git a/contrib/check-openvz-mirror-with-clair/main.go b/contrib/check-openvz-mirror-with-clair/main.go index 8b26a524..e3662309 100644 --- a/contrib/check-openvz-mirror-with-clair/main.go +++ b/contrib/check-openvz-mirror-with-clair/main.go @@ -48,9 +48,9 @@ type ClairAPI struct { } type AddLayoutRequestAPI struct { - ID string `json:"ID"` - Path string `json:"Path"` - ParantID string `json:"ParantID"` + ID string `json:"ID"` + Path string `json:"Path"` + ParentID string `json:"ParentID"` ImageFormat string `json:"ImageFormat"` } @@ -333,7 +333,7 @@ func CheckPriority(priority string) (result string, err error) { return "", err } if match { - result = strings.ToUpper(string(priority[0])) + strings.ToLower(priority[1:len(priority)]) + result = strings.ToUpper(string(priority[0])) + strings.ToLower(priority[1:]) return } return "", errors.New("Unknown priority " + priority) diff --git a/database/pgsql/complex_test.go b/database/pgsql/complex_test.go index 12f0b72a..9660a5ec 100644 --- a/database/pgsql/complex_test.go +++ b/database/pgsql/complex_test.go @@ -83,7 +83,7 @@ func TestRaceAffects(t *testing.T) { Name: uuid.New(), Namespace: feature.Namespace, FixedIn: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: feature, Version: types.NewVersionUnsafe(strconv.Itoa(version)), }, diff --git a/database/pgsql/feature_test.go b/database/pgsql/feature_test.go index 73b6478f..251fca6c 100644 --- a/database/pgsql/feature_test.go +++ b/database/pgsql/feature_test.go @@ -55,25 +55,25 @@ func TestInsertFeature(t *testing.T) { // Insert invalid FeatureVersion. for _, invalidFeatureVersion := range []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{}, Version: types.NewVersionUnsafe("1.0"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{}, Name: "TestInsertFeature2", }, Version: types.NewVersionUnsafe("1.0"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "TestInsertFeatureNamespace2"}, Name: "TestInsertFeature2", }, Version: types.NewVersionUnsafe(""), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "TestInsertFeatureNamespace2"}, Name: "TestInsertFeature2", diff --git a/database/pgsql/layer.go b/database/pgsql/layer.go index d5e2e88c..e19b371d 100644 --- a/database/pgsql/layer.go +++ b/database/pgsql/layer.go @@ -43,7 +43,7 @@ func (pgSQL *pgSQL) FindLayer(name string, withFeatures, withVulnerabilities boo t := time.Now() err := pgSQL.QueryRow(searchLayer, name). Scan(&layer.ID, &layer.Name, &layer.EngineVersion, &parentID, &parentName, &namespaceID, - &namespaceName) + &namespaceName) observeQueryTime("FindLayer", "searchLayer", t) if err != nil { diff --git a/database/pgsql/layer_test.go b/database/pgsql/layer_test.go index 40fd42fa..dec0384c 100644 --- a/database/pgsql/layer_test.go +++ b/database/pgsql/layer_test.go @@ -124,9 +124,9 @@ func TestInsertLayer(t *testing.T) { func testInsertLayerInvalid(t *testing.T, datastore database.Datastore) { invalidLayers := []database.Layer{ - database.Layer{}, - database.Layer{Name: "layer0", Parent: &database.Layer{}}, - database.Layer{Name: "layer0", Parent: &database.Layer{Name: "UnknownLayer"}}, + {}, + {Name: "layer0", Parent: &database.Layer{}}, + {Name: "layer0", Parent: &database.Layer{Name: "UnknownLayer"}}, } for _, invalidLayer := range invalidLayers { @@ -180,23 +180,23 @@ func testInsertLayerTree(t *testing.T, datastore database.Datastore) { } layers := []database.Layer{ - database.Layer{ + { Name: "TestInsertLayer1", }, - database.Layer{ + { Name: "TestInsertLayer2", Parent: &database.Layer{Name: "TestInsertLayer1"}, Namespace: &database.Namespace{Name: "TestInsertLayerNamespace1"}, }, // This layer changes the namespace and adds Features. - database.Layer{ + { Name: "TestInsertLayer3", Parent: &database.Layer{Name: "TestInsertLayer2"}, Namespace: &database.Namespace{Name: "TestInsertLayerNamespace2"}, Features: []database.FeatureVersion{f1, f2, f3}, }, // This layer covers the case where the last layer doesn't provide any new Feature. - database.Layer{ + { Name: "TestInsertLayer4a", Parent: &database.Layer{Name: "TestInsertLayer3"}, Features: []database.FeatureVersion{f1, f2, f3}, @@ -204,7 +204,7 @@ func testInsertLayerTree(t *testing.T, datastore database.Datastore) { // This layer covers the case where the last layer provides Features. // It also modifies the Namespace ("upgrade") but keeps some Features not upgraded, their // Namespaces should then remain unchanged. - database.Layer{ + { Name: "TestInsertLayer4b", Parent: &database.Layer{Name: "TestInsertLayer3"}, Namespace: &database.Namespace{Name: "TestInsertLayerNamespace3"}, diff --git a/database/pgsql/namespace_test.go b/database/pgsql/namespace_test.go index c5da400b..be8de686 100644 --- a/database/pgsql/namespace_test.go +++ b/database/pgsql/namespace_test.go @@ -15,9 +15,9 @@ package pgsql import ( + "fmt" "testing" - "fmt" - + "github.com/coreos/clair/database" "github.com/stretchr/testify/assert" ) diff --git a/database/pgsql/notification_test.go b/database/pgsql/notification_test.go index 23c8ede7..787cf567 100644 --- a/database/pgsql/notification_test.go +++ b/database/pgsql/notification_test.go @@ -36,7 +36,7 @@ func TestNotification(t *testing.T) { l1 := database.Layer{ Name: "TestNotificationLayer1", Features: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f1, Version: types.NewVersionUnsafe("0.1"), }, @@ -46,7 +46,7 @@ func TestNotification(t *testing.T) { l2 := database.Layer{ Name: "TestNotificationLayer2", Features: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f1, Version: types.NewVersionUnsafe("0.2"), }, @@ -56,7 +56,7 @@ func TestNotification(t *testing.T) { l3 := database.Layer{ Name: "TestNotificationLayer3", Features: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f1, Version: types.NewVersionUnsafe("0.3"), }, @@ -66,7 +66,7 @@ func TestNotification(t *testing.T) { l4 := database.Layer{ Name: "TestNotificationLayer4", Features: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f2, Version: types.NewVersionUnsafe("0.1"), }, @@ -88,7 +88,7 @@ func TestNotification(t *testing.T) { Link: "TestNotificationLink1", Severity: "Unknown", FixedIn: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f1, Version: types.NewVersionUnsafe("1.0"), }, @@ -148,11 +148,11 @@ func TestNotification(t *testing.T) { v1b := v1 v1b.Severity = types.High v1b.FixedIn = []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: f1, Version: types.MinVersion, }, - database.FeatureVersion{ + { Feature: f2, Version: types.MaxVersion, }, diff --git a/database/pgsql/vulnerability.go b/database/pgsql/vulnerability.go index 106f6935..ca53801a 100644 --- a/database/pgsql/vulnerability.go +++ b/database/pgsql/vulnerability.go @@ -465,7 +465,7 @@ func (pgSQL *pgSQL) DeleteVulnerabilityFix(vulnerabilityNamespace, vulnerability Name: vulnerabilityNamespace, }, FixedIn: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Name: featureName, Namespace: database.Namespace{ diff --git a/database/pgsql/vulnerability_test.go b/database/pgsql/vulnerability_test.go index c47cb74f..8177fdb0 100644 --- a/database/pgsql/vulnerability_test.go +++ b/database/pgsql/vulnerability_test.go @@ -44,11 +44,11 @@ func TestFindVulnerability(t *testing.T) { Severity: types.High, Namespace: database.Namespace{Name: "debian:7"}, FixedIn: []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{Name: "openssl"}, Version: types.NewVersionUnsafe("2.0"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "libssl"}, Version: types.NewVersionUnsafe("1.9-abc"), }, @@ -161,30 +161,30 @@ func TestInsertVulnerability(t *testing.T) { // Insert invalid vulnerabilities. for _, vulnerability := range []database.Vulnerability{ - database.Vulnerability{ + { Name: "", Namespace: n1, FixedIn: []database.FeatureVersion{f1}, Severity: types.Unknown, }, - database.Vulnerability{ + { Name: "TestInsertVulnerability0", Namespace: database.Namespace{}, FixedIn: []database.FeatureVersion{f1}, Severity: types.Unknown, }, - database.Vulnerability{ + { Name: "TestInsertVulnerability0-", Namespace: database.Namespace{}, FixedIn: []database.FeatureVersion{f1}, }, - database.Vulnerability{ + { Name: "TestInsertVulnerability0", Namespace: n1, FixedIn: []database.FeatureVersion{f1}, Severity: types.Priority(""), }, - database.Vulnerability{ + { Name: "TestInsertVulnerability0", Namespace: n1, FixedIn: []database.FeatureVersion{f2}, diff --git a/updater/fetchers/debian/debian_test.go b/updater/fetchers/debian/debian_test.go index e2b2eb52..42e81d3c 100644 --- a/updater/fetchers/debian/debian_test.go +++ b/updater/fetchers/debian/debian_test.go @@ -39,14 +39,14 @@ func TestDebianParser(t *testing.T) { assert.Equal(t, "This vulnerability is not very dangerous.", vulnerability.Description) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:8"}, Name: "aptdaemon", }, Version: types.MaxVersion, }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:unstable"}, @@ -65,21 +65,21 @@ func TestDebianParser(t *testing.T) { assert.Equal(t, "But this one is very dangerous.", vulnerability.Description) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:8"}, Name: "aptdaemon", }, Version: types.NewVersionUnsafe("0.7.0"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:unstable"}, Name: "aptdaemon", }, Version: types.NewVersionUnsafe("0.7.0"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:8"}, Name: "asterisk", @@ -97,7 +97,7 @@ func TestDebianParser(t *testing.T) { assert.Equal(t, "Un-affected packages.", vulnerability.Description) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "debian:8"}, Name: "asterisk", diff --git a/updater/fetchers/rhel/rhel_test.go b/updater/fetchers/rhel/rhel_test.go index dac55372..90998c78 100644 --- a/updater/fetchers/rhel/rhel_test.go +++ b/updater/fetchers/rhel/rhel_test.go @@ -39,21 +39,21 @@ func TestRHELParser(t *testing.T) { assert.Equal(t, `Xerces-C is a validating XML parser written in a portable subset of C++. A flaw was found in the way the Xerces-C XML parser processed certain XML documents. A remote attacker could provide specially crafted XML input that, when parsed by an application using Xerces-C, would cause that application to crash.`, vulnerabilities[0].Description) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "centos:7"}, Name: "xerces-c", }, Version: types.NewVersionUnsafe("3.1.1-7.el7_1"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "centos:7"}, Name: "xerces-c-devel", }, Version: types.NewVersionUnsafe("3.1.1-7.el7_1"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "centos:7"}, Name: "xerces-c-doc", @@ -77,14 +77,14 @@ func TestRHELParser(t *testing.T) { assert.Equal(t, `Mozilla Firefox is an open source web browser. XULRunner provides the XUL Runtime environment for Mozilla Firefox. Several flaws were found in the processing of malformed web content. A web page containing malicious content could cause Firefox to crash or, potentially, execute arbitrary code with the privileges of the user running Firefox.`, vulnerabilities[0].Description) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "centos:6"}, Name: "firefox", }, Version: types.NewVersionUnsafe("38.1.0-1.el6_6"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "centos:7"}, Name: "firefox", diff --git a/updater/fetchers/ubuntu/ubuntu.go b/updater/fetchers/ubuntu/ubuntu.go index 67b4839a..23850fb4 100644 --- a/updater/fetchers/ubuntu/ubuntu.go +++ b/updater/fetchers/ubuntu/ubuntu.go @@ -43,30 +43,30 @@ const ( var ( ubuntuIgnoredReleases = map[string]struct{}{ - "upstream": struct{}{}, - "devel": struct{}{}, + "upstream": {}, + "devel": {}, - "dapper": struct{}{}, - "edgy": struct{}{}, - "feisty": struct{}{}, - "gutsy": struct{}{}, - "hardy": struct{}{}, - "intrepid": struct{}{}, - "jaunty": struct{}{}, - "karmic": struct{}{}, - "lucid": struct{}{}, - "maverick": struct{}{}, - "natty": struct{}{}, - "oneiric": struct{}{}, - "saucy": struct{}{}, + "dapper": {}, + "edgy": {}, + "feisty": {}, + "gutsy": {}, + "hardy": {}, + "intrepid": {}, + "jaunty": {}, + "karmic": {}, + "lucid": {}, + "maverick": {}, + "natty": {}, + "oneiric": {}, + "saucy": {}, - "vivid/ubuntu-core": struct{}{}, - "vivid/stable-phone-overlay": struct{}{}, + "vivid/ubuntu-core": {}, + "vivid/stable-phone-overlay": {}, // Syntax error - "Patches": struct{}{}, + "Patches": {}, // Product - "product": struct{}{}, + "product": {}, } affectsCaptureRegexp = regexp.MustCompile(`(?P.*)_(?P.*): (?P[^\s]*)( \(+(?P[^()]*)\)+)?`) diff --git a/updater/fetchers/ubuntu/ubuntu_test.go b/updater/fetchers/ubuntu/ubuntu_test.go index 99af782e..b12f8eaf 100644 --- a/updater/fetchers/ubuntu/ubuntu_test.go +++ b/updater/fetchers/ubuntu/ubuntu_test.go @@ -43,21 +43,21 @@ func TestUbuntuParser(t *testing.T) { assert.True(t, hasUnkownRelease) expectedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "ubuntu:14.04"}, Name: "libmspack", }, Version: types.MaxVersion, }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "ubuntu:15.04"}, Name: "libmspack", }, Version: types.NewVersionUnsafe("0.4-3"), }, - database.FeatureVersion{ + { Feature: database.Feature{ Namespace: database.Namespace{Name: "ubuntu:15.10"}, Name: "libmspack-anotherpkg", diff --git a/worker/detectors/feature/dpkg/dpkg_test.go b/worker/detectors/feature/dpkg/dpkg_test.go index 4a408f4a..94fd34d4 100644 --- a/worker/detectors/feature/dpkg/dpkg_test.go +++ b/worker/detectors/feature/dpkg/dpkg_test.go @@ -24,18 +24,18 @@ import ( var dpkgPackagesTests = []feature.FeatureVersionTest{ // Test an Ubuntu dpkg status file - feature.FeatureVersionTest{ + { FeatureVersions: []database.FeatureVersion{ // Two packages from this source are installed, it should only appear one time - database.FeatureVersion{ + { Feature: database.Feature{Name: "pam"}, Version: types.NewVersionUnsafe("1.1.8-3.1ubuntu3"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "makedev"}, // The source name and the package name are equals Version: types.NewVersionUnsafe("2.3.1-93ubuntu1"), // The version comes from the "Version:" line }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "gcc-5"}, Version: types.NewVersionUnsafe("5.1.1-12ubuntu1"), // The version comes from the "Source:" line }, diff --git a/worker/detectors/feature/rpm/rpm_test.go b/worker/detectors/feature/rpm/rpm_test.go index 49862ea0..adb5adb4 100644 --- a/worker/detectors/feature/rpm/rpm_test.go +++ b/worker/detectors/feature/rpm/rpm_test.go @@ -25,15 +25,15 @@ import ( var rpmPackagesTests = []feature.FeatureVersionTest{ // Test a CentOS 7 RPM database // Memo: Use the following command on a RPM-based system to shrink a database: rpm -qa --qf "%{NAME}\n" |tail -n +3| xargs rpm -e --justdb - feature.FeatureVersionTest{ + { FeatureVersions: []database.FeatureVersion{ // Two packages from this source are installed, it should only appear once - database.FeatureVersion{ + { Feature: database.Feature{Name: "centos-release"}, Version: types.NewVersionUnsafe("7-1.1503.el7.centos.2.8"), }, // Two packages from this source are installed, it should only appear once - database.FeatureVersion{ + { Feature: database.Feature{Name: "filesystem"}, Version: types.NewVersionUnsafe("3.2-18.el7"), }, diff --git a/worker/detectors/namespace/aptsources/aptsources_test.go b/worker/detectors/namespace/aptsources/aptsources_test.go index 3070c8ff..d502dc48 100644 --- a/worker/detectors/namespace/aptsources/aptsources_test.go +++ b/worker/detectors/namespace/aptsources/aptsources_test.go @@ -22,7 +22,7 @@ import ( ) var aptSourcesOSTests = []namespace.NamespaceTest{ - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "debian:unstable"}, Data: map[string][]byte{ "etc/os-release": []byte( diff --git a/worker/detectors/namespace/lsbrelease/lsbrelease_test.go b/worker/detectors/namespace/lsbrelease/lsbrelease_test.go index 88f43e9f..9aa3b64f 100644 --- a/worker/detectors/namespace/lsbrelease/lsbrelease_test.go +++ b/worker/detectors/namespace/lsbrelease/lsbrelease_test.go @@ -22,7 +22,7 @@ import ( ) var lsbReleaseOSTests = []namespace.NamespaceTest{ - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "ubuntu:12.04"}, Data: map[string][]byte{ "etc/lsb-release": []byte( @@ -32,7 +32,7 @@ DISTRIB_CODENAME=precise DISTRIB_DESCRIPTION="Ubuntu 12.04 LTS"`), }, }, - namespace.NamespaceTest{ // We don't care about the minor version of Debian + { // We don't care about the minor version of Debian ExpectedNamespace: database.Namespace{Name: "debian:7"}, Data: map[string][]byte{ "etc/lsb-release": []byte( diff --git a/worker/detectors/namespace/osrelease/osrelease_test.go b/worker/detectors/namespace/osrelease/osrelease_test.go index 96296b12..4b08cf33 100644 --- a/worker/detectors/namespace/osrelease/osrelease_test.go +++ b/worker/detectors/namespace/osrelease/osrelease_test.go @@ -22,7 +22,7 @@ import ( ) var osReleaseOSTests = []namespace.NamespaceTest{ - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "debian:8"}, Data: map[string][]byte{ "etc/os-release": []byte( @@ -36,7 +36,7 @@ SUPPORT_URL="http://www.debian.org/support/" BUG_REPORT_URL="https://bugs.debian.org/"`), }, }, - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "ubuntu:15.10"}, Data: map[string][]byte{ "etc/os-release": []byte( @@ -51,7 +51,7 @@ SUPPORT_URL="http://help.ubuntu.com/" BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"`), }, }, - namespace.NamespaceTest{ // Doesn't have quotes around VERSION_ID + { // Doesn't have quotes around VERSION_ID ExpectedNamespace: database.Namespace{Name: "fedora:20"}, Data: map[string][]byte{ "etc/os-release": []byte( diff --git a/worker/detectors/namespace/redhatrelease/redhatrelease_test.go b/worker/detectors/namespace/redhatrelease/redhatrelease_test.go index 42a1f045..25c786ac 100644 --- a/worker/detectors/namespace/redhatrelease/redhatrelease_test.go +++ b/worker/detectors/namespace/redhatrelease/redhatrelease_test.go @@ -22,13 +22,13 @@ import ( ) var redhatReleaseTests = []namespace.NamespaceTest{ - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "centos:6"}, Data: map[string][]byte{ "etc/centos-release": []byte(`CentOS release 6.6 (Final)`), }, }, - namespace.NamespaceTest{ + { ExpectedNamespace: database.Namespace{Name: "centos:7"}, Data: map[string][]byte{ "etc/system-release": []byte(`CentOS Linux release 7.1.1503 (Core)`), diff --git a/worker/worker_test.go b/worker/worker_test.go index 87cfa3e5..b36a867d 100644 --- a/worker/worker_test.go +++ b/worker/worker_test.go @@ -63,35 +63,35 @@ func TestProcessWithDistUpgrade(t *testing.T) { // These FeatureVersions haven't been upgraded. nonUpgradedFeatureVersions := []database.FeatureVersion{ - database.FeatureVersion{ + { Feature: database.Feature{Name: "libtext-wrapi18n-perl"}, Version: types.NewVersionUnsafe("0.06-7"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "libtext-charwidth-perl"}, Version: types.NewVersionUnsafe("0.04-7"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "libtext-iconv-perl"}, Version: types.NewVersionUnsafe("1.7-5"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "mawk"}, Version: types.NewVersionUnsafe("1.3.3-17"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "insserv"}, Version: types.NewVersionUnsafe("1.14.0-5"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "db"}, Version: types.NewVersionUnsafe("5.1.29-5"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "ustr"}, Version: types.NewVersionUnsafe("1.0.4-3"), }, - database.FeatureVersion{ + { Feature: database.Feature{Name: "xz-utils"}, Version: types.NewVersionUnsafe("5.1.1alpha+20120614-2"), },