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: improve validation of cpes #4015

Open
terriko opened this issue Apr 9, 2024 · 0 comments
Open

fix: improve validation of cpes #4015

terriko opened this issue Apr 9, 2024 · 0 comments
Milestone

Comments

@terriko
Copy link
Contributor

terriko commented Apr 9, 2024

Moving this from a code review comment to a new issue because I decided it made more sense to merge the giant regex as an intermediate solution.

I love a ridiculous regex, but I think this is going to be hard to maintain and
it's almost certainly going to be vulnerable to regex denial of service.

Options:

  1. does anyone have a library for validating CPE strings we could leverage?
  2. In lieu of this, can we split on : and evaluate each piece separately with an explanation of what we're looking for in the comments?
  3. In lieu of this, can we split on : and only evaluate the parts we're going to use later? (e.g. vendor, product, version = cpe[2], cpe[3], cpe[4])
  4. In lieu of this, maybe we should validate and sanitize only vendor, product, version after the existing split?

I'm leaning towards the last one as potentially the right solution since that would allow us to have some util functions for sanitize_vendor(), sanitize_product(), sanitize_version() that we could re-use elsewhere in purl and triage work.

Originally posted by @terriko in #4014 (comment)

@terriko terriko added this to the 3.3.1 milestone Apr 16, 2024
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

No branches or pull requests

1 participant