mirror of
https://github.com/mandiant/capa.git
synced 2026-03-12 21:23:12 -07:00
* loader: handle struct.error from dnfile and show clear CorruptFile message When .NET metadata is truncated or invalid, dnfile can raise struct.error. Catch it in DnfileFeatureExtractor and DotnetFileFeatureExtractor and re-raise as CorruptFile with a user-friendly message. Fixes #2442 * dnfile: centralize dnPE() loading in load_dotnet_image helper Add load_dotnet_image() to dnfile/helpers.py that calls dnfile.dnPE() and catches struct.error, raising CorruptFile with the original error message included (f"Invalid or truncated .NET metadata: {e}"). Both DnfileFeatureExtractor and DotnetFileFeatureExtractor now call the helper instead of duplicating the try/except block, and their direct import of struct is removed. Addresses review feedback on #2872. * style: reformat dnfile files with black --line-length=120 Fixes CI code_style failure by applying the project's configured line length (120) instead of black's default (88). --------- Co-authored-by: Moritz <mr-tz@users.noreply.github.com> Co-authored-by: Mike Hunhoff <mike.hunhoff@gmail.com>