aquasecurity / fanal

Static Analysis Library for Containers
Apache License 2.0
199 stars 100 forks source link

fix(config): skip json config if type is not detected #513

Closed DmitriyLewen closed 2 years ago

DmitriyLewen commented 2 years ago

Description

Fanal saves all json file from system as config files. If there are a lot of json files in the system, it can cause a lot of memory usage. Added skip json files without config type.

liamg commented 2 years ago

I think it might be a nice approach to refactor types.File to instead hold a function which provides a reader to a file e.g. func() (io.Reader, error), instead of holding the raw []byte slice itself. That way we only read files into memory when we need to process them. WDYT?

knqyf263 commented 2 years ago

I did it at the beginning because that is why I asked you to add LazyMemoryFS. After some refactoring, I switched to []byte for some reason. But it is worth trying it again. @liamg Could you take it over? @DmitriyLewen Let me close this PR. Thanks.