scancode.io
scancode.io copied to clipboard
Improve scan_for_virus robustness and add missing resource test
Issues
- Closes: #2019
Changes
This improves the robustness of scan_for_virus when ClamAV reports files that are not indexed in CodebaseResource.
Previously, .get(path=...) could raise DoesNotExist, causing the pipeline to fail when ClamAV returned a file not present in the database.
This change:
- Avoids exception-driven control flow
- Preloads indexed resource paths to prevent per-file DB lookups
- Safely skips non-indexed infected files
- Preserves existing virus detection behavior
- Fixes typo in extra_data key (
calmav→clamav) - Adds a regression test covering the missing-resource scenario
Checklist
- [x] I have read the contributing guidelines
- [x] I have linked an existing issue above
- [x] I have added unit tests covering the new code
- [x] I have reviewed and understood every line of this PR
Hi @tdruez @pombredanne can you pls review !!
Hi @tdruez @pombredanne can u pls review it when u have time ! Thanks !
Fixed in https://github.com/aboutcode-org/scancode.io/pull/2190