Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: skip only absolute filesystem dirs #6657

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nikpivkin
Copy link
Contributor

Description

Related issues

Checklist

  • I've read the guidelines for contributing to this repository.
  • I've followed the conventions in the PR title.
  • I've added tests that prove my fix is effective or that my feature works.
  • I've updated the documentation with the relevant information (if needed).
  • I've added usage information (if the PR introduces new options)
  • I've included a "before" and "after" example to the description (if the PR is a user interface change).

@nikpivkin nikpivkin marked this pull request as ready for review May 13, 2024 03:47
@knqyf263
Copy link
Collaborator

@DmitriyLewen Can you please test this change?

@DmitriyLewen
Copy link
Contributor

@nikpivkin
These changes break image scanning:

➜ cat Dockerfile 
FROM ubuntu

COPY log4j-core-2.16.0.jar /sys/log4j-core-2.16.0.jar

COPY log4j-core-2.16.0.jar /dev/log4j-core-2.16.0.jar

➜ ./trivy image 6657 -f json --list-all-pkgs | jq '.Results[].Packages[] | select(.Name=="org.apache.logging.log4j:log4j-core")'
{
  "Name": "org.apache.logging.log4j:log4j-core",
  "Identifier": {
    "PURL": "pkg:maven/org.apache.logging.log4j/[email protected]",
    "UID": "1b4b8d0c2ceb5ca0"
  },
  "Version": "2.16.0",
  "Layer": {
    "DiffID": "sha256:74750d50e4fa74a48fe7866ed1e7f5f6f16c03e9504bf11412d12b7768e5e00d"
  },
  "FilePath": "sys/log4j-core-2.16.0.jar"
}
{
  "Name": "org.apache.logging.log4j:log4j-core",
  "Identifier": {
    "PURL": "pkg:maven/org.apache.logging.log4j/[email protected]",
    "UID": "a983edae42e3121e"
  },
  "Version": "2.16.0",
  "Layer": {
    "DiffID": "sha256:d8b26baefb6f0e55808ab1a5cb920497cabeac307b1cf46d06d5b27b68fc5924"
  },
  "FilePath": "dev/log4j-core-2.16.0.jar"
}

rootfs and fs modes also don't work (/proc dir is scanned):

root@ce1618593f59:/# ./trivy fs / -f json --list-all-pkgs
...
2024-05-14T06:36:48Z	FATAL	Fatal error	filesystem scan error: scan error: scan failed: failed analysis: walk filesystem: walk dir error: unknown error with /proc/3098/fdinfo/11: file info error: lstat /proc/3098/fdinfo/11: no such file or directory
root@ce1618593f59:/# ./trivy rootfs / -f json --list-all-pkgs
...
2024-05-14T06:36:51Z	FATAL	Fatal error	rootfs scan error: scan error: scan failed: failed analysis: walk filesystem: walk dir error: unknown error with /proc/3111/fdinfo/11: file info error: lstat /proc/3111/fdinfo/11: no such file or directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix: skip only absolute filesystem dirs
3 participants