syft
syft copied to clipboard
fix: better clean up of file handles
Previously, the ELF binary package cataloger would leak file handles, and the generic cataloger loop would leak file handles if parsing the file panicked. Instead, ensure both situations defer close new file readers as soon as they are made.
The incorrect behavior had been happening for some time, but was probably exposed by #2814 which caused the ELF binary package cataloger to rely more on file handles and less on in-memory buffers.
Fixes #2819 - in my testing, syft 1.3.0 needs about 1500 concurrent file handles to parse pytorch/pytorch:latest; after this change, the number is closer to 800.