mirror of
https://github.com/project-zot/zot.git
synced 2024-12-16 21:56:37 -05:00
fac1d1d05d
1. chore(trivy): update trivy library version The trivy team switched github.com/urfave/cli for viper so there are some other code changes as well. Since we don't use github.com/urfave/cli directly in our software we needed to add a tools.go in order for "go mod tidy" to not delete it. See this pattern explained in: - https://github.com/99designs/gqlgen#quick-start - https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module - https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md#walk-through The jobs using "go get -u" have been updated to use "go install", since go get modifies the go.mod by upgrading some of the packages, but downgrading trivy to an older version with broken dependencies 2. fix(storage) Update local storage to ignore folder names not compliant with dist spec Also updated trivy to download the DB and cache results under the rootDir/_trivy folder 3. fix(s3): one of the s3 tests was missing the skipIt call This caused a failure when running locally without s3 being available 4. make sure the offline scanning is enabled, and zot only downloads the trivy DB on the regular schedule, and doesn't download the DB on every image scan ci: increase build and test timeout as tests are reaching the limit more often Signed-off-by: Andrei Aaron <aaaron@luxoft.com>
78 lines
2.4 KiB
Go
78 lines
2.4 KiB
Go
package regexp
|
|
|
|
import "regexp"
|
|
|
|
//nolint:gochecknoglobals
|
|
var (
|
|
// alphaNumericRegexp defines the alpha numeric atom, typically a
|
|
// component of names. This only allows lower case characters and digits.
|
|
alphaNumericRegexp = match(`[a-z0-9]+`)
|
|
|
|
// separatorRegexp defines the separators allowed to be embedded in name
|
|
// components. This allow one period, one or two underscore and multiple
|
|
// dashes.
|
|
separatorRegexp = match(`(?:[._]|__|[-]*)`)
|
|
|
|
// nameComponentRegexp restricts registry path component names to start
|
|
// with at least one letter or number, with following parts able to be
|
|
// separated by one period, one or two underscore and multiple dashes.
|
|
nameComponentRegexp = expression(
|
|
alphaNumericRegexp,
|
|
optional(repeated(separatorRegexp, alphaNumericRegexp)))
|
|
|
|
// NameRegexp is the format for the name component of references. The
|
|
// regexp has capturing groups for the domain and name part omitting
|
|
// the separating forward slash from either.
|
|
NameRegexp = expression(
|
|
nameComponentRegexp,
|
|
optional(repeated(literal(`/`), nameComponentRegexp)))
|
|
|
|
// FullNameRegexp is the format which matches the full string of the
|
|
// name component of reference.
|
|
FullNameRegexp = expression(match("^"), NameRegexp, match("$"))
|
|
)
|
|
|
|
// match compiles the string to a regular expression.
|
|
//
|
|
//nolint:gochecknoglobals
|
|
var match = regexp.MustCompile
|
|
|
|
// literal compiles s into a literal regular expression, escaping any regexp
|
|
// reserved characters.
|
|
func literal(s string) *regexp.Regexp {
|
|
regx := match(regexp.QuoteMeta(s))
|
|
|
|
if _, complete := regx.LiteralPrefix(); !complete {
|
|
panic("must be a literal")
|
|
}
|
|
|
|
return regx
|
|
}
|
|
|
|
// expression defines a full expression, where each regular expression must
|
|
// follow the previous.
|
|
func expression(res ...*regexp.Regexp) *regexp.Regexp {
|
|
var s string
|
|
for _, re := range res {
|
|
s += re.String()
|
|
}
|
|
|
|
return match(s)
|
|
}
|
|
|
|
// optional wraps the expression in a non-capturing group and makes the
|
|
// production optional.
|
|
func optional(res ...*regexp.Regexp) *regexp.Regexp {
|
|
return match(group(expression(res...)).String() + `?`)
|
|
}
|
|
|
|
// repeated wraps the regexp in a non-capturing group to get one or more
|
|
// matches.
|
|
func repeated(res ...*regexp.Regexp) *regexp.Regexp {
|
|
return match(group(expression(res...)).String() + `+`)
|
|
}
|
|
|
|
// group wraps the regexp in a non-capturing group.
|
|
func group(res ...*regexp.Regexp) *regexp.Regexp {
|
|
return match(`(?:` + expression(res...).String() + `)`)
|
|
}
|