mirror of
https://github.com/anchore/grype
synced 2024-11-10 06:34:13 +00:00
30f05c3759
* Add --ignore-states flag for ignoring findings with by fix state Signed-off-by: James Hebden <jhebden@gitlab.com> * ignore options checked before scan, fail on invalid ignore states, ignore states comma-separated Signed-off-by: James Hebden <jhebden@gitlab.com> * Add CLI tests for new --ignore-states flag Signed-off-by: Will Murphy <will.murphy@anchore.com> --------- Signed-off-by: James Hebden <jhebden@gitlab.com> Signed-off-by: Will Murphy <will.murphy@anchore.com> Co-authored-by: Will Murphy <will.murphy@anchore.com>
36 lines
906 B
Go
36 lines
906 B
Go
package stringutil
|
|
|
|
import "strings"
|
|
|
|
// HasAnyOfSuffixes returns an indication if the given string has any of the given suffixes.
|
|
func HasAnyOfSuffixes(input string, suffixes ...string) bool {
|
|
for _, suffix := range suffixes {
|
|
if strings.HasSuffix(input, suffix) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// HasAnyOfPrefixes returns an indication if the given string has any of the given prefixes.
|
|
func HasAnyOfPrefixes(input string, prefixes ...string) bool {
|
|
for _, prefix := range prefixes {
|
|
if strings.HasPrefix(input, prefix) {
|
|
return true
|
|
}
|
|
}
|
|
|
|
return false
|
|
}
|
|
|
|
// SplitCommaSeparatedString returns a slice of strings separated from the input string by commas
|
|
func SplitCommaSeparatedString(input string) []string {
|
|
output := make([]string, 0)
|
|
for _, inputItem := range strings.Split(input, ",") {
|
|
if len(inputItem) > 0 {
|
|
output = append(output, inputItem)
|
|
}
|
|
}
|
|
return output
|
|
}
|