From 342e6f35cc3df24a7690f7a0a46f77683019fa75 Mon Sep 17 00:00:00 2001 From: ziadhany Date: Tue, 17 Nov 2026 00:24:40 +0200 Subject: [PATCH 1/2] Update ImportFromScan to accept the new scan toolname Signed-off-by: ziadhany --- product_portfolio/importers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/product_portfolio/importers.py b/product_portfolio/importers.py index 8a06e75c..f02d7561 100644 --- a/product_portfolio/importers.py +++ b/product_portfolio/importers.py @@ -520,7 +520,7 @@ def validate_headers(self): scan_options = header.get("options", {}).keys() self.validate_toolkit_options(scan_options) - elif tool_name == "scanpipe": + elif tool_name in ("scanpipe", "ScanCode.io"): if not (self.data.get("packages") or self.data.get("dependencies")): raise ValidationError( "This ScanCode.io output does not include packages nor dependencies data." From cfc720e716d7f852f5910c51d71bae12d755f19d Mon Sep 17 00:00:00 2001 From: ziadhany Date: Tue, 17 Nov 2026 20:15:46 +0200 Subject: [PATCH 2/2] Add a test to ensure the legacy scanpipe tool name works Signed-off-by: ziadhany --- product_portfolio/tests/test_importers.py | 21 +++++++++++++++++++ .../scancodeio_scan_codebase_results.json | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/product_portfolio/tests/test_importers.py b/product_portfolio/tests/test_importers.py index f98a616f..61e6ddb1 100644 --- a/product_portfolio/tests/test_importers.py +++ b/product_portfolio/tests/test_importers.py @@ -843,6 +843,27 @@ def test_product_portfolio_product_import_from_scan_scanpipe_results(self): self.assertEqual([], warnings) self.assertEqual({}, created_counts) + def test_product_portfolio_product_import_from_scan_scanpipe_tool_name(self): + # Test import_from_scan using the legacy "scanpipe" tool_name. + scan_input_location = self.testfiles_path / "scancodeio_scan_codebase_results.json" + scan_data = json.loads(scan_input_location.read_text()) + scan_data["headers"][0]["tool_name"] = "scanpipe" + + with tempfile.TemporaryDirectory() as tmp_dir: + edited_input_location = Path(tmp_dir) / scan_input_location.name + edited_input_location.write_text(json.dumps(scan_data)) + upload_file = wrap_as_temp_uploaded_file(edited_input_location) + importer = ImportFromScan(self.product1, self.super_user, upload_file) + warnings, created_counts = importer.save() + + self.assertEqual([], warnings) + self.assertEqual( + {"Packages": 1, "Product Packages": 1, "Codebase Resources": 3}, created_counts + ) + self.assertEqual(1, self.product1.packages.count()) + self.assertEqual(1, self.product1.productpackages.count()) + self.assertEqual(3, self.product1.codebaseresources.count()) + def test_product_portfolio_product_import_from_scan_package_without_purl(self): scan_input_location = self.testfiles_path / "package_without_purl.json" upload_file = wrap_as_temp_uploaded_file(scan_input_location) diff --git a/product_portfolio/tests/testfiles/scancodeio_scan_codebase_results.json b/product_portfolio/tests/testfiles/scancodeio_scan_codebase_results.json index 0ff1511d..469cfdae 100644 --- a/product_portfolio/tests/testfiles/scancodeio_scan_codebase_results.json +++ b/product_portfolio/tests/testfiles/scancodeio_scan_codebase_results.json @@ -1,7 +1,7 @@ { "headers": [ { - "tool_name": "scanpipe", + "tool_name": "ScanCode.io", "tool_version": "32.0.1", "notice": "Generated with ScanCode.io and provided on an \"AS IS\" BASIS, WITHOUT WARRANTIES\nOR CONDITIONS OF ANY KIND, either express or implied.\nNo content created from ScanCode.io should be considered or used as legal advice.\nConsult an Attorney for any legal advice.\nScanCode.io is a free software code scanning tool from nexB Inc. and others\nlicensed under the Apache License version 2.0.\nScanCode is a trademark of nexB Inc.\nVisit https://github.com/nexB/scancode.io for support and download.\n", "uuid": "35ee6b2b-88b3-4baf-9d40-5bd7e56c9741",