fix(vulnfeeds): add more phrases for extracting versions#4550
fix(vulnfeeds): add more phrases for extracting versions#4550Harshit28j wants to merge 2 commits intogoogle:masterfrom
Conversation
|
Please add real world examples of these different version formats, and add tests for them. (i.e. link to the CVEs, add them as test cases.) |
|
Thanks, mostly LGTM, though I'll let @jess-lowe take a look as well. 1 concern is most of these versions ranges seem to be from closed source CVEs, which we are not that interested in converting, so there's limited value there, but still good to have the functionality. |
|
Hey @Harshit28j, sorry for taking so long to review! I merged the changes locally with the changes I've been making for CVE conversion and have found at least one example in which it's picked up another version from the text description, so that is awesome! If it's possible, would you be able to update it to current level of changes / fix conflicts, and then I'm happy to merge :) |
Overview
Fixes #249
This PR extends the version extraction regex in ExtractVersionsFromText to support additional common phrases found in CVE descriptions.
Details
Problem
The existing regex only matched
throughandbeforekeywords, causing version information to be lost when CVE descriptions used other common phrasing.Solution
Added support for the following phrases:
up to and including(e.g., "versions 1.0 up to and including 2.3.4")prior to(e.g., "versions prior to 2.3.4")below(e.g., "versions below 2.3.4")and earlier(e.g., "version 2.3.4 and earlier")or older(e.g., "version 2.3.4 or older")and below(e.g., "version 2.3.4 and below")The implementation uses two regex patterns:
Testing
go test -run TestExtractVersionInfo)go fmt ./...)go vet ./...)