package com.freeleaps.devops.sast

interface SASTScanner {
  def scan()
}

abstract class SASTScannerBase implements SASTScanner {
  def steps
  def workspace
  def configs // TODO: add configurations file support
  def scannerType

  SASTScannerBase(steps, workspace, configs, scannerType) {
    this.steps = steps
    this.workspace = workspace
    this.configs = configs
    this.scannerType = scannerType
  }

  def scan() {
    steps.log.info("${scannerType.scanner}", "Scanning ${scannerType.language.language} code")
    steps.log.info("${scannerType.scanner}", "Workspace sets to: ${workspace}")

    if (configs != null || !configs.isEmpty()) {
      steps.log.warn("${scannerType.scanner}", "Configurations file is not supported for ${scannerType.scanner} yet")
    }

    doScan()
    steps.log.info("${scannerType.scanner}", "Code scanning has been completed")
  }

  abstract def doScan()
}