chainguard-dev / malcontent

#supply #chain #attack #detection
Apache License 2.0
446 stars 31 forks source link

walk: log error instead of returning an error #538

Closed tstromberg closed 3 weeks ago

tstromberg commented 3 weeks ago

Previously, if walk was unable to traverse a directory, it would exit without scanning any files:

🔎 Scanning "/etc"
error: scan: find: walk: open /etc/credstore: permission denied
exit status 2

With this PR, it just logs noisy error messages and keeps on trucking:

🔎 Scanning "/etc"
time=2024-10-23T20:53:27.491-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/credstore: open /etc/credst
ore: permission denied"
time=2024-10-23T20:53:27.491-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/credstore.encrypted: open /
etc/credstore.encrypted: permission denied"
time=2024-10-23T20:53:27.492-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/multipath: open /etc/multip
ath: permission denied"
time=2024-10-23T20:53:27.492-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/polkit-1/rules.d: open /etc
/polkit-1/rules.d: permission denied"
time=2024-10-23T20:53:27.493-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/ssl/private: open /etc/ssl/
private: permission denied"
time=2024-10-23T20:53:27.493-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:57 msg="error: /etc/sudoers.d: open /etc/sudoer
s.d: permission denied"
time=2024-10-23T20:53:27.494-04:00 level=ERROR source=/Users/t/src/bincapz/pkg/action/scan.go:100 msg="file type failure: /etc/.pwd.lock: ope
n: open /etc/.pwd.lock: permission denied" path=/etc/.pwd.lock