diff --git a/scanpipe/migrations/0068_codebaseresource_is_whiteout.py b/scanpipe/migrations/0068_codebaseresource_is_whiteout.py new file mode 100644 index 000000000..99c38b413 --- /dev/null +++ b/scanpipe/migrations/0068_codebaseresource_is_whiteout.py @@ -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.'), + ), + ] diff --git a/scanpipe/models.py b/scanpipe/models.py index f54395b05..b0e160392 100644 --- a/scanpipe/models.py +++ b/scanpipe/models.py @@ -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 diff --git a/scanpipe/pipelines/docker.py b/scanpipe/pipelines/docker.py index 5bf338458..65fcd18de 100644 --- a/scanpipe/pipelines/docker.py +++ b/scanpipe/pipelines/docker.py @@ -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, @@ -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"])