Commit 78972f2
authored
Malcontent: change extraction error default (#1085)
* mal: always report when archive extraction fails
malcontent by default bails out when it hits an extraction error like
so:
```
$ mal scan mlflow-3.2.0-r0.apk
🔎 Scanning "mlflow-3.2.0-r0.apk"
time=2025-08-12T14:30:08.221-07:00 level=ERROR source=$HOME/git/chainguard-dev/malcontent/pkg/action/scan.go:546 msg="unable to process mlflow-3.2.0-r0.apk: extract to temp: failed to walk directory: failed to extract archive: not a valid gzip archive: $HOME/tmp/mlflow-3.2.0-r0.apk2501165934/usr/share/mlflow/lib/python3.13/site-packages/joblib/test/data/joblib_0.10.0_compressed_pickle_py27_np17.gz"
💣 scan: extract to temp: failed to walk directory: failed to extract archive: not a valid gzip archive: $HOME/tmp/mlflow-3.2.0-r0.apk2501165934/usr/share/mlflow/lib/python3.13/site-packages/joblib/test/data/joblib_0.10.0_compressed_pickle_py27_np17.gz
```
However, when told to not exit on extraction errors, it then silently
skips them:
```
$ mal --exit-extraction=false scan mlflow-3.2.0-r0.apk
🔎 Scanning "mlflow-3.2.0-r0.apk"
```
This patch adjusts malcontent to report failures to extract archives,
even when continuing to process files, like so:
```
$ ~/git/chainguard-dev/malcontent/mal.adjusted --exit-extraction=false scan mlflow-3.2.0-r0.apk
🔎 Scanning "mlflow-3.2.0-r0.apk"
time=2025-08-12T14:29:40.086-07:00 level=ERROR source=$HOME/git/chainguard-dev/malcontent/pkg/action/scan.go:546 msg="unable to process mlflow-3.2.0-r0.apk: extract to temp: failed to walk directory: failed to extract archive: not a valid gzip archive: $HOME/tmp/mlflow-3.2.0-r0.apk1123830767/usr/share/mlflow/lib/python3.13/site-packages/joblib/test/data/joblib_0.10.0_compressed_pickle_py27_np17.gz"
$ echo $?
0
```
But still returns an error code when set to exit on extraction failures:
```
$ ~/git/chainguard-dev/malcontent/mal.adjusted scan mlflow-3.2.0-r0.apk
🔎 Scanning "mlflow-3.2.0-r0.apk"
time=2025-08-12T14:38:36.544-07:00 level=ERROR source=$HOME/git/chainguard-dev/malcontent/pkg/action/scan.go:546 msg="unable to process mlflow-3.2.0-r0.apk: extract to temp: failed to walk directory: failed to extract archive: not a valid gzip archive: $HOME/tmp/mlflow-3.2.0-r0.apk3305705399/usr/share/mlflow/lib/python3.13/site-packages/joblib/test/data/joblib_0.10.0_compressed_pickle_py27_np17.gz"
💣 scan: extract to temp: failed to walk directory: failed to extract archive: not a valid gzip archive: $HOME/tmp/mlflow-3.2.0-r0.apk3305705399/usr/share/mlflow/lib/python3.13/site-packages/joblib/test/data/joblib_0.10.0_compressed_pickle_py27_np17.gz
$ echo $?
2
```
Signed-off-by: Steve Beattie <steve.beattie@chainguard.dev>
* mal: don't exit on extraction errors by default
malcontent defaults to exiting on extraction errors by default, which
ends up being something a lot of people trip over when trying to figure
out what's being detected in an artifact. Fix that by defaulting to not
exiting on extraction errors (with the prior change, malcontent will
still report them).
Signed-off-by: Steve Beattie <steve.beattie@chainguard.dev>
---------
Signed-off-by: Steve Beattie <steve.beattie@chainguard.dev>1 parent d423a56 commit 78972f2
2 files changed
Lines changed: 6 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
291 | 291 | | |
292 | 292 | | |
293 | 293 | | |
294 | | - | |
| 294 | + | |
295 | 295 | | |
296 | 296 | | |
297 | 297 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
538 | 538 | | |
539 | 539 | | |
540 | 540 | | |
541 | | - | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
542 | 546 | | |
543 | 547 | | |
544 | 548 | | |
| |||
664 | 668 | | |
665 | 669 | | |
666 | 670 | | |
667 | | - | |
668 | | - | |
669 | | - | |
670 | | - | |
671 | | - | |
672 | 671 | | |
673 | 672 | | |
674 | 673 | | |
| |||
0 commit comments