Skip to content

Commit

Permalink
Remove the restrictive pipeline name validation in import #138
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez committed Aug 2, 2024
1 parent 93724bc commit 6cee948
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 27 deletions.
30 changes: 4 additions & 26 deletions product_portfolio/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,10 @@ def validate_headers(self):
self.validate_toolkit_options(scan_options)

elif tool_name == "scanpipe":
pass
# TODO: Reconsider the value of this, as if there's packages data we should
# runs = header.get("runs", [])
# accept the input anyway
# self.validate_pipeline_runs(runs)
if not (self.data.get("packages") or self.data.get("dependencies")):
raise ValidationError(
"This ScanCode.io output does not include packages nor dependencies data."
)

@staticmethod
def validate_toolkit_options(scan_options):
Expand All @@ -464,27 +463,6 @@ def validate_toolkit_options(scan_options):
options_str = " ".join(missing_options)
raise ValidationError(f"The Scan run is missing those required options: {options_str}")

# @staticmethod
# def validate_pipeline_runs(runs):
# """Raise a ValidationError if at least one of the supported pipeline was not run."""
# valid_pipelines = (
# "analyze_docker_image",
# "analyze_root_filesystem_or_vm_image",
# "analyze_windows_docker_image",
# "inspect_packages",
# "map_deploy_to_develop",
# "scan_codebase",
# "scan_single_package",
# )
#
# has_a_valid_pipeline = [True for run in runs if run.get("pipeline_name") in
# valid_pipelines]
#
# if not has_a_valid_pipeline:
# raise ValidationError(
# "This ScanPipe output does not have results from a valid pipeline."
# )

def import_packages(self):
product_packages_count = 0
packages_count = 0
Expand Down
2 changes: 1 addition & 1 deletion product_portfolio/tests/test_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,7 @@ def test_product_portfolio_product_import_from_scan_input_file_errors(self):
with self.assertRaisesMessage(ValidationError, expected):
importer.save()

expected = "This ScanPipe output does not have results from a valid pipeline."
expected = "'This ScanCode.io output does not include packages nor dependencies data."
scan_input_location = self.testfiles_path / "missing_correct_pipeline.json"
importer = ImportFromScan(self.product1, self.super_user, scan_input_location)
with self.assertRaisesMessage(ValidationError, expected):
Expand Down

0 comments on commit 6cee948

Please sign in to comment.