mirror of
https://github.com/kubescape/kubescape.git
synced 2026-02-14 18:09:55 +00:00
* bump version Signed-off-by: David Wertenteil <dwertent@armosec.io> * change default view Signed-off-by: David Wertenteil <dwertent@armosec.io> * fixed tests Signed-off-by: David Wertenteil <dwertent@armosec.io> * fixed go mod Signed-off-by: David Wertenteil <dwertent@armosec.io> --------- Signed-off-by: David Wertenteil <dwertent@armosec.io>
29 lines
960 B
Go
29 lines
960 B
Go
package shared
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/kubescape/go-logger/helpers"
|
|
"github.com/kubescape/kubescape/v3/core/cautils"
|
|
reporthandlingapis "github.com/kubescape/opa-utils/reporthandling/apis"
|
|
)
|
|
|
|
var ErrUnknownSeverity = fmt.Errorf("unknown severity. Supported severities are: %s", strings.Join(reporthandlingapis.GetSupportedSeverities(), ", "))
|
|
|
|
// ValidateSeverity returns an error if a given severity is not known, nil otherwise
|
|
func ValidateSeverity(severity string) error {
|
|
for _, val := range reporthandlingapis.GetSupportedSeverities() {
|
|
if strings.EqualFold(severity, val) {
|
|
return nil
|
|
}
|
|
}
|
|
return ErrUnknownSeverity
|
|
|
|
}
|
|
|
|
// TerminateOnExceedingSeverity terminates the program if the result exceeds the severity threshold
|
|
func TerminateOnExceedingSeverity(scanInfo *cautils.ScanInfo, l helpers.ILogger) {
|
|
l.Fatal("result exceeds severity threshold", helpers.String("Set severity threshold", scanInfo.FailThresholdSeverity))
|
|
}
|