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: version compare can't handle ~ in version numbers #3558

Closed
perrinjerome opened this issue Dec 2, 2023 · 3 comments · Fixed by #3565
Closed

fix: version compare can't handle ~ in version numbers #3558

perrinjerome opened this issue Dec 2, 2023 · 3 comments · Fixed by #3565
Labels
bug Something isn't working
Milestone

Comments

@perrinjerome
Copy link
Contributor

very similar to #3552

CannotParseVersionException: version string = 1.1.0l.1~deb9u2

happens with https://storage.googleapis.com/debian-osv/dla-osv/DLA-3008-1.json

@perrinjerome perrinjerome added the bug Something isn't working label Dec 2, 2023
@perrinjerome perrinjerome changed the title fix: version compare can't handle + in version numbers fix: version compare can't handle ~ in version numbers Dec 2, 2023
@terriko
Copy link
Contributor

terriko commented Dec 4, 2023

This one's interesting: even once we fix the ~ problem, it's still not going to know how to compare deb9u2. Is this pattern common enough that we should build this pattern into the version checker, or truncate it as I'm suggesting we do with the un-comparable hashes? This definitely looks more like something we could actually compare, but it's not clear to me if doing so makes things better or worse.

@terriko
Copy link
Contributor

terriko commented Dec 4, 2023

Also, now that I'm seeing some data (thank you so much for these bug reports!) it seems like it's probably worth going from individual character substitutions to something more like

s = re.sub('[^0-9a-zA-Z]+', '.', s)

And just subbing in anything that isn't alphanumeric. Need to do a bit of thinking or data crunching as to whether we need to support unicode here and have a slightly better regex to handle that, though.

@terriko terriko added this to the 3.3 milestone Dec 5, 2023
@terriko
Copy link
Contributor

terriko commented Dec 5, 2023

I did some additional asking around and consensus is that ignoring the distro part is probably good enough as a first step.

There's room for more finesse to use this data, and we might want to point people at the available_fix tools https://github.com/intel/cve-bin-tool/tree/main/cve_bin_tool/available_fix for some triage help. But for now I'm happy if the fix for #3556 handles the deb* part by truncating it.

terriko added a commit to terriko/cve-bin-tool that referenced this issue Dec 6, 2023
This switches the logic so we treat all non-alphanumeric characters as
separators equivalent to `.` in version strings.  This should make the
code more robust to unusual version strings.

* Fixes intel#3558 (in that we will be able to handle `~`)

Signed-off-by: Terri Oda <terri@toybox.ca>
terriko added a commit to terriko/cve-bin-tool that referenced this issue Dec 12, 2023
This switches the logic so we treat all non-alphanumeric characters as
separators equivalent to `.` in version strings.  This should make the
code more robust to unusual version strings.

* Fixes intel#3558 (in that we will be able to handle `~`)

Signed-off-by: Terri Oda <terri@toybox.ca>
terriko added a commit that referenced this issue Dec 12, 2023
This switches the logic so we treat all non-alphanumeric characters as
separators equivalent to `.` in version strings.  This should make the
code more robust to unusual version strings.

* Fixes #3558 (in that we will be able to handle `~`)

Signed-off-by: Terri Oda <terri.oda@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants