Skip to content

Commit ac28398

Browse files
committed
tag-whitedout files
Signed-off-by: Varsha U N <[email protected]>
1 parent a8b28da commit ac28398

File tree

4 files changed

+30
-12
lines changed

4 files changed

+30
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 5.1.1 on 2025-03-22 14:19
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('scanpipe', '0067_discoveredpackage_notes'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='codebaseresource',
15+
name='is_whiteout',
16+
field=models.BooleanField(default=False, help_text='Indicates if this resource is a white-out file in a container scan.'),
17+
),
18+
]

scanpipe/models.py

+4-10
Original file line numberDiff line numberDiff line change
@@ -2497,6 +2497,10 @@ class FileClassifierFieldsModelMixin(models.Model):
24972497
"manifest file."
24982498
),
24992499
)
2500+
is_whiteout = models.BooleanField(
2501+
default=False,
2502+
help_text="Indicates if this resource is a white-out file in a container scan."
2503+
)
25002504

25012505
class Meta:
25022506
abstract = True
@@ -2609,16 +2613,6 @@ class Type(models.TextChoices):
26092613
)
26102614

26112615
objects = CodebaseResourceQuerySet.as_manager()
2612-
labels = TaggableManager(through=UUIDTaggedItem, ordering=["name"])
2613-
2614-
@staticmethod
2615-
def is_white_out_file(file_path):
2616-
return file_path.endswith(".whiteout")
2617-
2618-
def tag_white_out_files(self):
2619-
if self.is_white_out_file(self.path):
2620-
self.labels.add("white-out")
2621-
self.save()
26222616

26232617
class Meta:
26242618
indexes = [

scanpipe/pipelines/docker.py

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def steps(cls):
3636
cls.find_images_os_and_distro,
3737
cls.collect_images_information,
3838
cls.collect_and_create_codebase_resources,
39+
cls.tag_whiteout_files,
3940
cls.collect_and_create_system_packages,
4041
cls.flag_uninteresting_codebase_resources,
4142
cls.flag_empty_files,
@@ -85,3 +86,10 @@ def flag_uninteresting_codebase_resources(self):
8586
"""Flag files that don't belong to any system package."""
8687
docker.flag_whiteout_codebase_resources(self.project)
8788
rootfs.flag_uninteresting_codebase_resources(self.project)
89+
90+
def tag_whiteout_files(project):
91+
"""Tag resources that are white-out files in the container scan."""
92+
for resource in project.codebaseresources.all():
93+
if resource.name.startswith(".wh."):
94+
resource.is_whiteout = True
95+
resource.save(update_fields=["is_whiteout"])

scanpipe/pipes/resolve.py

-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ def resolve_manifest_resources(resource,package_registry):
5353
for package_data in packages:
5454
package_data["codebase_resources"] = [resource]
5555

56-
resource.tag_white_out_files()
57-
5856
return packages
5957

6058

0 commit comments

Comments
 (0)