mirror of
https://github.com/anchore/syft
synced 2024-11-15 00:27:07 +00:00
6af132e088
* Adds installed.json functionality and tests Signed-off-by: Blaize Kaye <blaize.kaye@amazee.com> * Adds php-installed-cataloger Signed-off-by: Blaize Kaye <blaize.kaye@amazee.com> * Changes fallback logic Signed-off-by: Blaize Kaye <blaize.kaye@amazee.com> * Adds image tests for installed.json composer packages Signed-off-by: Blaize Kaye <blaize.kaye@amazee.com> * tweak PHP cataloger names Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * unexport PHP types and fix CLI tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * rename PHP cataloger file Signed-off-by: Alex Goodman <alex.goodman@anchore.com> Co-authored-by: Alex Goodman <alex.goodman@anchore.com>
226 lines
5.9 KiB
Go
226 lines
5.9 KiB
Go
package integration
|
|
|
|
import "github.com/anchore/syft/syft/pkg"
|
|
|
|
type testCase struct {
|
|
name string
|
|
pkgType pkg.Type
|
|
pkgLanguage pkg.Language
|
|
duplicates int
|
|
pkgInfo map[string]string
|
|
}
|
|
|
|
var imageOnlyTestCases = []testCase{
|
|
{
|
|
name: "find gemspec packages",
|
|
pkgType: pkg.GemPkg,
|
|
pkgLanguage: pkg.Ruby,
|
|
pkgInfo: map[string]string{
|
|
// specifications in the root specification directory
|
|
"bundler": "2.1.4",
|
|
// specifications in named directories
|
|
"unbundler": "3.1.4",
|
|
},
|
|
},
|
|
{
|
|
name: "find npm package",
|
|
pkgType: pkg.NpmPkg,
|
|
pkgLanguage: pkg.JavaScript,
|
|
pkgInfo: map[string]string{
|
|
"npm": "6.14.6",
|
|
},
|
|
},
|
|
{
|
|
name: "find python egg & wheel packages",
|
|
pkgType: pkg.PythonPkg,
|
|
pkgLanguage: pkg.Python,
|
|
pkgInfo: map[string]string{
|
|
"Pygments": "2.6.1",
|
|
"requests": "2.22.0",
|
|
"somerequests": "3.22.0",
|
|
"someotherpkg": "3.19.0",
|
|
},
|
|
},
|
|
{
|
|
name: "find PHP composer installed.json packages",
|
|
pkgType: pkg.PhpComposerPkg,
|
|
pkgLanguage: pkg.PHP,
|
|
pkgInfo: map[string]string{
|
|
"nikic/fast-route": "v1.3.0",
|
|
"psr/container": "2.0.2",
|
|
"psr/http-factory": "1.0.1",
|
|
},
|
|
},
|
|
{
|
|
// When the image is build lib overwrites pkgs/lib causing there to only be two packages
|
|
name: "find apkdb packages",
|
|
pkgType: pkg.ApkPkg,
|
|
pkgInfo: map[string]string{
|
|
"musl-utils": "1.1.24-r2",
|
|
"libc-utils": "0.7.2-r0",
|
|
},
|
|
},
|
|
}
|
|
|
|
var dirOnlyTestCases = []testCase{
|
|
{
|
|
name: "find gemfile packages",
|
|
pkgType: pkg.GemPkg,
|
|
pkgLanguage: pkg.Ruby,
|
|
pkgInfo: map[string]string{
|
|
"actionmailer": "4.1.1",
|
|
"actionpack": "4.1.1",
|
|
"actionview": "4.1.1",
|
|
"activemodel": "4.1.1",
|
|
"activerecord": "4.1.1",
|
|
"activesupport": "4.1.1",
|
|
"arel": "5.0.1.20140414130214",
|
|
"bootstrap-sass": "3.1.1.1",
|
|
"builder": "3.2.2",
|
|
"coffee-rails": "4.0.1",
|
|
"coffee-script": "2.2.0",
|
|
"coffee-script-source": "1.7.0",
|
|
"erubis": "2.7.0",
|
|
"execjs": "2.0.2",
|
|
"hike": "1.2.3",
|
|
"i18n": "0.6.9",
|
|
"jbuilder": "2.0.7",
|
|
"jquery-rails": "3.1.0",
|
|
"json": "1.8.1",
|
|
"kgio": "2.9.2",
|
|
"libv8": "3.16.14.3",
|
|
"mail": "2.5.4",
|
|
"mime-types": "1.25.1",
|
|
"minitest": "5.3.4",
|
|
"multi_json": "1.10.1",
|
|
"mysql2": "0.3.16",
|
|
"polyglot": "0.3.4",
|
|
"rack": "1.5.2",
|
|
"rack-test": "0.6.2",
|
|
"rails": "4.1.1",
|
|
"railties": "4.1.1",
|
|
"raindrops": "0.13.0",
|
|
"rake": "10.3.2",
|
|
"rdoc": "4.1.1",
|
|
"ref": "1.0.5",
|
|
"sass": "3.2.19",
|
|
"sass-rails": "4.0.3",
|
|
"sdoc": "0.4.0",
|
|
"spring": "1.1.3",
|
|
"sprockets": "2.11.0",
|
|
"sprockets-rails": "2.1.3",
|
|
"sqlite3": "1.3.9",
|
|
"therubyracer": "0.12.1",
|
|
"thor": "0.19.1",
|
|
"thread_safe": "0.3.3",
|
|
"tilt": "1.4.1",
|
|
"treetop": "1.4.15",
|
|
"turbolinks": "2.2.2",
|
|
"tzinfo": "1.2.0",
|
|
"uglifier": "2.5.0",
|
|
"unicorn": "4.8.3",
|
|
},
|
|
},
|
|
{
|
|
name: "find javascript npm packages (yarn.lock & package-lock.json)",
|
|
pkgType: pkg.NpmPkg,
|
|
pkgLanguage: pkg.JavaScript,
|
|
pkgInfo: map[string]string{
|
|
"@babel/code-frame": "7.10.4",
|
|
"get-stdin": "8.0.0",
|
|
},
|
|
},
|
|
{
|
|
name: "find python requirements.txt & setup.py package references",
|
|
pkgType: pkg.PythonPkg,
|
|
pkgLanguage: pkg.Python,
|
|
pkgInfo: map[string]string{
|
|
// dir specific test cases
|
|
"flask": "4.0.0",
|
|
"python-dateutil": "2.8.1",
|
|
"python-swiftclient": "3.8.1",
|
|
"pytz": "2019.3",
|
|
"jsonschema": "2.6.0",
|
|
"passlib": "1.7.2",
|
|
"mypy": "v0.770",
|
|
// common to image and directory
|
|
"Pygments": "2.6.1",
|
|
"requests": "2.22.0",
|
|
"somerequests": "3.22.0",
|
|
"someotherpkg": "3.19.0",
|
|
},
|
|
},
|
|
{
|
|
name: "find golang modules",
|
|
pkgType: pkg.GoModulePkg,
|
|
pkgLanguage: pkg.Go,
|
|
pkgInfo: map[string]string{
|
|
"github.com/bmatcuk/doublestar": "v1.3.1",
|
|
},
|
|
},
|
|
{
|
|
name: "find rust crates",
|
|
pkgType: pkg.RustPkg,
|
|
pkgLanguage: pkg.Rust,
|
|
pkgInfo: map[string]string{
|
|
"memchr": "2.3.3",
|
|
"nom": "4.2.3",
|
|
"version_check": "0.1.5",
|
|
},
|
|
},
|
|
{
|
|
name: "find apkdb packages",
|
|
pkgType: pkg.ApkPkg,
|
|
duplicates: 2, // when the directory is cataloged we have duplicates between lib/ and pkgs/lib
|
|
pkgInfo: map[string]string{
|
|
"musl-utils": "1.1.24-r2",
|
|
"libc-utils": "0.7.2-r0",
|
|
},
|
|
},
|
|
{
|
|
name: "find php composer package",
|
|
pkgType: pkg.PhpComposerPkg,
|
|
pkgLanguage: pkg.PHP,
|
|
pkgInfo: map[string]string{
|
|
"adoy/fastcgi-client": "1.0.2",
|
|
"alcaeus/mongo-php-adapter": "1.1.11",
|
|
},
|
|
},
|
|
}
|
|
|
|
var commonTestCases = []testCase{
|
|
{
|
|
name: "find rpmdb packages",
|
|
pkgType: pkg.RpmPkg,
|
|
pkgInfo: map[string]string{
|
|
"dive": "0.9.2-1",
|
|
},
|
|
},
|
|
{
|
|
name: "find dpkg packages",
|
|
pkgType: pkg.DebPkg,
|
|
pkgInfo: map[string]string{
|
|
"apt": "1.8.2",
|
|
"dash": "0.5.8-2.4",
|
|
"netbase": "5.4",
|
|
},
|
|
},
|
|
{
|
|
name: "find java packages",
|
|
pkgType: pkg.JavaPkg,
|
|
pkgLanguage: pkg.Java,
|
|
pkgInfo: map[string]string{
|
|
"example-java-app-maven": "0.1.0",
|
|
"joda-time": "2.9.2",
|
|
},
|
|
},
|
|
{
|
|
name: "find jenkins plugins",
|
|
pkgType: pkg.JenkinsPluginPkg,
|
|
pkgLanguage: pkg.Java,
|
|
duplicates: 1, // there is a "example-jenkins-plugin" HPI, and nested within that a JAR of the same name
|
|
pkgInfo: map[string]string{
|
|
"example-jenkins-plugin": "1.0-SNAPSHOT",
|
|
},
|
|
},
|
|
}
|