Skip to content

Commit ae1ffef

Browse files
committed
Fix the view output for OpenVEX
Signed-off-by: tdruez <[email protected]>
1 parent a3067eb commit ae1ffef

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

dje/outputs.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ def get_attachment_response(file_content, filename, content_type):
3737
if not file_content or not filename:
3838
raise Http404
3939

40+
if isinstance(file_content, bytes):
41+
file_content = file_content.decode("utf-8")
42+
4043
response = FileResponse(
4144
file_content,
4245
filename=filename,
@@ -398,13 +401,14 @@ def get_openvex_statements(product):
398401

399402

400403
def get_openvex_document(product):
404+
tooling = f"DejaCode-{dejacode_version}"
401405
return openvex.OpenVEX(
402406
field_context="https://openvex.dev/ns/v0.2.0",
403407
field_id=f"OpenVEX-Document-{str(product.uuid)}",
404408
author=product.dataspace.name,
405409
timestamp=get_openvex_timestamp(),
406410
version=1,
407-
tooling=f"DejaCode-{dejacode_version}",
411+
tooling=tooling,
408412
statements=get_openvex_statements(product),
409413
)
410414

dje/tests/test_outputs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def test_outputs_get_csaf_security_advisory(self):
210210

211211
self.assertJSONEqual(security_advisory_json, expected_location.read_text())
212212

213+
@mock.patch("dje.outputs.dejacode_version", "1000")
213214
def test_outputs_get_openvex_document_json(self):
214215
mock_now = datetime(2024, 12, 19, 12, 0, 0, tzinfo=UTC)
215216
with mock.patch("dje.outputs.datetime") as mock_datetime:

dje/tests/testfiles/outputs/openvex_document.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353
]
5454
}
5555
],
56-
"tooling": "DejaCode-v5.4.1-21-g9b9925b"
56+
"tooling": "DejaCode-1000"
5757
}

0 commit comments

Comments
 (0)