Skip to content

Tag files that are whitedouts #1529

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scanpipe/migrations/0068_codebaseresource_is_whiteout.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.1.1 on 2025-03-22 14:19

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('scanpipe', '0067_discoveredpackage_notes'),
]

operations = [
migrations.AddField(
model_name='codebaseresource',
name='is_whiteout',
field=models.BooleanField(default=False, help_text='Indicates if this resource is a white-out file in a container scan.'),
),
]
4 changes: 4 additions & 0 deletions scanpipe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2497,6 +2497,10 @@ class FileClassifierFieldsModelMixin(models.Model):
"manifest file."
),
)
is_whiteout = models.BooleanField(
default=False,
help_text="Indicates if this resource is a white-out file in a container scan."
)

class Meta:
abstract = True
Expand Down
8 changes: 8 additions & 0 deletions scanpipe/pipelines/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def steps(cls):
cls.find_images_os_and_distro,
cls.collect_images_information,
cls.collect_and_create_codebase_resources,
cls.tag_whiteout_files,
cls.collect_and_create_system_packages,
cls.flag_uninteresting_codebase_resources,
cls.flag_empty_files,
Expand Down Expand Up @@ -85,3 +86,10 @@ def flag_uninteresting_codebase_resources(self):
"""Flag files that don't belong to any system package."""
docker.flag_whiteout_codebase_resources(self.project)
rootfs.flag_uninteresting_codebase_resources(self.project)

def tag_whiteout_files(project):
"""Tag resources that are white-out files in the container scan."""
for resource in project.codebaseresources.all():
if resource.name.startswith(".wh."):
resource.is_whiteout = True
resource.save(update_fields=["is_whiteout"])