示例#1
0
文件: rpm_test.go 项目: coreos/clair
func TestRpmFeatureDetection(t *testing.T) {
	testData := []feature.TestData{
		// 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
		{
			FeatureVersions: []database.FeatureVersion{
				// Two packages from this source are installed, it should only appear once
				{
					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
				{
					Feature: database.Feature{Name: "filesystem"},
					Version: types.NewVersionUnsafe("3.2-18.el7"),
				},
			},
			Data: map[string][]byte{
				"var/lib/rpm/Packages": feature.LoadFileForTest("rpm/testdata/Packages"),
			},
		},
	}

	feature.TestDetector(t, &RpmFeaturesDetector{}, testData)
}
示例#2
0
文件: dpkg_test.go 项目: coreos/clair
func TestDpkgFeatureDetection(t *testing.T) {
	testData := []feature.TestData{
		// Test an Ubuntu dpkg status file
		{
			FeatureVersions: []database.FeatureVersion{
				// Two packages from this source are installed, it should only appear one time
				{
					Feature: database.Feature{Name: "pam"},
					Version: types.NewVersionUnsafe("1.1.8-3.1ubuntu3"),
				},
				{
					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
				},
				{
					Feature: database.Feature{Name: "gcc-5"},
					Version: types.NewVersionUnsafe("5.1.1-12ubuntu1"), // The version comes from the "Source:" line
				},
			},
			Data: map[string][]byte{
				"var/lib/dpkg/status": feature.LoadFileForTest("dpkg/testdata/status"),
			},
		},
	}

	feature.TestDetector(t, &DpkgFeaturesDetector{}, testData)
}
示例#3
0
文件: apk_test.go 项目: coreos/clair
func TestAPKFeatureDetection(t *testing.T) {
	testData := []feature.TestData{
		{
			FeatureVersions: []database.FeatureVersion{
				{
					Feature: database.Feature{Name: "musl"},
					Version: types.NewVersionUnsafe("1.1.14-r10"),
				},
				{
					Feature: database.Feature{Name: "busybox"},
					Version: types.NewVersionUnsafe("1.24.2-r9"),
				},
				{
					Feature: database.Feature{Name: "alpine-baselayout"},
					Version: types.NewVersionUnsafe("3.0.3-r0"),
				},
				{
					Feature: database.Feature{Name: "alpine-keys"},
					Version: types.NewVersionUnsafe("1.1-r0"),
				},
				{
					Feature: database.Feature{Name: "zlib"},
					Version: types.NewVersionUnsafe("1.2.8-r2"),
				},
				{
					Feature: database.Feature{Name: "libcrypto1.0"},
					Version: types.NewVersionUnsafe("1.0.2h-r1"),
				},
				{
					Feature: database.Feature{Name: "libssl1.0"},
					Version: types.NewVersionUnsafe("1.0.2h-r1"),
				},
				{
					Feature: database.Feature{Name: "apk-tools"},
					Version: types.NewVersionUnsafe("2.6.7-r0"),
				},
				{
					Feature: database.Feature{Name: "scanelf"},
					Version: types.NewVersionUnsafe("1.1.6-r0"),
				},
				{
					Feature: database.Feature{Name: "musl-utils"},
					Version: types.NewVersionUnsafe("1.1.14-r10"),
				},
				{
					Feature: database.Feature{Name: "libc-utils"},
					Version: types.NewVersionUnsafe("0.7-r0"),
				},
			},
			Data: map[string][]byte{
				"lib/apk/db/installed": feature.LoadFileForTest("apk/testdata/installed"),
			},
		},
	}
	feature.TestDetector(t, &detector{}, testData)
}
示例#4
0
	"github.com/coreos/clair/database"
	"github.com/coreos/clair/utils/types"
	"github.com/coreos/clair/worker/detectors/feature"
)

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
	{
		FeatureVersions: []database.FeatureVersion{
			// Two packages from this source are installed, it should only appear once
			{
				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
			{
				Feature: database.Feature{Name: "filesystem"},
				Version: types.NewVersionUnsafe("3.2-18.el7"),
			},
		},
		Data: map[string][]byte{
			"var/lib/rpm/Packages": feature.LoadFileForTest("rpm/testdata/Packages"),
		},
	},
}

func TestRpmFeaturesDetector(t *testing.T) {
	feature.TestFeaturesDetector(t, &RpmFeaturesDetector{}, rpmPackagesTests)
}
示例#5
0
	"github.com/coreos/clair/worker/detectors/feature"
)

var dpkgPackagesTests = []feature.FeatureVersionTest{
	// Test an Ubuntu dpkg status file
	{
		FeatureVersions: []database.FeatureVersion{
			// Two packages from this source are installed, it should only appear one time
			{
				Feature: database.Feature{Name: "pam"},
				Version: types.NewVersionUnsafe("1.1.8-3.1ubuntu3"),
			},
			{
				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
			},
			{
				Feature: database.Feature{Name: "gcc-5"},
				Version: types.NewVersionUnsafe("5.1.1-12ubuntu1"), // The version comes from the "Source:" line
			},
		},
		Data: map[string][]byte{
			"var/lib/dpkg/status": feature.LoadFileForTest("dpkg/testdata/status"),
		},
	},
}

func TestDpkgFeaturesDetector(t *testing.T) {
	feature.TestFeaturesDetector(t, &DpkgFeaturesDetector{}, dpkgPackagesTests)
}