Skip to content

Commit

Permalink
Load the LAYERS sheet data in load_inventory_from_xlsx #1490 (#1491)
Browse files Browse the repository at this point in the history
Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez authored Dec 31, 2024
1 parent 1a6318f commit d0f5280
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 4 additions & 1 deletion scanpipe/pipes/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
# Visit https://github.com/aboutcode-org/scancode.io for support and download.

import shutil
from pathlib import Path

Expand Down Expand Up @@ -199,3 +198,7 @@ def load_inventory_from_xlsx(project, input_location):
cleaned_data = clean_xlsx_data_to_model_data(model_class, row_data)
if cleaned_data:
object_maker_func(project, cleaned_data)

if "LAYERS" in workbook:
layers_data = get_worksheet_data(worksheet=workbook["LAYERS"])
project.update_extra_data({"layers": layers_data})
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"layers": [
{
"size": "5886464",
"author": null,
"comment": null,
"created": "2021-11-12T17:19:44.795237917Z",
"image_id": "12ebda3111cec73a788b0e802a00de04ebf5e9765043925dd396c2d03a7c1e66",
"layer_id": "1a058d5342cc722ad5439cacae4b2b4eedde51d8fe8800fcf28444302355c16d",
"layer_tag": "img-12ebda-layer-01-1a058d",
"created_by": "/bin/sh -c #(nop) ADD file:762c899ec0505d1a32930ee804c5b008825f41611161be104076cba33b7e5b2b in / ",
"xlsx_errors": null,
"archive_location": "ghcr_io_kyverno_sbom.tar-extract/1a058d5342cc722ad5439cacae4b2b4eedde51d8fe8800fcf28444302355c16d.tar"
}
]
}
11 changes: 11 additions & 0 deletions scanpipe/tests/pipes/test_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ def test_scanpipe_pipes_input_load_inventory_from_xlsx(self):
self.assertEqual(8, project1.discovereddependencies.count())
self.assertEqual(0, project1.codebaserelations.count())

def test_scanpipe_pipes_input_load_inventory_from_xlsx_layers_sheet(self):
project1 = Project.objects.create(name="Analysis")
input_location = self.data / "outputs" / "docker_ghcr.io_kyverno_sbom.xlsx"
input.load_inventory_from_xlsx(project1, input_location)
project1.refresh_from_db()
expected_location = (
self.data / "outputs" / "docker_ghcr.io_kyverno_sbom_expected.json"
)
expected = json.loads(expected_location.read_text())
self.assertEqual(expected, project1.extra_data)

def test_scanpipe_pipes_input_load_inventory_from_project_xlsx_output(self):
fixtures = self.data / "asgiref" / "asgiref-3.3.0_fixtures.json"
call_command("loaddata", fixtures, **{"verbosity": 0})
Expand Down

0 comments on commit d0f5280

Please sign in to comment.