Add support for nar files. (#1727)

- Update README.md to show that nar is now supported.
- Created a java-archives/example.nar so that the tests wouldn't break.
- Add nar glob and as an option for pkgType.

Closes #1701

Signed-off-by: Shane Dell <shanedell100@gmail.com>
This commit is contained in:
Shane Dell 2023-04-11 09:41:49 -04:00 committed by GitHub
parent 305838582b
commit 16ebcb2455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 2 deletions

View file

@ -42,7 +42,7 @@ For commercial support options with Syft or Grype, please [contact Anchore](http
- Erlang (rebar3)
- Go (go.mod, Go binaries)
- Haskell (cabal, stack)
- Java (jar, ear, war, par, sar, native-image)
- Java (jar, ear, war, par, sar, nar, native-image)
- JavaScript (npm, yarn)
- Jenkins Plugins (jpi, hpi)
- Nix (outputs in /nix/store)

View file

@ -108,7 +108,7 @@ func (a archiveFilename) extension() string {
func (a archiveFilename) pkgType() pkg.Type {
switch strings.ToLower(a.extension()) {
case "jar", "war", "ear", "lpkg", "par", "sar":
case "jar", "war", "ear", "lpkg", "par", "sar", "nar":
return pkg.JavaPkg
case "jpi", "hpi":
return pkg.JenkinsPluginPkg

View file

@ -79,6 +79,13 @@ func TestExtractInfoFromJavaArchiveFilename(t *testing.T) {
name: "pkg-extra-field-maven",
ty: pkg.JavaPkg,
},
{
filename: "pkg-extra-field-maven-4.3.2-rc1.nar",
version: "4.3.2-rc1",
extension: "nar",
name: "pkg-extra-field-maven",
ty: pkg.JavaPkg,
},
{
filename: "/some/path/pkg-extra-field-maven-4.3.2-rc1.jpi",
version: "4.3.2-rc1",

View file

@ -24,6 +24,7 @@ var archiveFormatGlobs = []string{
"**/*.ear",
"**/*.par",
"**/*.sar",
"**/*.nar",
"**/*.jpi",
"**/*.hpi",
"**/*.lpkg", // Zip-compressed package used to deploy applications

View file

@ -21,6 +21,7 @@ func Test_ArchiveCataloger_Globs(t *testing.T) {
"java-archives/example.ear",
"java-archives/example.par",
"java-archives/example.sar",
"java-archives/example.nar",
"java-archives/example.jpi",
"java-archives/example.hpi",
"java-archives/example.lpkg",

View file

@ -0,0 +1 @@
example archive