Package com.denimgroup.threadfix.service.defects

Examples of com.denimgroup.threadfix.service.defects.AbstractDefectTracker


      return null;
    }

    applicationService.decryptCredentials(application);

    AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    ProjectMetadata data = null;

        List<Defect> defectList = null;
        Map<String, Object> map = new HashMap<>();
    if (dt != null) {
            if (addDefectIds) {
                defectList = dt.getDefectList();
                if (dt.getLastError() != null && !dt.getLastError().isEmpty()) {
                    map.put(ERROR_MSG, dt.getLastError());
                    return map;
                }
            } else {
                defectList = list();
            }

      data = dt.getProjectMetadata();
            if (dt.getLastError() != null && !dt.getLastError().isEmpty()) {
                map.put(ERROR_MSG, dt.getLastError());
                return map;
            }

            // adding additional scanner info checkbox, checking for null dynamicformfields
            List<DynamicFormField> editableFields = data.getEditableFields();

            if (editableFields != null) {
                addAdditionalScannerInfoField(editableFields);

                //remove Order field in Version One dynamic form
                if (dt.getClass().equals(VersionOneDefectTracker.class)) {
                    DynamicFormField orderField = null;
                    for (DynamicFormField field : editableFields) {
                        if (field.getName().equals("Order")) {
                            orderField = field;
                        }
View Full Code Here


  // TODO move this elsewhere?
  @RequestMapping(value = "/jsontest", method = RequestMethod.POST)
  public @ResponseBody RestResponse<?> readJson(@ModelAttribute DefectTrackerBean bean) {
    DefectTracker defectTracker = defectTrackerService.loadDefectTracker(bean
        .getDefectTrackerId());
    AbstractDefectTracker dt = DefectTrackerFactory.getTrackerByType(defectTracker,
        bean.getUserName(), bean.getPassword());
    if (dt == null) {
      log.warn("Incorrect Defect Tracker credentials submitted.");
      return RestResponse.failure("Authentication failed.");
    }
    List<String> result = dt.getProductNames();
    if (result.isEmpty() || (result.size() == 1 && result.contains("Authentication failed"))) {
      return RestResponse.failure(JSONObject.quote(dt.getLastError()));
    }

        // ensure there are no duplicates. There's probably a better idiom
        result = listFrom(setFrom(result));
View Full Code Here

        application.getDefectTracker().getDefectTrackerType() == null) {
      return "";
    }
    applicationService.decryptCredentials(application);

    AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    List<Defect> defectList = list();
   
    ProjectMetadata data = null;
    if (dt != null) {
      data = dt.getProjectMetadata();
      defectList = dt.getDefectList();
    }
    model.addAttribute("projectMetadata", data);
    model.addAttribute("defectList", defectList);
    model.addAttribute(new DefectViewModel());
    model.addAttribute("contentPage", "defects/mergeDefectForm.jsp");
View Full Code Here

        application.setPassword(null);
        application.setProjectName(null);
      } else {
       
        application.setDefectTracker(defectTracker);
        AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
        if (dt != null) {
          if (application.getUserName() == null
              || application.getUserName().isEmpty()) {
            result.rejectValue("userName", "errors.required",
                new String [] { "User Name" }, null);
          }
          if (application.getPassword() == null
              || application.getPassword().isEmpty()) {
            result.rejectValue("password", "errors.required",
                new String [] { "Password" }, null);
          }
         
          if (!result.hasErrors()) {
            if (!dt.hasValidCredentials()) {
              if (dt.getLastError() == null) {
                result.rejectValue("userName", "errors.invalid",
                    new String [] { invalidCredentials }, null);
              } else {
                result.rejectValue("userName", "errors.detail",
                    new String [] { dt.getLastError() }, null);
              }
              application.setUserName(null);
              application.setPassword(null);
              application.setProjectName(null);
            } else if (!dt.hasValidProjectName()) {
              result.rejectValue("projectName", "errors.detail",
                  new String [] { invalidProjectName }, null);
              application.setProjectName(null);
            } else {
              encryptCredentials(application);
              application.setProjectId(dt.getProjectIdByName());
              return checkNewDefectTracker(application);
            }
          }
        }
      }
View Full Code Here

  @Override
  public boolean checkUrl(DefectTracker defectTracker, BindingResult result) {
    if (defectTracker != null && defectTracker.getDefectTrackerType() != null &&
        defectTracker.getUrl() != null) {
     
      AbstractDefectTracker tracker = DefectTrackerFactory.getTracker(
          defectTrackerTypeDao.retrieveById(defectTracker.getDefectTrackerType().getId()));
     
      if (tracker != null) {
        tracker.setUrl(defectTracker.getUrl());
       
        if (tracker.hasValidUrl()) {
          return true;
        } else if (tracker.getLastError() != null) {
          result.rejectValue("url", null, null, tracker.getLastError());
          return false;
        }
      }
    }
   
View Full Code Here

   
    if (application != null) {
      applicationService.decryptCredentials(application);
    }
   
    AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    if (dt == null) {
      log.warn("Unable to load Defect Tracker.");
      return null;
    }
   
    String editedSummary = summary, editedPreamble = preamble;

    // TODO handle error cases better.
    if (editedSummary == null || editedSummary.equals("")) {
      if (vuln.getGenericVulnerability() != null && vuln.getSurfaceLocation() != null) {
        editedSummary = createMessage(vuln);
      } else {
        editedSummary = "No editedSummary could be parsed.";
      }
    }

    if (editedPreamble == null || editedPreamble.equals("")) {
      if (vuln.getGenericVulnerability() != null && vuln.getSurfaceLocation() != null) {

                if(additionalScannerInfo){
                    String additionalScannerInfoStr = getAdditionalScannerInfo(allVulns);

                    if(additionalScannerInfoStr == null || additionalScannerInfoStr.equals("")){
                        editedPreamble = createMessage(vuln);
                    } else  {
                        editedPreamble = createMessageWithScannerInfo(vuln, additionalScannerInfoStr);
                    }
                } else {
                    editedPreamble = createMessage(vuln);
                }
      } else {
        editedPreamble = "No editedPreamble could be parsed.";
      }
    }

    List<Vulnerability> vulnsWithoutDefects = list();

    for (Vulnerability vulnerability : allVulns) {
      if (vulnerability.getDefect() == null) {
        vulnsWithoutDefects.add(vulnerability);
      }
    }

    if (vulnsWithoutDefects.size() == 0) {
      log.warn("All the vulnerabilities already had defects, exiting.");
      return null;
    }
   
    String defectTrackerName = null;
    if (application != null && application.getDefectTracker() != null
        && application.getDefectTracker().getDefectTrackerType() != null
        && application.getDefectTracker().getDefectTrackerType().getName() != null) {
      defectTrackerName = application.getDefectTracker().getDefectTrackerType().getName();
    }
   
    if (defectTrackerName != null) {
      log.info("About to submit a defect to " + defectTrackerName + ".");
    } else {
      log.info("About to submit a defect to the defect tracker.");
    }
   
    String defectId = dt.createDefect(vulnsWithoutDefects,
        new DefectMetadata(editedSummary, editedPreamble,
        component, version, severity, priority, status, fieldsMap));

    if (defectId != null) {
     
      Defect defect = new Defect();
      defect.setNativeId(defectId);
      defect.setVulnerabilities(vulnsWithoutDefects);
      defect.setApplication(application);
            Object sObj = null;
            if (fieldsMap != null && status == null) {
                sObj = fieldsMap.get("status")==null ? fieldsMap.get("Status") : fieldsMap.get("status");
            }
      status = (sObj != null ? String.valueOf(sObj) : status);

            // By default, set status to Open
            if (status == null)
                status = "Open";

            defect.setStatus(status);
      defect.setDefectURL(dt.getBugURL(
          application.getDefectTracker().getUrl(), defectId));
      defectDao.saveOrUpdate(defect);

      for (Vulnerability vulnerability : vulnsWithoutDefects) {
        vulnerability.setDefect(defect);
        vulnerability.setDefectSubmittedTime(Calendar.getInstance());
        vulnerabilityDao.saveOrUpdate(vulnerability);
      }
     
      if (defectTrackerName != null) {
        log.info("Successfully submitted defect to " + defectTrackerName + ".");
      } else {
        log.info("Successfully submitted defect.");
      }
            map.put(DEFECT, defect);
      return map;
    }
   
    if (defectTrackerName != null) {
      log.warn("There was an error submitting the defect to " + defectTrackerName + ".");
    } else {
      log.warn("There was an error submitting the defect.");
    }
        map.put(ERROR, dt.getLastError());
    return map;
  }
View Full Code Here

    Application application = vuln.getApplication();

        applicationService.decryptCredentials(application);

        AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    if (dt == null) {
      return noDefectTrackerError;
    }

    List<Vulnerability> vulnList = list();
   
    for (Vulnerability vulnerability : vulns) {
      if (vulnerability.getDefect() == null) {
        vulnList.add(vulnerability);
      }
    }

    if (vulnList.size() == 0) {
      return allVulnsAlreadyInSystem;
    }

    String trackerError = dt.getTrackerError();

    if (trackerError == null || trackerError.trim().equals("")) {
      return defaultTrackerError;
    } else {
      return trackerError;
View Full Code Here

      return false;
    }
   
        applicationService.decryptCredentials(application);

    AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    if (dt == null) {
      log.warn("Unable to load Defect Tracker, exiting.");
      return false;
    }
   
    if (application.getDefectList() == null ||
        application.getDefectList().size() == 0) {
      log.warn("No Defects found, updating information is " +
          "only useful after creating Defects. Exiting.");
      return false;
    }

    Map<Defect, Boolean> defectMap = dt.getMultipleDefectStatus(
        application.getDefectList());
    if (defectMap == null) {
      log.warn("There was an error retrieving information from the " +
          "Defect Tracker, exiting.");
      return false;
View Full Code Here

            return false;
        }

        applicationService.decryptCredentials(application);

    AbstractDefectTracker dt = DefectTrackerFactory.getTracker(application);
    if (dt == null) {
      log.warn("Unable to load Defect Tracker.");
      return false;
    }
    Defect defect = new Defect();
    defect.setNativeId(id);
    defect.setDefectURL(dt.getBugURL(
        application.getDefectTracker().getUrl(), id));
    defect.setApplication(application);
    List<Defect> defectList = list();
    defectList.add(defect);
        Map<Defect, Boolean> map = dt.getMultipleDefectStatus(defectList);
        if (map.isEmpty())
            return false;
    defectDao.saveOrUpdate(defect);

    for (Vulnerability vulnerability : vulnerabilities) {
View Full Code Here

TOP

Related Classes of com.denimgroup.threadfix.service.defects.AbstractDefectTracker

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.