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(debian): move *.list dpkg analyzer to separate analyzer #6682

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

DmitriyLewen
Copy link
Contributor

Description

dpkg contains all installed packages in var/lib/dpkg/status file. But installed files for each package are stored invar/lib/dpkg/info/<pkg_name>.list files.
Therefore, when we work with packages at different levels, we can overwrite system files.

e.g.:

FROM Ubuntu
RUN apt install curl -y

— line 1: We parse default installed packages with their system files.
— line 2: install new package. var/lib/dpkg/status will be updated at this layer (curl will be added). Therefore, we find all packages of first layer + curl. But second layer only includes var/lib/dpkg/info/curl.list file, so system files for first layer packages will be overwritten with empty value and we will not include this in report.

This PR moves analyze of *.list files (saving system files for each package) to separate analyzer.
System files will be merged with packages when layers are applied.

before:

➜ trivy -q image -f json --list-all-pkgs nginx | jq '.Results[].Packages[] | select(.ID=="[email protected]") | .InstalledFiles'
null

after:

➜  trivy git:(fix-dpkg/separate-analyzer-for-lists) ./trivy -q image -f json --list-all-pkgs nginx | jq '.Results[].Packages[] | select(.ID=="[email protected]") | .InstalledFiles'
[
  "/etc/adduser.conf",
  "/etc/deluser.conf",
  "/usr/sbin/addgroup",
  "/usr/sbin/adduser",
  "/usr/sbin/delgroup",
  "/usr/sbin/deluser",
  "/usr/share/doc/adduser/NEWS.Debian.gz",
   ...
  "/var/cache/adduser"
]

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).

@DmitriyLewen DmitriyLewen self-assigned this May 14, 2024
@DmitriyLewen DmitriyLewen changed the title Fix dpkg/separate analyzer for lists fix(dpkg): move *.list file analyzer to separate analyzer May 14, 2024
@DmitriyLewen DmitriyLewen changed the title fix(dpkg): move *.list file analyzer to separate analyzer fix(debian): move *.list dpkg analyzer to separate analyzer May 14, 2024
@DmitriyLewen DmitriyLewen marked this pull request as ready for review May 14, 2024 11:51
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.

scan image with --list-all-pkgs flag has missing os installed files with in the report
1 participant