fix empty licenses for dpkg if package dir is symlink (filesystem sca… #8424
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently trivy don't support symlinks as they can create loops and that is why filepath.WalkDir skips them.
When we skip symlink directories in /usr/share/doc - packages with the same directory name don't have licenses.
It is hard to sync symlinks if they located on different layers, but for local filesystem we have only one layer. So we don't need to sync anything. In case we know exact path of license path (and for dpkg packages we know) and we have access to filesystem we can resolve this symlinks by just reading file. As we read it by full path, and there are no iterations by directories it is safe.
So in this fix we produce dpkg analyzer with access to local filesystem to read files from there. The same action with file read can be done with other analyzers.
After this change if we scan trivy with filesystem scan all dkpg packages which has symlink directory will be resolved.
Image scan will work as before, as it is impossible for now to fix it:
This all requires a lot of changes in cache.