Package com.denimgroup.threadfix.webapp.controller

Examples of com.denimgroup.threadfix.webapp.controller.ReportCheckResultBean


  @Override
  public ReportCheckResultBean generateReport(ReportParameters parameters,
      HttpServletRequest request) {
    if (parameters.getReportFormat() == ReportFormat.BAD_FORMAT) {
      return new ReportCheckResultBean(ReportCheckResult.BAD_REPORT_TYPE);
    }
   
    List<Integer> applicationIdList = getApplicationIdList(parameters);
 
    if (applicationIdList == null || applicationIdList.isEmpty()) {
      return new ReportCheckResultBean(ReportCheckResult.NO_APPLICATIONS);
    }
   
    if (parameters.getReportFormat() == ReportFormat.VULNERABILITY_LIST) {
      StringBuffer dataExport = getDataVulnListReport(getListofRowParams(applicationIdList), applicationIdList);
      return new ReportCheckResultBean(ReportCheckResult.VALID, dataExport, null);
    }

        if (parameters.getReportFormat() == ReportFormat.TOP_TWENTY_APPS) {
      applicationIdList = applicationDao.getTopXVulnerableAppsFromList(20, applicationIdList);
    }

    if (applicationIdList == null || applicationIdList.isEmpty()) {
      return new ReportCheckResultBean(ReportCheckResult.NO_APPLICATIONS);
    }
    log.info("About to generate report for " + applicationIdList.size() + " applications.");

        Map<String, Object> params = new HashMap<>();
        params.put("appId", applicationIdList);
        String path = request.getSession().getServletContext().getRealPath("/");

        String format = null;
        if (parameters.getFormatId() == 2) {
            format = "CSV";
        } else if (parameters.getFormatId() == 3) {
            format = "PDF";
        } else {
            format = "HTML";
        }

        ReportFormat reportFormat = parameters.getReportFormat();
        try {
            return getReport(path, reportFormat, format, params, applicationIdList, request);
        } catch (IOException e) {
            log.error("IOException encountered while trying to generate report.", e);
            return new ReportCheckResultBean(ReportCheckResult.IO_ERROR);
        } finally {
            log.info("Finished generating report.");
        }
    }
View Full Code Here


    @Override
    public ReportCheckResultBean generateDashboardReport(ReportParameters parameters, HttpServletRequest request) {

        List<Integer> applicationIdList = getApplicationIdList(parameters);
        if (applicationIdList == null || applicationIdList.isEmpty()) {
            return new ReportCheckResultBean(ReportCheckResult.NO_APPLICATIONS);
        }

        ReportCheckResultBean report = null;

        if (parameters.getReportFormat() == ReportFormat.TOP_TEN_APPS) {
            applicationIdList = applicationDao.getTopXVulnerableAppsFromList(10, applicationIdList);
            report = getTopAppsReportD3(applicationIdList);
        }
        if (parameters.getReportFormat() == ReportFormat.POINT_IN_TIME_GRAPH) {
            report = getPointInTimeD3(applicationIdList, parameters.getOrganizationId());
        }

        if (parameters.getReportFormat() == ReportFormat.TOP_TEN_VULNS) {
            List<Integer> vulnIds = vulnerabilityDao.getTopTenVulnTypes(applicationIdList);
            report = getTopVulnsReportD3(applicationIdList, vulnIds);
        }

        if (parameters.getReportFormat() == ReportFormat.TRENDING) {
            JasperScanReport reportExporter = new JasperScanReport(applicationIdList, scanDao, filterJsonBlobDao.getDefaultFilter());
            report = new ReportCheckResultBean(ReportCheckResult.VALID, null, null, reportExporter.buildReportList());
            report.setEndDate(reportExporter.getEndDate());
            report.setStartDate(reportExporter.getStartDate());
        }

        if (report == null || report.getReportList() == null || report.getReportList().size()==0)
            return new ReportCheckResultBean(ReportCheckResult.NO_APPLICATIONS);

        return report;
    }
