No license information for binutils-aarch64-linux-gnu #8391
-
DescriptionGood day, have next issue and need help to resolve it. Dockerfile: FROM ubuntu But when I try to get license information for binutils-aarch64-linux-gnu package - I don't have it. trivy image --format cyclonedx --output 1.json {my_image} --license-full --debug --license-confidence-level=0.1 So as you can see google classifier (https://github.com/google/licenseclassifier) should check the content of /usr/share/doc/binutils-aarch64-linux-gnu/copyright file But if I use identify_license (v2) it produce me correct information: 2025/02/12 14:50:25 Classifying license(s): /usr/share/doc/binutils-aarch64-linux-gnu/copyright As I can see both projects assets.DefaultClassifier() So I can't understand why identify_license can get license information, and trivy don't Desired Behaviortrivy find license information for binutils-aarch64-linux-gnu Actual Behaviortrivy don't find license information for binutils-aarch64-linux-gnu Reproduction Steps1. run: trivy image --format cyclonedx --output 1.json {my_image} --license-full --debug --license-confidence-level=0.1
2. run: identify_license /usr/share/doc/binutils-aarch64-linux-gnu/copyright (headers option must be set to true)
3. identify_license find license, trivy don't.
... TargetNone ScannerNone Output FormatNone ModeNone Debug Outputtrivy image --format cyclonedx --output /Users/albe/1.json albe_image --license-full --debug --license-confidence-level=0.1
2025-02-12T15:28:48+03:00 DEBUG No plugins loaded
2025-02-12T15:28:48+03:00 DEBUG Default config file "file_path=trivy.yaml" not found, using built in values
2025-02-12T15:28:48+03:00 DEBUG Cache dir dir="/Users/albe/Library/Caches/trivy"
2025-02-12T15:28:48+03:00 DEBUG Cache dir dir="/Users/albe/Library/Caches/trivy"
2025-02-12T15:28:48+03:00 DEBUG Parsed severities severities=[UNKNOWN LOW MEDIUM HIGH CRITICAL]
2025-02-12T15:28:48+03:00 DEBUG Ignore statuses statuses=[]
2025-02-12T15:28:48+03:00 INFO "--format cyclonedx" disables security scanning. Specify "--scanners vuln" explicitly if you want to include vulnerabilities in the "cyclonedx" report.
2025-02-12T15:28:48+03:00 DEBUG [pkg] Package types types=[os library]
2025-02-12T15:28:48+03:00 DEBUG [pkg] Package relationships relationships=[unknown root workspace direct indirect]
2025-02-12T15:28:48+03:00 DEBUG Initializing scan cache... type="fs"
2025-02-12T15:28:48+03:00 DEBUG [image] Detected image ID image_id="sha256:cbdc5bd9e29ebf8921c9ecafea2fb3f94eba51385dd23a550023096df46b5d04"
2025-02-12T15:28:48+03:00 DEBUG [image] Detected diff ID diff_ids=[sha256:375990b2a90a8d8f332d9b9422d948f7068a3313bf5a1c9fbb91ff2d29046130 sha256:b1378c57a3b9d6c70f56a179300f20978a34ab64f5bf7d7a5ae909c901a1ebe7]
2025-02-12T15:28:48+03:00 DEBUG [image] Detected base layers diff_ids=[sha256:375990b2a90a8d8f332d9b9422d948f7068a3313bf5a1c9fbb91ff2d29046130]
2025-02-12T15:28:48+03:00 DEBUG [image] Missing image ID in cache image_id="sha256:cbdc5bd9e29ebf8921c9ecafea2fb3f94eba51385dd23a550023096df46b5d04"
2025-02-12T15:28:48+03:00 DEBUG [image] Missing diff ID in cache diff_id="sha256:375990b2a90a8d8f332d9b9422d948f7068a3313bf5a1c9fbb91ff2d29046130"
2025-02-12T15:28:48+03:00 DEBUG [image] Missing diff ID in cache diff_id="sha256:b1378c57a3b9d6c70f56a179300f20978a34ab64f5bf7d7a5ae909c901a1ebe7"
2025-02-12T15:28:48+03:00 DEBUG [dpkg] Unable to parse the available file file_path="var/lib/dpkg/available" err="file open error: open var/lib/dpkg/available: file does not exist"
2025-02-12T15:28:49+03:00 DEBUG Loading the default license classifier...
2025-02-12T15:28:49+03:00 DEBUG No secrets found in container image config
2025-02-12T15:28:49+03:00 INFO Detected OS family="ubuntu" version="24.04"
2025-02-12T15:28:49+03:00 INFO Number of language-specific files num=0
2025-02-12T15:28:49+03:00 DEBUG Specified ignore file does not exist file=".trivyignore"
2025-02-12T15:28:49+03:00 DEBUG [vex] VEX filtering is disabled Operating SystemMac Version0.59.1 Checklist
|
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 33 replies
-
Helllo @albe19029 For ➜ docker run -it --rm 8391 ls -ahl /usr/share/doc | grep binutils-aarch64-linux-gnu
lrwxrwxrwx 1 root root 11 Aug 7 2024 binutils-aarch64-linux-gnu -> libbinutils Trivy doesn't currently support links - #5356 Regards, Dmitriy |
Beta Was this translation helpful? Give feedback.
-
Thanks for the clarification |
Beta Was this translation helpful? Give feedback.
-
As I understand here we skip symlinks ((https://github.com/aquasecurity/trivy/blob/main/pkg/fanal/walker/tar.go#L74) But can we modify dpkgLicenseAnalyzer to make it PostAnalyzer? In this case we can implement Required method to get all /usr/share/doc/*/copyright files, and then in Analyze we will have all files content to read it without new tar iteration? And we only need to pass symlink and process it here: (https://github.com/aquasecurity/trivy/blob/main/pkg/fanal/artifact/image/image.go#L385) Maybe I missed something, correct me if I am wrong. In other case can we do that? |
Beta Was this translation helpful? Give feedback.
-
But I don't want to change this logic, I just want to resolve symlinks from other layes, by coping directory content from other lower layers filesystems. So from my perspective a.walker.Walk will execute for every layer. But then they all will wait to all layers. And having in case symlink is on another layer - files will be copied from another compositeFile. but as I will copy it with symlink name all layers will have only their files, but with resolve symlinks. No need to change logic with caches. |
Beta Was this translation helpful? Give feedback.
-
How do you think is it possible to provide original filesystem fs.FS in analyzer.PostAnalysisInput (in filesystem type). In this case it will be possible to read file having package name without iteration on filesystem. So if for example we detected package binutils-aarch64-linux-gnu we can check /usr/share/doc/binutils-aarch64-linux-gnu/copyright, even if it is a symlink. It will not fix image type, but at least filesystem type will produce correct information, as it has only one layer. |
Beta Was this translation helpful? Give feedback.
-
I have much better implementation now. #8432 So basic idea:
|
Beta Was this translation helpful? Give feedback.
Helllo @albe19029
Thanks for your report!
For
deb
packages Trivy detects licenses from/usr/share/doc/*/copyright
files.But file for
binutils-aarch64-linux-gnu
is link:Trivy doesn't currently support links - #5356
Regards, Dmitriy