-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add basic zstd compression support #842
feat: add basic zstd compression support #842
Conversation
A couple of more broad thoughts:
|
Method looks good to me -- can you add malcontent/pkg/archive/archive.go Lines 202 to 222 in 5254e43
|
Malcontent was not properly scanning zstd compressed files e.g. kernel modules on modern Ubuntu systems. As an example, without this change: ``` $ mal --format=simple --verbose analyze /lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst time=2025-03-24T20:51:36.262-07:00 level=DEBUG source=$HOME/git/chainguard-dev/malcontent/pkg/action/scan.go:71 msg="skipping /usr/lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst [<unknown>]: data file or empty" path=/usr/lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst ``` With this patch applied: ``` $ ./mal --format=simple --verbose analyze /lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst time=2025-03-24T20:53:47.375-07:00 level=DEBUG source=$HOME/git/chainguard-dev/malcontent/pkg/archive/archive.go:110 msg="creating temp dir" path=/usr/lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst time=2025-03-24T20:53:47.375-07:00 level=DEBUG source=$HOME/git/chainguard-dev/malcontent/pkg/archive/zstd.go:18 msg="extracting zstd" dir=$HOME/tmp/ksmbd.ko.zst439390431 file=/usr/lib/modules/6.11.0-19-generic/kernel/fs/smb/server/ksmbd.ko.zst c2/addr/ip: medium crypto/aes: low crypto/cipher: medium fs/attributes/remove: medium fs/attributes/set: medium fs/directory/create: low fs/directory/remove: low fs/file/delete: low fs/file/open: low fs/lock_update: low impact/remote_access/heartbeat: medium net/ip/send_unicast: low net/rpc/ntlm: medium net/socket/listen: medium net/socket/peer_address: low net/socket/receive: low net/socket/send: low os/kernel/netlink: low persist/daemon: medium persist/kernel_module/module: medium persist/kernel_module/name: medium sus/exclamation: medium ``` This patch was mostly copy-wasting from the bz2 archive implementation and cherry-picking bits and bobs from the zstd support in the rpm.go implementation. v2: pick up missed change to add the zst and zstd extensions to ExtractMethod(). Signed-off-by: Steve Beattie <[email protected]>
fdae0a5
to
d1f3a42
Compare
Doh, I had made that change locally, but missed adding it to the commit; the dangers of late night hacking. Added and pushed. |
Malcontent was not properly scanning zstd compressed files e.g. kernel modules on modern Ubuntu systems. As an example, without this change:
With this patch applied:
This patch was mostly copy-wasting from the bz2 archive implementation and cherry-picking bits and bobs from the zstd support in the rpm.go implementation.