chainguard-dev / bincapz

detect malicious program behaviors
Apache License 2.0
380 stars 24 forks source link

Remove unnecessary archive code; fix .tar.xz support #214

Closed egibs closed 1 month ago

egibs commented 1 month ago

I was running a scan on the go1.22.2.linux-arm64.tar.gz archive which contains nested .tar and .zip files.

The recursive extraction logic in each of the extract functions was indeed incorrect, not needed, and broke extraction for this type of archive.

Removing this logic 1) fixed the issue with that archive and 2) was proven unnecessary for .gem files:

❯ ls -hal /var/folders/3g/88131l9j11x995ppjbxsvhbh0000gn/T/cocoapods-fixbugs-plugin-0.1.0.gem2017939464
Permissions Size User  Date Modified Name
.rw-r--r--@   76 egibs 10 May 16:27  .travis.yml
drwxr-xr-x@    - egibs 10 May 16:27  bin
.rw-r--r--@  418 egibs 10 May 16:27  checksums.yaml
.rw-r--r--@  991 egibs 10 May 16:27  cocoapods-fixbugs-plugin.gemspec
.rw-r--r--@  109 egibs 10 May 16:27  Gemfile
drwxr-xr-x@    - egibs 10 May 16:27  lib
.rw-r--r--@ 1.1k egibs 10 May 16:27  LICENSE.txt
.rw-r--r--@ 2.2k egibs 10 May 16:27  metadata
.rw-r--r--@   28 egibs 10 May 16:27  Rakefile
.rw-r--r--@ 1.4k egibs 10 May 16:27  README.md