Skip to content

Commit

Permalink
Fix PDF
Browse files Browse the repository at this point in the history
  • Loading branch information
sudhirverma committed Oct 9, 2024
1 parent 0eed64b commit 04c48c4
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions src/utils/OsarPdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ import 'jspdf-autotable';

import CheckIcon from '../assets/images/checked.png';

const checkReport: any = {
'insecure-code-detection': 'Insecure Code Detection',
'sbom': 'SBOM',
'criticality_score': 'Criticality Score',
'scorecard': 'Scorecard',
'sast': 'SAST',
'License Compliance': 'License Compliance',
'dast': 'DAST',
'LLM Benchmark': 'LLM Benchmark'
};

// Function to generate the PDF
export function generatePdfFromJson(getOsarReport: any, filename: string, attested = false) {
const doc: any = new jsPDF();
Expand Down Expand Up @@ -66,7 +77,7 @@ export function generatePdfFromJson(getOsarReport: any, filename: string, attest
});

// Loop through each assessment and add content dynamically
getOsarReport.assessments.forEach((assessment: any, index: number) => {
getOsarReport.assessments.forEach((assessment: any) => {
// Ensure space before starting new sections or pages
if (yOffset > 250) { // Adjust according to your content size
doc.addPage();
Expand All @@ -75,17 +86,6 @@ export function generatePdfFromJson(getOsarReport: any, filename: string, attest

yOffset += 10; // Add some space before the next section

// Assessment Details Section
doc.setFontSize(16);
doc.setTextColor(0, 0, 0);
doc.text(`Assessment ${index + 1} Details`, 10, yOffset);
yOffset += 10;

// Horizontal line separator
doc.setLineWidth(0.5);
doc.line(10, yOffset, 200, yOffset);
yOffset += 10;

const toolDetails = assessment.tool;
const executionDetails = assessment.execution;

Expand All @@ -102,6 +102,19 @@ export function generatePdfFromJson(getOsarReport: any, filename: string, attest
["Output", executionDetails.output_path]
];

// Assessment Details Section
doc.setFontSize(16);
doc.setTextColor(0, 0, 0);
doc.setFont("helvetica", "bold");
doc.text(`${checkReport[toolDetails.type]}`, 10, yOffset);
yOffset += 10;

// Horizontal line separator
doc.setLineWidth(0.5);
doc.line(10, yOffset, 200, yOffset);
yOffset += 10;


assessmentDetails.forEach(([key, value]) => {
doc.setFontSize(12);
doc.setFont("helvetica", "bold");
Expand All @@ -123,7 +136,7 @@ export function generatePdfFromJson(getOsarReport: any, filename: string, attest
// Assessment results Section
doc.setFontSize(16);
doc.setTextColor(0, 0, 0);
doc.text("Assessment results", 10, yOffset);
doc.text("Assessment Result", 10, yOffset);
yOffset += 10;

// Horizontal line separator
Expand Down

0 comments on commit 04c48c4

Please sign in to comment.