Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing and comparing versions with build information #8

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

bpfoster
Copy link
Contributor

@bpfoster bpfoster commented Nov 4, 2024

This regex is pretty complex and I don't grok it all. I found that removing the last ? allows expected results when build information is present, and does not break any existing scenarios covered by unit tests.
With 2 ?'s, regex101 describes this as

?? matches the previous token between zero and one times, as few times as possible, expanding as needed (lazy)

vs with 1 ?:

? matches the previous token between zero and one times, as many times as possible, giving back as needed (greedy)

Additionally I added multiple test cases to validate build information being handled as expected. Per the semver spec, "Build metadata MUST be ignored when determining version precedence" - added test cases verify that it is in fact ignored as expected.

fixes #7

@knqyf263 knqyf263 merged commit 1951e80 into aquasecurity:main Nov 5, 2024
2 checks passed
@knqyf263
Copy link
Collaborator

knqyf263 commented Nov 5, 2024

Thanks

@bpfoster bpfoster deleted the issue-7 branch November 5, 2024 12:06
@bpfoster
Copy link
Contributor Author

bpfoster commented Nov 5, 2024

Do you require me to update go-version in go.mod in trivy or will this get picked up in another manner?

@knqyf263
Copy link
Collaborator

knqyf263 commented Nov 5, 2024

You can open a PR bumping go-version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected non-match in version when build is present in constraint
2 participants