From 826b728402352a5c8aedac97dd2feba01a3981f9 Mon Sep 17 00:00:00 2001 From: swatipersistent <99341045+swatipersistent@users.noreply.github.com> Date: Wed, 17 Apr 2024 15:00:37 +0530 Subject: [PATCH] Jenkins Q2 Release (#249) * Enable Data Retention * updated comment --- src/main/java/com/cx/restclient/CxSASTClient.java | 2 +- src/main/java/com/cx/restclient/ast/AstScaClient.java | 2 +- src/main/java/com/cx/restclient/sast/utils/SASTUtils.java | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/cx/restclient/CxSASTClient.java b/src/main/java/com/cx/restclient/CxSASTClient.java index d089fcab..38f9802d 100644 --- a/src/main/java/com/cx/restclient/CxSASTClient.java +++ b/src/main/java/com/cx/restclient/CxSASTClient.java @@ -541,7 +541,7 @@ public Results waitForScanResults() { if (config.getReportsDir() != null) { String now = new SimpleDateFormat("dd_MM_yyyy-HH_mm_ss").format(new Date()); String pdfFileName = PDF_REPORT_NAME + "_" + now + ".pdf"; - String pdfLink = writePDFReport(pdfReport, config.getReportsDir(), pdfFileName, log); + String pdfLink = writePDFReport(pdfReport, config.getReportsDir(), pdfFileName, log, "PDF"); sastResults.setSastPDFLink(pdfLink); sastResults.setPdfFileName(pdfFileName); } diff --git a/src/main/java/com/cx/restclient/ast/AstScaClient.java b/src/main/java/com/cx/restclient/ast/AstScaClient.java index bca4e6da..ba4c05e3 100644 --- a/src/main/java/com/cx/restclient/ast/AstScaClient.java +++ b/src/main/java/com/cx/restclient/ast/AstScaClient.java @@ -308,8 +308,8 @@ public Results waitForScanResults() { } fileName = PDF_REPORT_NAME + "_" + now + "." + reportFormat.toLowerCase(); + String pdfLink = SASTUtils.writePDFReport(scanReport, config.getReportsDir(), fileName, log, reportFormat); if (reportFormat.toLowerCase().equals("pdf")) { - String pdfLink = SASTUtils.writePDFReport(scanReport, config.getReportsDir(), fileName, log); scaResults.setScaPDFLink(pdfLink); scaResults.setPdfFileName(fileName); } diff --git a/src/main/java/com/cx/restclient/sast/utils/SASTUtils.java b/src/main/java/com/cx/restclient/sast/utils/SASTUtils.java index 5c7a6e4a..bdb38613 100644 --- a/src/main/java/com/cx/restclient/sast/utils/SASTUtils.java +++ b/src/main/java/com/cx/restclient/sast/utils/SASTUtils.java @@ -57,12 +57,13 @@ public static void printSASTResultsToConsole(SASTResults sastResults, boolean en } //PDF Report - public static String writePDFReport(byte[] scanReport, File workspace, String pdfFileName, Logger log) { + //This method is used for generate report for other file formats(CSV , XML, JSON etc) as well not only PDF file format. + public static String writePDFReport(byte[] scanReport, File workspace, String pdfFileName, Logger log, String reportFormat) { try { FileUtils.writeByteArrayToFile(new File(workspace + CX_REPORT_LOCATION, pdfFileName), scanReport); - log.info("PDF report location: " + workspace + CX_REPORT_LOCATION + File.separator + pdfFileName); + log.info("" +reportFormat + " Report Location: " + workspace + CX_REPORT_LOCATION+ File.separator+ pdfFileName); } catch (Exception e) { - log.error("Failed to write PDF report to workspace: ", e.getMessage()); + log.error("Failed to write "+reportFormat+" report to workspace: ", e.getMessage()); pdfFileName = ""; } return pdfFileName;