goharbor / harbor

An open source trusted cloud native registry project that stores, signs, and scans content.
https://goharbor.io
Apache License 2.0
23.86k stars 4.74k forks source link

Allow real regexp patterns for tag matching in retention policy/immutability rules #19328

Open Cobraeti opened 1 year ago

Cobraeti commented 1 year ago

Is your feature request related to a problem? Please describe. Hello, I'm trying to create an immutability rule for all SemVer tags corresponding to "normal" release versions (refered as <version core> at https://semver.org/). It seems even the tag matching is made using doublestar, wich is really limiting to describe widely-used SemVer tags, as [0-9].[0-9].[0-9] would only match versions with major/minor/patch up to 9, whereas *.*.* would match versions with major/minor/patch even over 9 but also any pre-release or build variants of the same version...

Describe the solution you'd like I would have expected tag matching rules to use a less limiting regexp engine, like https://pkg.go.dev/regexp#Regexp.Match, as doublestar is really nice for repo paths matching, but really poor for SemVer or any more generic tags matching...

Describe the main design/architecture of your solution Replace doublestar.Match by regexp.Match for tag rules (breaking API, maybe not desired) or allow kind: 'regexp' in addition to kind: 'doublestar' (by creating a regexp selector available at least for RetentionSelector and ImmutableSelector + maybe RetentionSelectorMetadata)

Describe the development plan you've considered I could contribute directly for option 1, but option 2 might be a bit too high-level for my coding skills :sweat_smile: Unless option 2 is just adding regexp/selector.go and regexp/selector_test.go to /src/lib/selector/selectors ? but I bet I'm dreaming :rofl:

Additional context I'm currently stuck with Harbor version 2.5.6 because of my cloud provider offer, but able to start a higher version aside with a custom deployment if it could help testing :wink:

AzHicham commented 9 months ago

+1

Right now I can make tag like x.y.z immutable but this will also include dev tags like x.y.z-dev.N which is not the desired behavior

sebhoss commented 8 months ago

I've opened https://github.com/bmatcuk/doublestar/issues/91 to ask for quantifier support for character classes in doublestar which would at least allow [0-9]+.[0-9]+.[0-9]+ matching