feat: Add R cataloger (#1790)

Add a cataloger that detects installed R packages by looking for DESCRIPTION
files. The base R package is now picked up in coverageImage tests in
test/cli/packages_cmd_test.go, so increment expected package counts for the
tests that use that image.

Signed-off-by: Will Murphy <will.murphy@anchore.com>
This commit is contained in:
William Murphy
2023-05-10 12:30:11 -04:00
committed by GitHub
parent 0580328ad9
commit da3624644a
31 changed files with 2476 additions and 5 deletions
+4 -4
View File
@@ -96,7 +96,7 @@ func TestPackagesCmdFlags(t *testing.T) {
name: "squashed-scope-flag",
args: []string{"packages", "-o", "json", "-s", "squashed", coverageImage},
assertions: []traitAssertion{
assertPackageCount(35),
assertPackageCount(36),
assertSuccessfulReturnCode,
},
},
@@ -213,7 +213,7 @@ func TestPackagesCmdFlags(t *testing.T) {
// the application config in the log matches that of what we expect to have been configured.
assertInOutput("parallelism: 2"),
assertInOutput("parallelism=2"),
assertPackageCount(35),
assertPackageCount(36),
assertSuccessfulReturnCode,
},
},
@@ -224,7 +224,7 @@ func TestPackagesCmdFlags(t *testing.T) {
// the application config in the log matches that of what we expect to have been configured.
assertInOutput("parallelism: 1"),
assertInOutput("parallelism=1"),
assertPackageCount(35),
assertPackageCount(36),
assertSuccessfulReturnCode,
},
},
@@ -238,7 +238,7 @@ func TestPackagesCmdFlags(t *testing.T) {
assertions: []traitAssertion{
assertNotInOutput("secret_password"),
assertNotInOutput("secret_key_path"),
assertPackageCount(35),
assertPackageCount(36),
assertSuccessfulReturnCode,
},
},
@@ -69,6 +69,14 @@ var imageOnlyTestCases = []testCase{
"joda-time": "2.9.2",
},
},
{
name: "find R packages",
pkgType: pkg.Rpkg,
pkgLanguage: pkg.R,
pkgInfo: map[string]string{
"base": "4.3.0",
},
},
}
var dirOnlyTestCases = []testCase{
@@ -220,10 +220,12 @@ func TestPkgCoverageDirectory(t *testing.T) {
observedLanguages.Remove(pkg.UnknownLanguage.String())
definedLanguages.Remove(pkg.UnknownLanguage.String())
definedLanguages.Remove(pkg.R.String())
observedPkgs.Remove(string(pkg.UnknownPkg))
definedPkgs.Remove(string(pkg.BinaryPkg))
definedPkgs.Remove(string(pkg.LinuxKernelPkg))
definedPkgs.Remove(string(pkg.LinuxKernelModulePkg))
definedPkgs.Remove(string(pkg.Rpkg))
definedPkgs.Remove(string(pkg.UnknownPkg))
// for directory scans we should not expect to see any of the following package types
@@ -0,0 +1,11 @@
Package: base
Version: 4.3.0
Priority: base
Title: The R Base Package
Author: R Core Team and contributors worldwide
Maintainer: R Core Team <do-use-Contact-address@r-project.org>
Contact: R-help mailing list <r-help@r-project.org>
Description: Base R functions.
License: Part of R 4.3.0
Suggests: methods
Built: R 4.3.0; ; 2023-04-21 11:33:09 UTC; unix