View Full Code Here

      if (reportFormat == ReportFormat.TRENDING) {
        jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, new JasperScanReport(applicationIdList, scanDao, null));
      } else if (reportFormat == ReportFormat.TWELVE_MONTH_SUMMARY) {
        jasperPrint = getXMonthReport(applicationIdList, parameters, jasperReport, 12);
        if (jasperPrint == null) {
          return new ReportCheckResultBean(ReportCheckResult.NO_APPLICATIONS);
        }
      } else if (reportFormat == ReportFormat.MONTHLY_PROGRESS_REPORT) {
        jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,
                        new JasperMonthlyScanReport(applicationIdList, scanDao));
      } else if (reportFormat == ReportFormat.VULNERABILITY_PROGRESS_BY_TYPE) {
        jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,
                        new JasperCWEReport(applicationIdList,vulnerabilityDao));
      } else if (reportFormat == ReportFormat.CHANNEL_COMPARISON_SUMMARY) {
        jasperPrint = JasperFillManager.fillReport(jasperReport, parameters,
                        new JasperScannerComparisonReport(applicationIdList, vulnerabilityDao));
      } else {
        jasperPrint = JasperFillManager.fillReport(jasperReport, parameters);
      }
     
      if (jasperPrint == null) {
        return null;
      }
     
      if(format.equals("PDF")) {
        byte[] pdfByteArray = JasperExportManager.exportReportToPdf(jasperPrint);
        if (pdfByteArray != null) {
          return new ReportCheckResultBean(ReportCheckResult.VALID, null, pdfByteArray);
        } else {
          return null;
        }
      }

      exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
      exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER,
          report);
     
      exporter.setParameter(
          JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR,
          Boolean.FALSE);
     
      String mapKey = getMapKey(reportFormat.ordinal(), applicationIdList);
     
      Map<Object, Object> imagesMap = new HashMap<>();
      request.getSession().setAttribute(mapKey, imagesMap);
           
      exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);

      exporter.setParameter(
          JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN,
          Boolean.TRUE);

            String imagesPath = request.getContextPath() + "/jasperimage/" + mapKey + "/";

      exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,
                    imagesPath);

      exporter.exportReport();

    } catch (JRException ex) {
      log.error("Encountered a Jasper exception, the report was probably not exported correctly.",ex);
    } finally {
      try {
        if (inputStream != null) {
          inputStream.close();
        }
      } catch (IOException e) {
        log.warn("Failed to close an InputStream", e);
      }
    }

    log.debug("Returning report.");
   
    return new ReportCheckResultBean(ReportCheckResult.VALID, report, null);
  }
View Full Code Here

        if (resultList.size() == 0 ) {
            log.info("Unable to fill Report - no vulns were found.");
            return null;
        } else {
            return new ReportCheckResultBean(ReportCheckResult.VALID, null, null, resultList);
        }

    }
View Full Code Here

        if (resultList.size() == 0 ) {
            log.info("Unable to fill Report - no apps were found.");
            return null;
        } else {
            return new ReportCheckResultBean(ReportCheckResult.VALID, null, null, resultList);
        }
    }
View Full Code Here

        if (resultList.size() == 0 ) {
            log.info("Unable to fill Report - no vulns were found.");
            return null;
        } else {
            return new ReportCheckResultBean(ReportCheckResult.VALID, null, null, resultList);
        }
    }
View Full Code Here

    }

    @Override
    public ReportCheckResultBean generateSearchReport(List<Vulnerability> vulnerabilityList) {
        StringBuffer dataExport = getDataVulnListReport(getVulnListInfo(vulnerabilityList), null);
        return new ReportCheckResultBean(ReportCheckResult.VALID, dataExport, null);
    }
View Full Code Here

TOP

Related Classes of com.denimgroup.threadfix.webapp.controller.ReportCheckResultBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.