Trivy fails to parse Rancher binary's -ldflags due to unsupported flags like -extldflags #8363
Closed
kerringtonwells
started this conversation in
Bugs
Replies: 1 comment 1 reply
-
Hello @kerringtonwells Created #8365 for this task. Rehards, Dmitriy |
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
Trivy is encountering issues parsing strings from the Rancher binary and extracting version information. This prevents it from correctly mapping the Rancher version to known CVEs.
Function that is failing to parse -ldflags for reference:
https://github.com/aquasecurity/trivy/blob/main/pkg/dependency/parser/golang/binary/parse.go#L154
The function above is unable to properly parse the following:
-ldflags="-X github.com/rancher/rancher/pkg/version.Version=v2.8.4 -X github.com/rancher/rancher/pkg/version.GitCommit=29572e61e -X github.com/rancher/rancher/pkg/settings.InjectDefaults={"rke-version":"v1.5.9"} -extldflags -static -s"
Desired Behavior
Trivy should:
Actual Behavior
strings rancher |grep ldflags
-ldflags="-X github.com/rancher/rancher/pkg/version.Version=v2.8.4 -X github.com/rancher/rancher/pkg/version.GitCommit=29572e61e -X github.com/rancher/rancher/pkg/settings.InjectDefaults={"rke-version":"v1.5.9"} -extldflags -static -s"
This causes the pflag library to fail with the error:
pflag: help requested
Trivy is unable to extract the Rancher version or map it to CVEs.
The function below in Trivy's code fails to correctly parse the -ldflags strings from the Rancher binary.
https://github.com/aquasecurity/trivy/blob/main/pkg/dependency/parser/golang/binary/parse.go#L154
Reproduction Steps
Target
Container Image
Scanner
Vulnerability
Output Format
JSON
Mode
Standalone
Debug Output
Operating System
debian:bookworm-slim
Version
Checklist
trivy clean --all
Beta Was this translation helpful? Give feedback.
All reactions