mirror of
https://github.com/anchore/syft
synced 2024-11-10 14:24:12 +00:00
fb0857ff93
* change directory resolver to ignore system runtime paths + drive by index Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add event/etui support for filesystem indexing (for dir resolver) Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add warnings for path indexing problems Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * add directory resolver index tests Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * improve testing around directory resolver Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * renamed p var to path when not conflicting with import Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * pull docker image in CLI dir scan timeout test Signed-off-by: Alex Goodman <alex.goodman@anchore.com> * ensure file not exist errors do not stop directory resolver indexing Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
21 lines
482 B
Go
21 lines
482 B
Go
package internal
|
|
|
|
import "strings"
|
|
|
|
// 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
|
|
}
|
|
|
|
func TruncateMiddleEllipsis(input string, maxLen int) string {
|
|
if len(input) <= maxLen {
|
|
return input
|
|
}
|
|
return input[:maxLen/2] + "..." + input[len(input)-(maxLen/2):]
|
|
}
|