github.com/noqcks/syft@v0.0.0-20230920222752-a9e2c4e288e5/test/integration/catalog_packages_cases_test.go (about)

     1  package integration
     2  
     3  import "github.com/anchore/syft/syft/pkg"
     4  
     5  type testCase struct {
     6  	name        string
     7  	pkgType     pkg.Type
     8  	pkgLanguage pkg.Language
     9  	duplicates  int
    10  	pkgInfo     map[string]string
    11  }
    12  
    13  var imageOnlyTestCases = []testCase{
    14  	{
    15  		name:        "find gemspec packages",
    16  		pkgType:     pkg.GemPkg,
    17  		pkgLanguage: pkg.Ruby,
    18  		pkgInfo: map[string]string{
    19  			// specifications in the root specification directory
    20  			"bundler": "2.1.4",
    21  			// specifications in named directories
    22  			"unbundler": "3.1.4",
    23  		},
    24  	},
    25  	{
    26  		name:        "find npm package",
    27  		pkgType:     pkg.NpmPkg,
    28  		pkgLanguage: pkg.JavaScript,
    29  		pkgInfo: map[string]string{
    30  			"npm": "6.14.6",
    31  		},
    32  	},
    33  	{
    34  		name:        "find python egg & wheel packages",
    35  		pkgType:     pkg.PythonPkg,
    36  		pkgLanguage: pkg.Python,
    37  		pkgInfo: map[string]string{
    38  			"Pygments":     "2.6.1",
    39  			"requests":     "2.22.0",
    40  			"somerequests": "3.22.0",
    41  			"someotherpkg": "3.19.0",
    42  		},
    43  	},
    44  	{
    45  		name:        "find PHP composer installed.json packages",
    46  		pkgType:     pkg.PhpComposerPkg,
    47  		pkgLanguage: pkg.PHP,
    48  		pkgInfo: map[string]string{
    49  			"nikic/fast-route": "v1.3.0",
    50  			"psr/container":    "2.0.2",
    51  			"psr/http-factory": "1.0.1",
    52  		},
    53  	},
    54  	{
    55  		// When the image is build lib overwrites pkgs/lib causing there to only be two packages
    56  		name:    "find apkdb packages",
    57  		pkgType: pkg.ApkPkg,
    58  		pkgInfo: map[string]string{
    59  			"musl-utils": "1.1.24-r2",
    60  			"libc-utils": "0.7.2-r0",
    61  		},
    62  	},
    63  	{
    64  		name:        "find java packages excluding pom.xml", // image scans can not include packages that have yet to be installed
    65  		pkgType:     pkg.JavaPkg,
    66  		pkgLanguage: pkg.Java,
    67  		pkgInfo: map[string]string{
    68  			"example-java-app-maven": "0.1.0",
    69  			"joda-time":              "2.9.2",
    70  		},
    71  	},
    72  	{
    73  		name:        "find R packages",
    74  		pkgType:     pkg.Rpkg,
    75  		pkgLanguage: pkg.R,
    76  		pkgInfo: map[string]string{
    77  			"base": "4.3.0",
    78  		},
    79  	},
    80  }
    81  
    82  var dirOnlyTestCases = []testCase{
    83  	{
    84  		name:        "find gemfile packages",
    85  		pkgType:     pkg.GemPkg,
    86  		pkgLanguage: pkg.Ruby,
    87  		pkgInfo: map[string]string{
    88  			"actionmailer":         "4.1.1",
    89  			"actionpack":           "4.1.1",
    90  			"actionview":           "4.1.1",
    91  			"activemodel":          "4.1.1",
    92  			"activerecord":         "4.1.1",
    93  			"activesupport":        "4.1.1",
    94  			"arel":                 "5.0.1.20140414130214",
    95  			"bootstrap-sass":       "3.1.1.1",
    96  			"builder":              "3.2.2",
    97  			"coffee-rails":         "4.0.1",
    98  			"coffee-script":        "2.2.0",
    99  			"coffee-script-source": "1.7.0",
   100  			"erubis":               "2.7.0",
   101  			"execjs":               "2.0.2",
   102  			"google-cloud-errors":  "1.3.0",
   103  			"hike":                 "1.2.3",
   104  			"i18n":                 "0.6.9",
   105  			"jbuilder":             "2.0.7",
   106  			"jquery-rails":         "3.1.0",
   107  			"json":                 "1.8.1",
   108  			"kgio":                 "2.9.2",
   109  			"libv8":                "3.16.14.3",
   110  			"mail":                 "2.5.4",
   111  			"mime-types":           "1.25.1",
   112  			"minitest":             "5.3.4",
   113  			"multi_json":           "1.10.1",
   114  			"mysql2":               "0.3.16",
   115  			"polyglot":             "0.3.4",
   116  			"rack":                 "1.5.2",
   117  			"rack-test":            "0.6.2",
   118  			"rails":                "4.1.1",
   119  			"railties":             "4.1.1",
   120  			"raindrops":            "0.13.0",
   121  			"rake":                 "10.3.2",
   122  			"rdoc":                 "4.1.1",
   123  			"ref":                  "1.0.5",
   124  			"sass":                 "3.2.19",
   125  			"sass-rails":           "4.0.3",
   126  			"sdoc":                 "0.4.0",
   127  			"spring":               "1.1.3",
   128  			"sprockets":            "2.11.0",
   129  			"sprockets-rails":      "2.1.3",
   130  			"sqlite3":              "1.3.9",
   131  			"therubyracer":         "0.12.1",
   132  			"thor":                 "0.19.1",
   133  			"thread_safe":          "0.3.3",
   134  			"tilt":                 "1.4.1",
   135  			"treetop":              "1.4.15",
   136  			"turbolinks":           "3.0.0",
   137  			"tzinfo":               "1.2.0",
   138  			"uglifier":             "2.5.0",
   139  			"unicorn":              "4.8.3",
   140  		},
   141  	},
   142  	{
   143  		name:        "find javascript npm packages (yarn.lock & package-lock.json)",
   144  		pkgType:     pkg.NpmPkg,
   145  		pkgLanguage: pkg.JavaScript,
   146  		pkgInfo: map[string]string{
   147  			"yarn":              "0.0.0",
   148  			"package-lock":      "0.0.0",
   149  			"@babel/code-frame": "7.10.4",
   150  			"get-stdin":         "8.0.0",
   151  		},
   152  	},
   153  	{
   154  		name:        "find python requirements.txt & setup.py package references",
   155  		pkgType:     pkg.PythonPkg,
   156  		pkgLanguage: pkg.Python,
   157  		pkgInfo: map[string]string{
   158  			// dir specific test cases
   159  			"flask":              "4.0.0",
   160  			"python-dateutil":    "2.8.1",
   161  			"python-swiftclient": "3.8.1",
   162  			"pytz":               "2019.3",
   163  			"jsonschema":         "2.6.0",
   164  			"passlib":            "1.7.2",
   165  			"mypy":               "v0.770",
   166  			// common to image and directory
   167  			"Pygments":     "2.6.1",
   168  			"requests":     "2.22.0",
   169  			"somerequests": "3.22.0",
   170  			"someotherpkg": "3.19.0",
   171  		},
   172  	},
   173  	{
   174  		name:        "find golang modules",
   175  		pkgType:     pkg.GoModulePkg,
   176  		pkgLanguage: pkg.Go,
   177  		pkgInfo: map[string]string{
   178  			"github.com/bmatcuk/doublestar": "v1.3.1",
   179  		},
   180  	},
   181  	{
   182  		name:        "find conan packages",
   183  		pkgType:     pkg.ConanPkg,
   184  		pkgLanguage: pkg.CPP,
   185  		pkgInfo: map[string]string{
   186  			"catch2":     "2.13.8",
   187  			"docopt.cpp": "0.6.3",
   188  			"fmt":        "8.1.1",
   189  			"spdlog":     "1.9.2",
   190  			"sdl":        "2.0.20",
   191  			"fltk":       "1.3.8",
   192  		},
   193  	},
   194  	{
   195  		name:        "find rust crates",
   196  		pkgType:     pkg.RustPkg,
   197  		pkgLanguage: pkg.Rust,
   198  		pkgInfo: map[string]string{
   199  			"memchr":        "2.3.3",
   200  			"nom":           "4.2.3",
   201  			"version_check": "0.1.5",
   202  		},
   203  	},
   204  	{
   205  		name:       "find apkdb packages",
   206  		pkgType:    pkg.ApkPkg,
   207  		duplicates: 2, // when the directory is cataloged we have duplicates between lib/ and pkgs/lib
   208  		pkgInfo: map[string]string{
   209  			"musl-utils": "1.1.24-r2",
   210  			"libc-utils": "0.7.2-r0",
   211  		},
   212  	},
   213  	{
   214  		name:        "find php composer package",
   215  		pkgType:     pkg.PhpComposerPkg,
   216  		pkgLanguage: pkg.PHP,
   217  		pkgInfo: map[string]string{
   218  			"adoy/fastcgi-client":       "1.0.2",
   219  			"alcaeus/mongo-php-adapter": "1.1.11",
   220  		},
   221  	},
   222  	{
   223  		name:        "find pubspec lock packages",
   224  		pkgType:     pkg.DartPubPkg,
   225  		pkgLanguage: pkg.Dart,
   226  		pkgInfo: map[string]string{
   227  			"ansicolor":  "1.1.1",
   228  			"archive":    "2.0.13",
   229  			"args":       "1.6.0",
   230  			"key_binder": "1.11.20",
   231  			"ale":        "3.3.0",
   232  			"analyzer":   "0.40.7",
   233  		},
   234  	},
   235  	{
   236  		name:        "find dotnet packages",
   237  		pkgType:     pkg.DotnetPkg,
   238  		pkgLanguage: pkg.Dotnet,
   239  		pkgInfo: map[string]string{
   240  			"AWSSDK.Core": "3.7.10.6",
   241  			"Microsoft.Extensions.DependencyInjection":              "6.0.0",
   242  			"Microsoft.Extensions.DependencyInjection.Abstractions": "6.0.0",
   243  			"Microsoft.Extensions.Logging":                          "6.0.0",
   244  			"Microsoft.Extensions.Logging.Abstractions":             "6.0.0",
   245  			"Microsoft.Extensions.Options":                          "6.0.0",
   246  			"Microsoft.Extensions.Primitives":                       "6.0.0",
   247  			"Newtonsoft.Json":                                       "13.0.1",
   248  			"Serilog":                                               "2.10.0",
   249  			"Serilog.Sinks.Console":                                 "4.0.1",
   250  			"System.Diagnostics.DiagnosticSource":                   "6.0.0",
   251  			"System.Runtime.CompilerServices.Unsafe":                "6.0.0",
   252  			"TestCommon":                                            "1.0.0",
   253  			"TestLibrary":                                           "1.0.0",
   254  		},
   255  	},
   256  	{
   257  		name:        "find java packages including pom.xml", // directory scans can include packages that have yet to be installed
   258  		pkgType:     pkg.JavaPkg,
   259  		pkgLanguage: pkg.Java,
   260  		duplicates:  1, // joda-time is included in both pom.xml AND the .jar collection
   261  		pkgInfo: map[string]string{
   262  			"example-java-app-maven": "0.1.0",
   263  			"joda-time":              "2.9.2",
   264  			"junit":                  "4.12",
   265  		},
   266  	},
   267  	{
   268  		name:        "find cocoapods packages",
   269  		pkgType:     pkg.CocoapodsPkg,
   270  		pkgLanguage: pkg.Swift,
   271  		pkgInfo: map[string]string{
   272  			"GlossButtonNode":                        "3.1.2",
   273  			"PINCache":                               "3.0.3",
   274  			"PINCache/Arc-exception-safe":            "3.0.3",
   275  			"PINCache/Core":                          "3.0.3",
   276  			"PINOperation":                           "1.2.1",
   277  			"PINRemoteImage/Core":                    "3.0.3",
   278  			"PINRemoteImage/iOS":                     "3.0.3",
   279  			"PINRemoteImage/PINCache":                "3.0.3",
   280  			"Reveal-SDK":                             "33",
   281  			"SwiftGen":                               "6.5.1",
   282  			"Texture":                                "3.1.0",
   283  			"Texture/AssetsLibrary":                  "3.1.0",
   284  			"Texture/Core":                           "3.1.0",
   285  			"Texture/MapKit":                         "3.1.0",
   286  			"Texture/Photos":                         "3.1.0",
   287  			"Texture/PINRemoteImage":                 "3.1.0",
   288  			"Texture/Video":                          "3.1.0",
   289  			"TextureSwiftSupport":                    "3.13.0",
   290  			"TextureSwiftSupport/Components":         "3.13.0",
   291  			"TextureSwiftSupport/Experiments":        "3.13.0",
   292  			"TextureSwiftSupport/Extensions":         "3.13.0",
   293  			"TextureSwiftSupport/LayoutSpecBuilders": "3.13.0",
   294  			"TinyConstraints":                        "4.0.2",
   295  		},
   296  	},
   297  	{
   298  		name:        "find hackage packages",
   299  		pkgType:     pkg.HackagePkg,
   300  		pkgLanguage: pkg.Haskell,
   301  		pkgInfo: map[string]string{
   302  			"Cabal":                    "3.2.1.0",
   303  			"Diff":                     "0.4.1",
   304  			"HTTP":                     "4000.3.16",
   305  			"HUnit":                    "1.6.2.0",
   306  			"OneTuple":                 "0.3.1",
   307  			"Only":                     "0.1",
   308  			"PyF":                      "0.10.2.0",
   309  			"QuickCheck":               "2.14.2",
   310  			"RSA":                      "2.4.1",
   311  			"SHA":                      "1.6.4.4",
   312  			"Spock":                    "0.14.0.0",
   313  			"ShellCheck":               "0.8.0",
   314  			"colourista":               "0.1.0.1",
   315  			"language-docker":          "11.0.0",
   316  			"spdx":                     "1.0.0.2",
   317  			"hspec":                    "2.9.4",
   318  			"hspec-core":               "2.9.4",
   319  			"hspec-discover":           "2.9.4",
   320  			"stm":                      "2.5.0.2",
   321  			"configurator-pg":          "0.2.6",
   322  			"hasql-dynamic-statements": "0.3.1.1",
   323  			"hasql-implicits":          "0.1.0.4",
   324  			"hasql-pool":               "0.5.2.2",
   325  			"lens-aeson":               "1.1.3",
   326  			"optparse-applicative":     "0.16.1.0",
   327  			"protolude":                "0.3.2",
   328  			"ptr":                      "0.16.8.2",
   329  		},
   330  	},
   331  	{
   332  		name:        "find hex packages",
   333  		pkgType:     pkg.HexPkg,
   334  		pkgLanguage: pkg.Elixir + "," + pkg.Erlang,
   335  		pkgInfo: map[string]string{
   336  			// elixir
   337  			"castore":          "0.1.17",
   338  			"connection":       "1.1.0",
   339  			"cowboy":           "2.9.0",
   340  			"cowboy_telemetry": "0.4.0",
   341  			"cowlib":           "2.11.0",
   342  			"db_connection":    "2.4.2",
   343  			"decimal":          "2.0.0",
   344  			"earmark_parser":   "1.4.25",
   345  			"ecto":             "3.8.1",
   346  			"ecto_sql":         "3.8.1",
   347  			"esbuild":          "0.5.0",
   348  			"ex_doc":           "0.28.4",
   349  			"gettext":          "0.19.1",
   350  			"hpax":             "0.1.1",
   351  			"jason":            "1.3.0",
   352  
   353  			// erlang
   354  			"certifi":             "2.9.0",
   355  			"idna":                "6.1.1",
   356  			"metrics":             "1.0.1",
   357  			"mimerl":              "1.2.0",
   358  			"parse_trans":         "3.3.1",
   359  			"ssl_verify_fun":      "1.1.6",
   360  			"unicode_util_compat": "0.7.0",
   361  		},
   362  	},
   363  	{
   364  		name:        "find swift package manager packages",
   365  		pkgType:     pkg.SwiftPkg,
   366  		pkgLanguage: pkg.Swift,
   367  		pkgInfo: map[string]string{
   368  			"swift-algorithms":       "1.0.0",
   369  			"swift-async-algorithms": "0.1.0",
   370  			"swift-atomics":          "1.1.0",
   371  			"swift-collections":      "1.0.4",
   372  			"swift-numerics":         "1.0.2",
   373  		},
   374  	},
   375  	{
   376  		name:    "find github action packages (from usage in workflow files and composite actions)",
   377  		pkgType: pkg.GithubActionPkg,
   378  		pkgInfo: map[string]string{
   379  			"actions/checkout": "v4",
   380  		},
   381  	},
   382  	{
   383  		name:    "find github shared workflow calls (from usage in workflow files)",
   384  		pkgType: pkg.GithubActionWorkflowPkg,
   385  		pkgInfo: map[string]string{
   386  			"octo-org/this-repo/.github/workflows/workflow-1.yml": "172239021f7ba04fe7327647b213799853a9eb89",
   387  		},
   388  	},
   389  }
   390  
   391  var commonTestCases = []testCase{
   392  	{
   393  		name:    "find alpm packages",
   394  		pkgType: pkg.AlpmPkg,
   395  		pkgInfo: map[string]string{
   396  			"pacman": "6.0.1-5",
   397  		},
   398  	},
   399  	{
   400  		name:    "find rpmdb packages",
   401  		pkgType: pkg.RpmPkg,
   402  		pkgInfo: map[string]string{
   403  			"dive": "0.9.2-1",
   404  		},
   405  	},
   406  	{
   407  		name:    "find dpkg packages",
   408  		pkgType: pkg.DebPkg,
   409  		pkgInfo: map[string]string{
   410  			"apt":     "1.8.2",
   411  			"dash":    "0.5.8-2.4",
   412  			"netbase": "5.4",
   413  		},
   414  	},
   415  	{
   416  		name:    "find portage packages",
   417  		pkgType: pkg.PortagePkg,
   418  		pkgInfo: map[string]string{
   419  			"app-containers/skopeo": "1.5.1",
   420  		},
   421  	},
   422  
   423  	{
   424  		name:        "find jenkins plugins",
   425  		pkgType:     pkg.JenkinsPluginPkg,
   426  		pkgLanguage: pkg.Java,
   427  		duplicates:  1, // there is a "example-jenkins-plugin" HPI, and nested within that a JAR of the same name
   428  		pkgInfo: map[string]string{
   429  			"example-jenkins-plugin": "1.0-SNAPSHOT",
   430  		},
   431  	},
   432  	{
   433  		name:    "find nix store packages",
   434  		pkgType: pkg.NixPkg,
   435  		pkgInfo: map[string]string{
   436  			"glibc": "2.34-210",
   437  		},
   438  	},
   439  }