Skip to content

Commit eee8a86

Browse files
committed
Clear to_codebase status before D2D #1938
* Many D2D steps look for resources without a status. However, the earlier scanning step flags all resources as "scanned". To prevent D2D steps from skipping these resources, we clear the status of all `to` resources Signed-off-by: Chin Yeung Li <tli@nexb.com>
1 parent 57de8f9 commit eee8a86

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

scanpipe/pipelines/scan_nix_package.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ def steps(cls):
5757
cls.collect_and_create_codebase_resources,
5858
cls.scan_for_application_packages,
5959
cls.scan_for_files,
60+
cls.clear_to_codebase_status,
6061
cls.collect_and_create_license_detections,
6162
cls.add_from_to_tag,
6263
cls.d2d_steps,
6364
cls.validate_package_license_integrity,
64-
cls.flag_mapped_status,
6565
cls.cleanup_docker_volumes,
6666
)
6767

@@ -120,6 +120,13 @@ def extract_input_to_codebase_directory(self):
120120

121121
self.env = self.project.get_env()
122122

123+
def clear_to_codebase_status(self):
124+
"""
125+
Clear the status of the to codebase resources in the project as
126+
having status will prevent D2D from running.
127+
"""
128+
flag.clear_status(self.project.codebaseresources.to_codebase())
129+
123130
def add_from_to_tag(self):
124131
"""Update 'from' and 'to' tag to resources based on their path."""
125132
if self.d2d_enable:
@@ -212,9 +219,6 @@ def d2d_process(self):
212219
self.perform_house_keeping_tasks()
213220
self.match_purldb_resources_post_process()
214221
self.remove_packages_without_resources()
215-
self.scan_ignored_to_files()
216-
self.scan_unmapped_to_files()
217-
self.scan_mapped_from_for_files()
218222
self.flag_deployed_from_resources_with_missing_license()
219223
self.create_local_files_packages()
220224

scanpipe/pipes/d2d.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,8 @@ def _map_checksum_resource(to_resource, from_resources, checksum_field):
141141

142142
def map_checksum(project, checksum_field, logger=None):
143143
"""Map using checksum."""
144-
project_files = project.codebaseresources.files().no_status()
145-
from_resources = project_files.from_codebase().has_value(checksum_field)
146-
to_resources = (
147-
project_files.to_codebase().has_value(checksum_field).has_no_relation()
148-
)
144+
from_resources = project.codebaseresources.files().from_codebase().has_value(checksum_field)
145+
to_resources = project.codebaseresources.files().to_codebase().has_value(checksum_field).has_no_relation()
149146
resource_count = to_resources.count()
150147

151148
if logger:

scanpipe/pipes/flag.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,8 @@ def flag_mapped_resources(project):
139139
"""Flag all codebase resources that were mapped during the d2d pipeline."""
140140
resources = project.codebaseresources.has_relation().no_status()
141141
return resources.update(status=MAPPED)
142+
143+
144+
def clear_status(resource_qs):
145+
"""Clear the status of given codebase resources."""
146+
return resource_qs.update(status="")

0 commit comments

Comments
 (0)