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

com.danielsomerfield.cvecheck.gradle.handlers.VulnerabilityCountResultHandler.groovy Maven / Gradle / Ivy

There is a newer version: 0.6.2-100
Show newest version
package com.danielsomerfield.cvecheck.gradle.handlers

import com.danielsomerfield.cvecheck.ScanResult
import com.danielsomerfield.cvecheck.ScanResultHandler
import org.gradle.api.GradleException
import org.slf4j.Logger
import org.slf4j.LoggerFactory

public class VulnerabilityCountResultHandler implements ScanResultHandler {
  private final Logger logger = LoggerFactory.getLogger(this.getClass())
  private final int allowedVulnerabilities;

  VulnerabilityCountResultHandler(int allowedVulnerabilities = 0) {
    this.allowedVulnerabilities = allowedVulnerabilities
  }

  @Override
  def void handleScanResult(ScanResult scanResult) {
    if (scanResult.vulnCount > allowedVulnerabilities) {
      logger.info("Detected vulns!")
      throw new GradleException("${scanResult.vulnCount} vulnerabilities were detected")
    } else {
      logger.info("No vulnerabilities detected.")
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy