Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion product_portfolio/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
21 changes: 21 additions & 0 deletions product_portfolio/tests/test_importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
Loading