Skip to content

feat: implement coarse versioning in go#5225

Open
michaelkedar wants to merge 2 commits intogoogle:masterfrom
michaelkedar:🏜️🏞️

Hidden character warning

The head ref may contain hidden characters: "\ud83c\udfdc\ufe0f\ud83c\udfde\ufe0f"
Open

feat: implement coarse versioning in go#5225
michaelkedar wants to merge 2 commits intogoogle:masterfrom
michaelkedar:🏜️🏞️

Conversation

@michaelkedar
Copy link
Copy Markdown
Member

Re-implements the EE:XXXXXXXX.YYYYYYYY.ZZZZZZZZ comparable version string generation in Go from Python.

The implementations are mostly the same as the Python ones, but the semantic submodule in scalibr is generally much more lenient in accepting technically invalid versions (dunno if we should be being more strict about this).

Differences are mostly due to how we want to handle invalid versions, which I don't think really appears in the OSV database. I'll do a pass over the AffectedVersions in the database once the worker is migrated to Go to make sure this is all consistent anyway.

I created a program & test that compiles every single unique version (from affected[].versions and affected[].ranges[]) in every single OSV record, and verifies that Parse and Coarse both error on the same strings, and Coarse maintains monotonicity. This test doesn't run by default because a) the versions list is 22MB big and b) it takes a while to generate and run.

I've also added some fuzzing tests to help catch edge cases if we want to run them for a bit. It's already helped me find a few edge cases in dpkg and packagist, which is nice. The regular tests run the fuzzers with only the explicit seed corpus. To do full fuzzing, you need to run it manually.

APK is currently not implemented due to transitivity issues in scalibr that I'm looking to fix (google/osv-scalibr#1932)

Copy link
Copy Markdown
Contributor

@another-rex another-rex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just some minor questions.

Comment thread go/osv/ecosystem/apk.go
}

func (e apkEcosystem) Coarse(_ string) (string, error) {
// TODO(michaelkedar): semantic.AlpineVersion currently breaks transitivity rules
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if coarse is not supported when querying at the moment? Is it just everything for a specific package has to be loaded into memory?

)

func TestCoarseMonotonicityLarge(t *testing.T) {
if os.Getenv("RUN_COARSE_LARGE_TEST") != "1" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you document this env somewhere.

Also ideally add this to the Makefile as a help option similar to osv-scanner, though I think that can wait till we moved everything over to go.

Comment thread go/osv/ecosystem/util.go
EmptyAs *string // If not nil, treats empty parts as the given string instead of removing them. If nil, removes them.
}

var implicitRegex = regexp.MustCompile(`\d+|\D+`)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does implicit mean here...?

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.

2 participants