harden OSTypeProber with regex list against version updates#300
Merged
harden OSTypeProber with regex list against version updates#300
Conversation
cc570a4 to
559fefa
Compare
559fefa to
89ad1e9
Compare
majewsky
requested changes
Mar 23, 2026
liquidapi/constants.go
Outdated
| // We do not recommend utilizing this regex list for anything else other than | ||
| // validating the "vmware_ostype" attribute on existing images. | ||
|
|
||
| var isValidVMwareOSTypeRegex = map[regexpext.BoundedRegexp]bool{ |
Contributor
There was a problem hiding this comment.
BoundedRegexp has a very limited cache for regex compilations. Putting this many regexes in there will make the cache perform very badly. Please compile the regexes explicitly, e.g.
var validVMWareOsTypeRegexes = []*regexp.Regexp{
regexp.MustCompile(`^almalinux_64Guest$`),
regexp.MustCompile(`^amazonlinux(\d+)_64Guest$`),
...
}e3226ad to
d59d2ad
Compare
majewsky
requested changes
Mar 24, 2026
Contributor
majewsky
left a comment
There was a problem hiding this comment.
I can reproduce the CI failure. Do you have the latest golangci-lint version locally (2.11.4)?
d59d2ad to
3804bc1
Compare
Merging this branch will decrease overall coverage
Coverage by fileChanged files (no unit tests)
Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code. Changed unit test files
|
majewsky
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
We recently had the problem, that unknown
vmware_ostypevalues are present on newer images, which makes theOSTypeProberrender them invalid. This then causes wrong figures in billing.In order to make this robust, we could go with regexes which replace the version numbers with placeholders. IMHO, this should be very safe, because a specific version number should not be an indicator to not bill an image. I copied the outdated list with specific entries to the test, so we make sure we don't loose any coverage.
cc @kc1r74p