Replies: 2 comments 1 reply
-
Hello @andaaron Created #5272 Regards, Dmitriy |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you @DmitriyLewen, I tested the fix locally, and it's working. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
We are importing trivy as a library to scan images hosted in the container image registry we develop, zot.
Trivy is running in zot server side, scanning images from the local the oci layout.
For the most part it is working well, but recently we started scanning images containing Java files.
It looks like every time we scan an image containing Java files, a new file descriptor for
trivy-java.db
is added, but not closed after the scan is done. The scan is functioning correctly, but it seems like the Java DB is not properly closed.The code where we are importing an scanning using trivy is at:https://github.com/project-zot/zot/blob/3a9a9327919ff51309269a288ecbd72b550be9d0/pkg/extensions/search/cve/trivy/scanner.go
More specifically setting up the general scan options:
https://github.com/project-zot/zot/blob/3a9a9327919ff51309269a288ecbd72b550be9d0/pkg/extensions/search/cve/trivy/scanner.go#L39
Setting up the input, as a local OCI image in local layout:
https://github.com/project-zot/zot/blob/3a9a9327919ff51309269a288ecbd72b550be9d0/pkg/extensions/search/cve/trivy/scanner.go#L156
Calling the Trivy APIs using the above options as parameters:
https://github.com/project-zot/zot/blob/3a9a9327919ff51309269a288ecbd72b550be9d0/pkg/extensions/search/cve/trivy/scanner.go#L170
Note the Java DB is downloaded in a separate API call, and that calls seems to be OK, no leaking file descriptor for just the download.
The leak seems to be related to the actual scan, or analyzer.
Maybe the sqlite DB is not properly closed after being used?
Note there are no such issues with the other DBs, trivy.db and fanal.db.
Desired Behavior
After the scan is done we shouldn't see a file descriptor open for trivy-java.db.
Actual Behavior
For a very large number of images/scans we can get into this situation
Reproduction Steps
Target
Container Image
Scanner
Vulnerability
Output Format
JSON
Mode
Standalone
Debug Output
Operating System
Ubuntu 20.04.1
Version
Checklist
trivy image --reset
Beta Was this translation helpful? Give feedback.
All reactions