Skip to content

Commit

Permalink
Add .xz archive support (#433)
Browse files Browse the repository at this point in the history
Signed-off-by: egibs <[email protected]>
  • Loading branch information
egibs authored Aug 29, 2024
1 parent f80e63d commit f17fe94
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: Checkout code
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
Expand All @@ -47,9 +47,9 @@ jobs:
sudo add-apt-repository -n -y "deb http://security.ubuntu.com/ubuntu mantic-security main restricted universe multiverse"
sudo apt update && sudo apt install libyara-dev -y
- name: Prepare samples
run : |
run: |
cp -a ${{ github.workspace }}/test_data/. ${{ github.workspace }}/samples/
for file in caddy.xz chezmoi.xz minio_x86_64.xz mongosh.xz neuvector_agent_aarch64.xz opa.xz ; do \
tar -xJvf ${{ github.workspace }}/samples/linux/clean/${file} -C ${{ github.workspace }}/samples/linux/clean; \
Expand Down
4 changes: 2 additions & 2 deletions pkg/action/archive.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func extractTar(ctx context.Context, d string, f string) error {
}
defer gzStream.Close()
tr = tar.NewReader(gzStream)
case strings.Contains(filename, ".tar.xz"):
case strings.Contains(filename, ".xz"):
_, err := tf.Seek(0, io.SeekStart) // Seek to start for xz reading
if err != nil {
return fmt.Errorf("failed to seek to start: %w", err)
Expand Down Expand Up @@ -347,7 +347,7 @@ func extractionMethod(ext string) func(context.Context, string, string) error {
return extractZip
case ".gz":
return extractGzip
case ".apk", ".gem", ".tar", ".tar.gz", ".tgz", ".tar.xz":
case ".apk", ".gem", ".tar", ".tar.gz", ".tgz", ".tar.xz", ".xz":
return extractTar
default:
return nil
Expand Down
1 change: 1 addition & 0 deletions pkg/action/programkind.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var archiveMap = map[string]bool{
".tar.xz": true,
".tar": true,
".tgz": true,
".xz": true,
".zip": true,
}

Expand Down

0 comments on commit f17fe94

Please sign in to comment.