public static List<PartialMapping> toPartialMappingList(Scan scan) { List<PartialMapping> results = new ArrayList<PartialMapping>(); if (scan.getFindings() != null) { for (Finding finding : scan.getFindings()) { results.add(toPartialMapping(finding)); } } return results; } }
public DeletedScan(Scan scan) { if (scan != null) { if (scan.getApplication() != null) { setApplicationId(scan.getApplication().getId()); } if (scan.getApplicationChannel() != null) { setApplicationChannelId(scan.getApplicationChannel().getId()); } setId(scan.getId()); setImportTime(scan.getImportTime()); setNumberClosedVulnerabilities(scan.getNumberClosedVulnerabilities()); setNumberNewVulnerabilities(scan.getNumberNewVulnerabilities()); setNumberOldVulnerabilities(scan.getNumberOldVulnerabilities()); setNumberResurfacedVulnerabilities(scan.getNumberResurfacedVulnerabilities()); setNumberRepeatResults(scan.getNumberRepeatResults()); setNumberRepeatFindings(scan.getNumberRepeatFindings()); } }
/** * This constructor maps everything correctly, so just creating the object is enough. * This object is useless without the mappings, so it makes sense to include them here. * @param scan */ public ScanCloseVulnerabilityMap(Vulnerability vulnerability, Scan scan) { this.vulnerability = vulnerability; this.scan = scan; if (vulnerability != null) { if (vulnerability.getScanCloseVulnerabilityMaps() == null) { vulnerability.setScanCloseVulnerabilityMaps(new ArrayList<ScanCloseVulnerabilityMap>()); } vulnerability.getScanCloseVulnerabilityMaps().add(this); } if (scan != null) { if (scan.getScanCloseVulnerabilityMaps() == null) { scan.setScanCloseVulnerabilityMaps(new ArrayList<ScanCloseVulnerabilityMap>()); } scan.getScanCloseVulnerabilityMaps().add(this); } }
@Transient @JsonIgnore public List<Integer> getReportList() { List<Integer> integerList = new ArrayList<Integer>(); integerList.add(getId()); integerList.add(getNumberTotalVulnerabilities()); integerList.add(getNumberNewVulnerabilities()); integerList.add(getNumberOldVulnerabilities()); integerList.add(getNumberResurfacedVulnerabilities()); integerList.add(getNumberClosedVulnerabilities()); return integerList; }
/** * This constructor maps everything correctly, so just creating the object is enough. * This object is useless without the mappings, so it makes sense to include them here. * @param scan */ public ScanReopenVulnerabilityMap(Vulnerability vulnerability, Scan scan) { this.vulnerability = vulnerability; this.scan = scan; if (vulnerability != null) { if (vulnerability.getScanReopenVulnerabilityMaps() == null) { vulnerability.setScanReopenVulnerabilityMaps(new ArrayList<ScanReopenVulnerabilityMap>()); } vulnerability.getScanReopenVulnerabilityMaps().add(this); } if (scan != null) { if (scan.getScanReopenVulnerabilityMaps() == null) { scan.setScanReopenVulnerabilityMaps(new ArrayList<ScanReopenVulnerabilityMap>()); } scan.getScanReopenVulnerabilityMaps().add(this); } }
.createQuery("from DataFlowElement element " + "where element.finding in (select id from Finding where scan = :scan)") .setInteger("scan", scan.getId()) .list(); .createQuery("from SurfaceLocation " + "where id in (select surfaceLocation.id from Finding where scan = :scan)") .setInteger("scan", scan.getId()) .list(); for (Finding finding : scan.getFindings()) { for (Event event : eventDao.retrieveAllByFinding(finding)) { event.setFinding(null); for (Event event : listFrom(scan.getEvents())) { event.setDeletedScanId(scan.getId()); event.setScan(null); scan.getEvents().remove(event); sessionFactory.getCurrentSession().save(event); for (ScanCloseVulnerabilityMap map : listFrom(scan.getScanCloseVulnerabilityMaps())) { map.getVulnerability().getScanCloseVulnerabilityMaps().remove(map); scan.getScanCloseVulnerabilityMaps().remove(map); map.setVulnerability(null); map.setScan(null); .setInteger("scan", scan.getId()) .list();
private void addParameterLists(List<Integer> filteredSeverities, List<Integer> filteredVulnerabilities, Scan scan, Query query) { if (!filteredSeverities.isEmpty()) { query.setParameterList("filteredSeverities", filteredSeverities); } if (!filteredVulnerabilities.isEmpty()) { query.setParameterList("filteredVulnerabilities", filteredVulnerabilities); } if (scan != null) { query.setParameter("scanId", scan.getId()); } }
@Override public int compare(Scan scan1, Scan scan2){ Calendar scan1Time = scan1.getImportTime(); Calendar scan2Time = scan2.getImportTime(); if (scan1Time == null || scan2Time == null) { return 0; } return scan1Time.compareTo(scan2Time); } }
private String buildScanLink(Scan scan, String linkText, Map<String, Object> urlMap) { if (scan == null) { return linkText; } Application application = getApplication(); if (application == null) { application = scan.getApplication(); } if ((application == null) || (!application.isActive())) { return linkText; } Organization organization = application.getOrganization(); if ((organization == null) || (!organization.isActive())) { return linkText; } String urlString = "/organizations/" + scan.getApplication().getOrganization().getId() + "/applications/" + scan.getApplication().getId() + "/scans/" + scan.getId(); return buildLink(urlString, linkText, urlMap); }
@JsonView({AllViews.TableRow.class, AllViews.RestViewScanStatistic.class}) @Transient private Integer getApplicationChannelId(){ return (getApplicationChannel()==null ? null : getApplicationChannel().getId()); }
@Override public void delete(ScanCloseVulnerabilityMap map) { if (map.getScan() != null && map.getScan().getScanCloseVulnerabilityMaps() != null) { map.getScan().getScanCloseVulnerabilityMaps().remove(map); } if (map.getVulnerability() != null && map.getVulnerability().getScanCloseVulnerabilityMaps() != null) { map.getVulnerability().getScanCloseVulnerabilityMaps().remove(map); } map.setScan(null); map.setVulnerability(null); sessionFactory.getCurrentSession().delete(map); }
@Override public void delete(ScanReopenVulnerabilityMap map) { if (map.getScan() != null && map.getScan().getScanReopenVulnerabilityMaps() != null) { map.getScan().getScanReopenVulnerabilityMaps().remove(map); } if (map.getVulnerability() != null && map.getVulnerability().getScanReopenVulnerabilityMaps() != null) { map.getVulnerability().getScanReopenVulnerabilityMaps().remove(map); } map.setScan(null); map.setVulnerability(null); sessionFactory.getCurrentSession().delete(map); } }
@JsonView({ AllViews.TableRow.class, AllViews.RestViewScanStatistic.class}) @Transient private Map<String, Object> getApp() { Application app = getApplication(); Map<String, Object> map = new HashMap<String, Object>(); map.put("id", app.getId()); map.put("name", app.getName()); return map; }
@Transient public String getFullFilePath(Scan scan) { return fileUploadLocation + File.separator + scan.getFileName(); }
@Transient @JsonView({ AllViews.TableRow.class, AllViews.VulnerabilityDetail.class }) private Integer getScanId() { return getScan().getId(); }
@Transient @JsonIgnore public Scan getLatestScan() { if (scanList == null || scanList.size() == 0) return null; Scan latestScan = scanList.get(0); for (Scan scan : scanList) { if (scan != null && scan.getImportTime() != null) { int result = scan.getImportTime().compareTo(latestScan.getImportTime()); if (result > 0) { latestScan = scan; } } } return latestScan; }
application = scan.getApplication(); scan.getApplication().getOrganization().getId() + "/applications/" + scan.getApplication().getId() + "/scans/" + scan.getId() + "/findings/" + finding.getId();
@Transient public String getScannerType() { if (getApplicationChannel() != null && getApplicationChannel().getChannelType() != null && getApplicationChannel().getChannelType().getName() != null) { String scannerName = getApplicationChannel().getChannelType().getName(); if (DYNAMIC_TYPES.contains(scannerName)) { return DYNAMIC; } else if (STATIC_TYPES.contains(scannerName)) { return STATIC; } else if (MIXED_TYPES.contains(scannerName)) { return MIXED; } } return null; }
@JsonView({AllViews.TableRow.class, AllViews.RestViewScanStatistic.class}) @Transient private Map<String, Object> getTeam() { Organization team = getApplication().getOrganization(); Map<String, Object> map = new HashMap<String, Object>(); map.put("id", team.getId()); map.put("name", team.getName()); return map; }
@Transient @JsonView({ AllViews.HistoryView.class}) public Integer getScanId() { Scan scan = getScan(); if (scan != null) { return scan.getId(); } return null; }