-
Notifications
You must be signed in to change notification settings - Fork 2
Feature/803 include other dependencies in vulnerability report #806
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
Draft
ArBridgeman
wants to merge
10
commits into
main
Choose a base branch
from
feature/803_include_other_dependencies_in_reports
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4214475
Refactor out inner function for exporting & update nosec comments
ArBridgeman 59f310d
Move poetry_2_1_pyproject_toml to conftest.py for sharing
ArBridgeman bb1688b
Expand test to another variant
ArBridgeman e5d2800
Add sample versions to conftest for later simplified usage
ArBridgeman 2181b07
Simplify setup
ArBridgeman 7c95548
Move fixtures around for simplified usage and prevent local poetry ch…
ArBridgeman cad38f4
Use new fixture and add optional dependency ruff
ArBridgeman d4a1a4b
Update poetry dependencies and test
ArBridgeman b958f5f
Add export plugin to conftest
ArBridgeman b3e4066
With poetry export fixture
ArBridgeman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| import subprocess | ||
| from enum import Enum | ||
|
|
||
| import pytest | ||
|
|
||
|
|
||
| class SampleVersions(str, Enum): | ||
| black = "25.1.0" | ||
| isort = "6.0.1" | ||
| pylint = "3.3.7" | ||
| ruff = "0.14.14" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def sample_versions(): | ||
| return SampleVersions | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def poetry_2_1_pyproject_text(sample_versions) -> str: | ||
| return f""" | ||
| [project] | ||
| name = "project" | ||
| version = "0.1.0" | ||
| description = "" | ||
| authors = [] | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "pylint (=={sample_versions.pylint})" | ||
| ] | ||
|
|
||
| [tool.poetry] | ||
| packages = [{{include = "project", from = "src"}}] | ||
|
|
||
| [tool.poetry.group.dev.dependencies] | ||
| isort = "{sample_versions.isort}" | ||
|
|
||
| [tool.poetry.group.analysis.dependencies] | ||
| black = "{sample_versions.black}" | ||
|
|
||
| [project.optional-dependencies] | ||
| ruff = [ "ruff (=={sample_versions.ruff})" ] | ||
|
|
||
| [build-system] | ||
| requires = ["poetry-core>=2.0.0,<3.0.0"] | ||
| build-backend = "poetry.core.masonry.api" | ||
| """ | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def poetry_2_3_pyproject_text(sample_versions) -> str: | ||
| return f""" | ||
| [project] | ||
| name = "project" | ||
| version = "0.1.0" | ||
| description = "" | ||
| authors = [] | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| dependencies = [ | ||
| "pylint (=={sample_versions.pylint})" | ||
| ] | ||
|
|
||
| [tool.poetry] | ||
| packages = [{{include = "project", from = "src"}}] | ||
|
|
||
| [dependency-groups] | ||
| dev = [ | ||
| "isort=={sample_versions.isort}", | ||
| ] | ||
| analysis = [ | ||
| "black=={sample_versions.black}" | ||
| ] | ||
|
|
||
| [project.optional-dependencies] | ||
| ruff = [ "ruff (=={sample_versions.ruff})" ] | ||
|
|
||
| [build-system] | ||
| requires = ["poetry-core>=2.0.0,<3.0.0"] | ||
| build-backend = "poetry.core.masonry.api" | ||
| """ | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def cwd(tmp_path_factory): | ||
| return tmp_path_factory.mktemp("test") | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def project_name(): | ||
| return "project" | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def project_path(cwd, project_name): | ||
| return cwd / project_name | ||
|
|
||
|
|
||
| @pytest.fixture(scope="module") | ||
| def create_new_poetry_project( | ||
| poetry_path, cwd, project_name, project_path, sample_versions | ||
| ): | ||
| subprocess.run([poetry_path, "new", project_name], cwd=cwd, check=True) | ||
|
|
||
| commands = [ | ||
| [poetry_path, "self", "add", "poetry-plugin-export"], | ||
| [poetry_path, "add", f"pylint=={sample_versions.pylint}"], | ||
| [poetry_path, "add", "--group", "dev", f"isort=={sample_versions.isort}"], | ||
| [poetry_path, "add", "--group", "analysis", f"black=={sample_versions.black}"], | ||
| [poetry_path, "add", f"ruff@{sample_versions.ruff}", "--optional", "ruff"], | ||
| ] | ||
| for cmd in commands: | ||
| subprocess.run(cmd, cwd=project_path, env={}, check=True) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
If we think it's worthwhile to differentiate main and optional dependency groups, then we will need to make an issue for it.
While we could add snippet to capture optional-dependency groups in this property (
PoetryToml.groups). This would be problematic when the groups are then used inPoetryDependencies.direct_dependencies, as the command to extract which groups goes with which dependencies will not work:In fact, there is not a way to differentiate between
mainandoptional-dependenciesfrom this command, which means currentoptional-dependencies(when they exist in a project) are already undermain. Additionally, as the PEP-compliance of poetry continues to involve, it might be foolhardy for us to try to extract this ourselves from thepyproject.toml, and in thepoetry.lock, the markings overlap, meaning one cannot say it is directly from main, transitive, etc.So it would need to be thought about how one could approach this with minimal effort.
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.
See https://github.com/exasol/python-toolbox/pull/806/changes#r3145359536 for a reference of what I described above with optional dependencies being reported in
main.