Skip to content

fix(vulnfeeds): add more phrases for extracting versions#4550

Open
Harshit28j wants to merge 2 commits intogoogle:masterfrom
Harshit28j:fix/regex-version-extraction
Open

fix(vulnfeeds): add more phrases for extracting versions#4550
Harshit28j wants to merge 2 commits intogoogle:masterfrom
Harshit28j:fix/regex-version-extraction

Conversation

@Harshit28j
Copy link

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 through and before keywords, 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:

  1. Prefix pattern: For phrases where version comes after the keyword (before, prior to, below, etc.)
  2. Trailing pattern: For phrases where version comes before the keyword (and earlier, or older, and below)

Testing

  • Existing tests pass (go test -run TestExtractVersionInfo)
  • Code formatted (go fmt ./...)
  • Code vetted (go vet ./...)
image

@another-rex
Copy link
Contributor

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.)

@another-rex
Copy link
Contributor

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.

@jess-lowe
Copy link
Contributor

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 :)

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.

vulnfeeds: Add some more common phrases when extracting versions from CVE description

3 participants