scancode.io icon indicating copy to clipboard operation
scancode.io copied to clipboard

Improve scan_for_virus robustness and add missing resource test

Open dikshaa2909 opened this issue 9 months ago • 2 comments

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

dikshaa2909 avatar Mar 03 '26 09:03 dikshaa2909

Hi @tdruez @pombredanne can you pls review !!

dikshaa2909 avatar Mar 04 '26 09:03 dikshaa2909

Hi @tdruez @pombredanne can u pls review it when u have time ! Thanks !

dikshaa2909 avatar Mar 09 '26 06:03 dikshaa2909

Fixed in https://github.com/aboutcode-org/scancode.io/pull/2190

tdruez avatar Jul 09 '26 11:07 tdruez