From 349e05b1d5594f7d574c7f8ead18d577fb4649b4 Mon Sep 17 00:00:00 2001 From: pedrooot Date: Fri, 22 Aug 2025 12:09:44 +0200 Subject: [PATCH] chore: Martin's revision --- api/src/backend/api/v1/views.py | 3 +++ ui/actions/scans/scans.ts | 17 +++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/api/src/backend/api/v1/views.py b/api/src/backend/api/v1/views.py index e513dca82f..27a21e0d90 100644 --- a/api/src/backend/api/v1/views.py +++ b/api/src/backend/api/v1/views.py @@ -1507,6 +1507,9 @@ class ProviderViewSet(BaseRLSViewSet): description="PDF file containing the threatscore report" ), 202: OpenApiResponse(description="The task is in progress"), + 401: OpenApiResponse( + description="API key missing or user not Authenticated" + ), 403: OpenApiResponse(description="There is a problem with credentials"), 404: OpenApiResponse( description="The scan has no threatscore reports, or the threatscore report generation task has not started yet" diff --git a/ui/actions/scans/scans.ts b/ui/actions/scans/scans.ts index e1c556793e..f0acd62303 100644 --- a/ui/actions/scans/scans.ts +++ b/ui/actions/scans/scans.ts @@ -348,13 +348,22 @@ export const getThreatscoreReport = async (scanId: string) => { ); } - const arrayBuffer = await response.arrayBuffer(); - const base64 = Buffer.from(arrayBuffer).toString("base64"); + const filename = `scan-${scanId}-threatscore.pdf`; + + const blob = await response.blob(); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); return { success: true, - data: base64, - filename: `scan-${scanId}-threatscore.pdf`, + data: url, + filename, }; } catch (error) { return {