All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.securecodebox.persistence.defectdojo.service.ImportScanService Maven / Gradle / Ivy

The newest version!
// SPDX-FileCopyrightText: the secureCodeBox authors
//
// SPDX-License-Identifier: Apache-2.0

package io.securecodebox.persistence.defectdojo.service;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.securecodebox.persistence.defectdojo.ScanType;
import io.securecodebox.persistence.defectdojo.config.Config;
import io.securecodebox.persistence.defectdojo.http.ProxyConfig;
import io.securecodebox.persistence.defectdojo.http.ProxyConfigFactory;
import io.securecodebox.persistence.defectdojo.model.ScanFile;
import lombok.Data;
import lombok.NonNull;

import java.util.HashMap;
import java.util.Map;

/**
 * Service to re/import findings into DefectDojo
 */
public interface ImportScanService {
  /**
   * Factory method to create new instance of service default implementation
   *
   * @param config must not be {@code null}
   * @return never {@code null}
   */
  static ImportScanService createDefault(final Config config) {
    return createDefault(config, new ProxyConfigFactory().create());
  }

  /**
   * Factory method to create new instance of service default implementation
   *
   * @param config      must not be {@code null}
   * @param proxyConfig must not be {@code null}
   * @return never {@code null}
   */
  static ImportScanService createDefault(@NonNull final Config config, @NonNull final ProxyConfig proxyConfig) {
    return new DefaultImportScanService(config, proxyConfig);
  }

  default ImportScanResponse importScan(ScanFile scanFile, long engagementId, long lead, String currentDate, ScanType scanType, long testType) {
    return this.importScan(scanFile, engagementId, lead, currentDate, scanType, testType, new HashMap<>());
  }

  ImportScanResponse importScan(ScanFile scanFile, long engagementId, long lead, String currentDate, ScanType scanType, long testType, Map options);

  default ImportScanResponse reimportScan(ScanFile scanFile, long testId, long lead, String currentDate, ScanType scanType, long testType) {
    return this.reimportScan(scanFile, testId, lead, currentDate, scanType, testType, new HashMap<>());
  }

  ImportScanResponse reimportScan(ScanFile scanFile, long testId, long lead, String currentDate, ScanType scanType, long testType, Map options);

  @Data
  class ImportScanResponse {
    @JsonProperty
    protected Boolean verified;

    @JsonProperty
    protected Boolean active;

    @JsonProperty("test")
    protected long testId;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy