-
Notifications
You must be signed in to change notification settings - Fork 588
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
feat: make python requirements.txt parser more inclusive #1597
feat: make python requirements.txt parser more inclusive #1597
Conversation
Signed-off-by: manifestori <[email protected]>
Signed-off-by: manifestori <[email protected]>
2590aaa
to
23acfe5
Compare
Sorry for the delay on this PR -- thanks for the contributing! I'm a little hesitant to guess at a specific version for these dependencies. We're starting to add more cataloger specific configurations in the future, I feel that this would be a great opt-in functionality, where by default there would still be no guessing, but an app config could allow for turning it on: # example .syft.yaml
...
python:
# when running across entries in requirements.txt that do not specify a specific
# version, attempt to guess what the version could be based on the version
# requirements specified.
#
# allowable input: "lowest-version", "highest-version", "false", "true"
# note: "true" is an alias for "lowest-version"
# default: "false"
guess-unpinned-requirements: true |
type PythonRequirementsMetadata struct {
name string
extras []string
versionConstraint string
url string
markers map[string]string
}
{
"name": "requests[security]"
"version": "2.8.1",
"metadata": {
"name": "requests",
"extras": [ "security" ],
"version": ">= 2.8.1, == 2.8.*",
"markers": {
"python_version": "< \"2.7\""
}
}
}
Edit: this was implemented in #1759 , but on rebase this could nicely leverage it 👍 |
Now that #1759 is merged, we'll need to account for URLs that are parsed to see if we can extract tags from URLs in cases where
|
Sorry for my delay; I've lost track of this PR and want to review all your comments. Pinging back soon :) |
no worries @manifestori, I was ready to rebase, add a little bit of code, and bring it across the finish line in case you were short on time (I got to this PR rather late 😳 ). Up to you! |
Hey @manifestori I went to rebase this and push more changes however it seems that this PR might not be enabled to allow maintainers to modify the PR. I could change the target branch to a feature branch in this repo, merge it, then make further adjustments in a subsequent PR of the in-repo feature branch. Are you ok with this? |
I was afk for awhile, yeah go ahead. as long as people benefit from this change, this would be amazing :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice work! I've changed the base branch to an in-repo branch so I can incorporate a rebase and configuration updates as discussed in the comments above.
Hi :)
This is my first contribution to the fantastic Syft CLI. I tried my best to keep to the standard 👯
Today, when parsing the
requirements.txt
file, Syft ignores unpinned packages when creating an SBOM.In most cases, this is OK. However, if we want to use the generated SBOM for vulnerability detection, we won't be able to know if an asset contains "any" occurrences of a skipped package.
I know that unpinned version cannot suggest the exact package version, which is problematic. However, I used the "closest version" approach to at least enable CPE matching when searching for vulnerabilities.
This behavior exists in other generators such as
cdxgen
Thank you for your time :))