-
Notifications
You must be signed in to change notification settings - Fork 110
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(python): support python requirements.txt #32
feat(python): support python requirements.txt #32
Conversation
@@ -0,0 +1,8 @@ | |||
click==8.0.0 | |||
Flask==2.0.0 | |||
itsdangerous==2.0.0 |
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.
Thank you for Pull Request.
https://pip.pypa.io/en/latest/cli/pip_install/#requirements-file-format
The following patterns should need to be supported.
itsdangerous==2.0.0 # a comment
# itsdangerous==2.0.0
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.
Added comment stripping and test coverage for this. Let me know if further test cases are required.
pkg/python/parse_test.go
Outdated
file: "testdata/requirements_flask.txt", | ||
want: requirementsFlask, |
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.
Please add more tests. requirements.txt
may include requirements without version specifiers, other requirements files, etc.
https://pip.pypa.io/en/latest/cli/pip_install/#requirements-file-format
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.
Also, the version may have spaces after ==
as follows.
docopt == 0.6.1
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.
Added whitespace stripping and test coverage for this. Let me know if more is required.
Added additional test coverage
@Sam-Lane FeatureCould you support this specification? No support for comparison operators other than "==" is required. TestAnd add test more format. e.g
|
As the operator other that == suggests range of versions, these will be ignored
50456ac
to
8a0bcb5
Compare
pkg/python/parse.go
Outdated
@@ -34,8 +36,8 @@ func Parse(r io.Reader) ([]types.Library, error) { | |||
return libs, nil | |||
} | |||
|
|||
func stripComments(line *string) { | |||
if pos := strings.IndexAny(*line, commentRune); pos >= 0 { | |||
func RstripByKey(line *string, key string) { |
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.
Why do you need to export this function? And I prefer returning updated text like strings.TrimPrefix
.
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.
Sorry, it was a mistake
6b7a617
to
4949673
Compare
4949673
to
8f18007
Compare
Raising to help support this ticket in Trivy.
aquasecurity/trivy#492
Thank you.