Skip to content

Commit

Permalink
Add support for nar files.
Browse files Browse the repository at this point in the history
- 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 anchore#1701

Signed-off-by: Shane Dell <shanedell100@gmail.com>
  • Loading branch information
shanedell committed Apr 10, 2023
1 parent a260fb2 commit ad63e31
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion syft/pkg/cataloger/java/archive_filename.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions syft/pkg/cataloger/java/archive_filename_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions syft/pkg/cataloger/java/archive_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var archiveFormatGlobs = []string{
"**/*.ear",
"**/*.par",
"**/*.sar",
"**/*.nar",
"**/*.jpi",
"**/*.hpi",
"**/*.lpkg", // Zip-compressed package used to deploy applications
Expand Down
1 change: 1 addition & 0 deletions syft/pkg/cataloger/java/cataloger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
example archive

0 comments on commit ad63e31

Please sign in to comment.