Skip to content

Commit d0f5280

Browse files
authored
Load the LAYERS sheet data in load_inventory_from_xlsx #1490 (#1491)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 1a6318f commit d0f5280

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

scanpipe/pipes/input.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#
2020
# ScanCode.io is a free software code scanning tool from nexB Inc. and others.
2121
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
22-
2322
import shutil
2423
from pathlib import Path
2524

@@ -199,3 +198,7 @@ def load_inventory_from_xlsx(project, input_location):
199198
cleaned_data = clean_xlsx_data_to_model_data(model_class, row_data)
200199
if cleaned_data:
201200
object_maker_func(project, cleaned_data)
201+
202+
if "LAYERS" in workbook:
203+
layers_data = get_worksheet_data(worksheet=workbook["LAYERS"])
204+
project.update_extra_data({"layers": layers_data})
Binary file not shown.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"layers": [
3+
{
4+
"size": "5886464",
5+
"author": null,
6+
"comment": null,
7+
"created": "2021-11-12T17:19:44.795237917Z",
8+
"image_id": "12ebda3111cec73a788b0e802a00de04ebf5e9765043925dd396c2d03a7c1e66",
9+
"layer_id": "1a058d5342cc722ad5439cacae4b2b4eedde51d8fe8800fcf28444302355c16d",
10+
"layer_tag": "img-12ebda-layer-01-1a058d",
11+
"created_by": "/bin/sh -c #(nop) ADD file:762c899ec0505d1a32930ee804c5b008825f41611161be104076cba33b7e5b2b in / ",
12+
"xlsx_errors": null,
13+
"archive_location": "ghcr_io_kyverno_sbom.tar-extract/1a058d5342cc722ad5439cacae4b2b4eedde51d8fe8800fcf28444302355c16d.tar"
14+
}
15+
]
16+
}

scanpipe/tests/pipes/test_input.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ def test_scanpipe_pipes_input_load_inventory_from_xlsx(self):
118118
self.assertEqual(8, project1.discovereddependencies.count())
119119
self.assertEqual(0, project1.codebaserelations.count())
120120

121+
def test_scanpipe_pipes_input_load_inventory_from_xlsx_layers_sheet(self):
122+
project1 = Project.objects.create(name="Analysis")
123+
input_location = self.data / "outputs" / "docker_ghcr.io_kyverno_sbom.xlsx"
124+
input.load_inventory_from_xlsx(project1, input_location)
125+
project1.refresh_from_db()
126+
expected_location = (
127+
self.data / "outputs" / "docker_ghcr.io_kyverno_sbom_expected.json"
128+
)
129+
expected = json.loads(expected_location.read_text())
130+
self.assertEqual(expected, project1.extra_data)
131+
121132
def test_scanpipe_pipes_input_load_inventory_from_project_xlsx_output(self):
122133
fixtures = self.data / "asgiref" / "asgiref-3.3.0_fixtures.json"
123134
call_command("loaddata", fixtures, **{"verbosity": 0})

0 commit comments

Comments
 (0)