
com.danielsomerfield.cvecheck.gradle.handlers.buildRules.CVSSIndividualThresholdBuildRule.groovy Maven / Gradle / Ivy
package com.danielsomerfield.cvecheck.gradle.handlers.buildRules
import com.danielsomerfield.cvecheck.ScanResult
import com.danielsomerfield.cvecheck.Vulnerability
import static com.danielsomerfield.cvecheck.gradle.handlers.buildRules.RuleOutcome.Failed
import static com.danielsomerfield.cvecheck.gradle.handlers.buildRules.RuleOutcome.Passed
class CVSSIndividualThresholdBuildRule implements BuildRule {
private static final int DEFAULT = 5
protected int threshold
CVSSIndividualThresholdBuildRule(BuildRuleConfiguration configuration) {
//TODO: replace with default mechanism
this.threshold = configuration.threshold.getValue(DEFAULT)
}
@Override
RuleOutcome execute(final ScanResult result) {
float cvss = result.vulnerabilities.inject(0f) { float highest, Vulnerability vuln
-> highest > vuln.cvssScore() ? highest : vuln.cvssScore() }
cvss > threshold ? Failed : Passed
}
@Override
String getName() {
"CVSS Individual Threshold"
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy