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

Incorrect package name returned by pip parser #307

Closed
aasish-r opened this issue May 22, 2024 · 1 comment
Closed

Incorrect package name returned by pip parser #307

aasish-r opened this issue May 22, 2024 · 1 comment

Comments

@aasish-r
Copy link

aasish-r commented May 22, 2024

While scanning I have come across a requirements.txt from a templating engine which is being used to generate the final requirements.txt file.
For example this is a line from the above mentioned requirements.txt file
... %ifcookiecutter.command_line_interface|lower=='click'-%} ...
Since we scan all requirements.txt files while doing a file system scan we would be splitting the line by == to get package name and version (as per logic here). As we can see this result is not intended, I'm wondering if we can add some validation and skip these kind of lines which lead to incorrect/invalid packages (in not just pip parser but in other languages as well)
Below is an example of the packages being generated as part of output of trivy scan when we do a file system scan in the above mentioned scenario.
{ "Target": "opt/conda/pkgs/cookiecutter-2.6.0-py311h06a4308_0/info/test/tests/test-templates/include/{{cookiecutter.project_slug}}/requirements.txt", "Class": "lang-pkgs", "Type": "pip", "Packages": [ { "Name": "{%ifcookiecutter.command_line_interface|lower", "Identifier": { "PURL": "pkg:pypi/%7B%25ifcookiecutter.command-line-interface%7Clower@%27click%27-%25%7D" }, "Version": "'click'-%}", "Layer": {} }, { "Name": "{%ifcookiecutter.use_pytest", "Identifier": { "PURL": "pkg:pypi/%7B%25ifcookiecutter.use-pytest@%27y%27-%25%7D" }, "Version": "'y'-%}", "Layer": {} } ] }

@knqyf263
Copy link
Collaborator

moved to aquasecurity/trivy#6750

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

2 participants