chainguard-dev / bincapz

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

Miscellaneous tweaks, additions, and performance improvements #236

Closed egibs closed 1 month ago

egibs commented 1 month ago

This PR has a few tweaks to consolidate string matching logic and improve performance along with some other miscellaneous changes.

On the performance side, I replaced filepath.Walk with filepath.WalkDir when recursively looking for files in a given scan path. With the code in main, scanning the Linux repository consisting of ~85,000 files took roughly ~4 minutes. With these changes, the scan takes about ~3 1/2 which is a decent improvement.

The other changes are mostly just syntax changes, though I did add a few more program kinds for the sake of completion along with a test and benchmark for longestUnique since it looks like a possible area for future optimization.