public DeletedDefect(Defect defect) { if (defect != null) { setNativeId(defect.getNativeId()); setId(defect.getId()); setStatus(defect.getStatus()); setDefectURL(defect.getDefectURL()); if (defect.getApplication() != null) { setApplicationId(defect.getApplication().getId()); } } }
@Override public void delete(Defect defect) { for (Event event: defect.getEvents()) { event.setDefect(null); eventDao.saveOrUpdate(event); } sessionFactory.getCurrentSession().save(new DeletedDefect(defect)); sessionFactory.getCurrentSession().delete(defect); } }
if(vulnerability.isActive() == defect.isOpen()) { vulnerabilityDefectConsistencyState = VulnerabilityDefectConsistencyState.CONSISTENT; } else if (defect.isOpen()) { vulnerabilityDefectConsistencyState = VulnerabilityDefectConsistencyState.VULN_CLOSED_DEFECT_OPEN_NEEDS_SCAN; } else { Calendar defectStatusUpdatedDate = defect.getStatusUpdatedDate(); if (defectStatusUpdatedDate == null) { defectStatusUpdatedDate = Calendar.getInstance(); defectStatusUpdatedDate.setTime(defect.getModifiedDate());
@Transient @JsonView({ AllViews.HistoryView.class}) public Integer getDefectId() { Defect defect = getDefect(); if (defect != null) { return defect.getId(); } return null; }
@Transient @JsonIgnore public VulnerabilityMarker toVulnerabilityMarker() { VulnerabilityMarker marker = new VulnerabilityMarker(); marker.setFilePath(getFindingCalculatedFilePath()) .setLineNumber(getEntryPointLineNumber()) .setGenericVulnId(genericVulnerability.getId()) .setGenericVulnName(genericVulnerability.getName()) .setParameter(surfaceLocation.getParameter()); if (getDefect() != null) { marker.setDefectId(getDefect().getNativeId()) .setDefectUrl(getDefect().getDefectURL()); } Set<String> scanners = set(); marker.setSeverity(getSeverityName()); for (Finding finding : getFindings()) { scanners.add(finding.getChannelNameOrNull()); } marker.setScanners(listFrom(scanners)); return marker; }
private void appendDefectLink(StringBuilder description, Map<String, Object> descriptionUrlMap, HistoryView historyView) { if (getDefect() != null) { description.append(buildDefectLink(getVulnerability(), getDefect().getNativeId(), descriptionUrlMap)); } }
private String buildDefectLink(Vulnerability vulnerability, String linkText, Map<String, Object> urlMap) { if ((defect == null) || (!defect.isActive()) || (vulnerability == null) || (!vulnerability.isActive())) { return linkText; } Application application = getApplication(); if (application == null) { application = vulnerability.getApplication(); } if ((application == null) || (!application.isActive())) { return linkText; } Organization organization = application.getOrganization(); if ((organization == null) || (!organization.isActive())) { return linkText; } String urlString = "/organizations/" + vulnerability.getApplication().getOrganization().getId() + "/applications/" + vulnerability.getApplication().getId() + "/vulnerabilities/" + vulnerability.getId() + "/defect"; return buildLink(urlString, linkText, urlMap); }
private List<Event> retrieveUngrouped(List<String> eventActions, Vulnerability vulnerability) { Set<Integer> vulnIds = set(); vulnIds.add(vulnerability.getId()); Set<Integer> defectIds = null; if (vulnerability.getDefect() != null) { defectIds = set(); defectIds.add(vulnerability.getDefect().getId()); } return retrieveUngrouped(eventActions, null, null, null, null, null, vulnIds, defectIds); } private List<Event> retrieveUngrouped(List<String> eventActions, User user) {
public static Vulnerabilities.Vulnerability convertTFVulnToSSVLVuln(Vulnerability tfVuln) { Vulnerabilities.Vulnerability ssvlVuln = factory.createVulnerabilitiesVulnerability(); ssvlVuln.setDescription(tfVuln.getGenericVulnName()); if (tfVuln.getDefect() != null) ssvlVuln.setIssueID(tfVuln.getDefect().getNativeId()); ssvlVuln.setCWE(tfVuln.getGenericVulnerability().getDisplayId()); ssvlVuln.setSeverity(Severities.fromValue(tfVuln.getSeverityName())); ssvlVuln.setApplication(tfVuln.getAppName()); if (tfVuln.getFindings() != null) { for (Finding tfFinding: tfVuln.getFindings()) { ssvlVuln.getFinding().add(convertTFFindingToSSVLFinding(tfFinding)); } } return ssvlVuln; }
setDefectId(vulnerability.getDefect().getId());
@SuppressWarnings("unchecked") @Override public void deleteByDefectTrackerId(Integer defectTrackerId) { sessionFactory.getCurrentSession() .createQuery("update Vulnerability set defect = null where application in " + "(from Application where defectTracker = :defectTracker)") .setInteger("defectTracker", defectTrackerId) .executeUpdate(); List<Defect> defects = ((List<Defect>) sessionFactory.getCurrentSession() .createQuery("from Defect where application in " + "(from Application where defectTracker = :defectTracker)") .setInteger("defectTracker", defectTrackerId) .list()); if (defects != null && defects.size() > 0) { for (Defect defect : defects) { for (Event event: defect.getEvents()) { event.setDefect(null); eventDao.saveOrUpdate(event); } delete(defect); } } }