Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/python_package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
distribution: 'zulu'
java-version: ${{ matrix.java-version }}
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
- name: Upgrade pip
run: |
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade build
python3 -m pip install .[tests] .[dev]
python3 -m pip install --upgrade pip==26.0 build==1.2.2
python3 -m pip install .[tests] .[dev] # NOSONAR - dynamic local package extras

Check warning on line 37 in .github/workflows/python_package.yml

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=ansible_drools_jpy&issues=AZ-A7oHwp3bAlirjeNb2&open=AZ-A7oHwp3bAlirjeNb2&pullRequest=84

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Lock dependencies installed through the test and development extras.

Although pip and build are pinned, pip install .[tests] .[dev] can still resolve transitive dependencies to changing index versions. Install these extras through a reviewed constraints/lock file with hashes, or otherwise lock the complete dependency graph.

As per path instructions, focus on major issues impacting performance, readability, maintainability and security.
🧰 Tools
🪛 GitHub Check: SonarCloud Code Analysis

[warning] 37-37: Using dependencies without locking resolved versions is security-sensitive.

See more on https://sonarcloud.io/project/issues?id=ansible_drools_jpy&issues=AZ-A7oHwp3bAlirjeNb2&open=AZ-A7oHwp3bAlirjeNb2&pullRequest=84

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/python_package.yml at line 37, Update the dependency
installation step in the workflow around the extras passed to pip so the
complete tests and dev dependency graph is resolved through the repository’s
reviewed, hash-verified constraints or lock file. Preserve installation of both
.[tests] and .[dev], and ensure every transitive dependency is constrained
rather than only pinning pip and build.

Sources: Path instructions, Linters/SAST tools

- name: Run flake8
run: flake8 .
- name: Run formatter
Expand Down
38 changes: 24 additions & 14 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[build-system]
requires = ["setuptools>=61.2", "jpy"]
requires = ["setuptools>=61.2", "jpy==2.1.0", "build==1.2.1"]
build-backend = "setuptools.build_meta"

[project]
Expand All @@ -19,28 +19,37 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
]
dependencies = [
"jpy",
"jpy==2.1.0",
]

[project.optional-dependencies]
local = [
'flake8',
'black',
'isort',
'tox',
'pyyaml',
"flake8 == 7.1.1",
"black == 24.10.0",
"isort == 5.13.2",
"pyyaml == 6.0.3"
]
tests = [
'coverage>=5.0.3',
'pytest',
'pytest-asyncio',
'pytest-cov',
'tox',
# ---- Python 3.9 Specific Pinned Versions ----
"coverage==7.4.4; python_version == '3.9'",
"pytest==8.3.4; python_version == '3.9'",
"pytest-asyncio==0.23.8; python_version == '3.9'",
"pytest-cov==5.0.0; python_version == '3.9'",
"tox==4.18.1; python_version == '3.9'",
"tox-gh-actions==3.2.0; python_version == '3.9'",

# ---- Fallbacks for Python 3.10 and Newer ----
"coverage==7.15.2; python_version > '3.9'",
"pytest==9.1.1; python_version > '3.9'",
"pytest-asyncio==1.4.0; python_version > '3.9'",
"pytest-cov==7.1.0; python_version > '3.9'",
"tox==4.57.0; python_version > '3.9'",
"tox-gh-actions==3.3.0; python_version > '3.9'"
]

dev = [
"drools_jpy[local]",
"drools_jpy[tests]",
"drools_jpy[local] == 0.4.1",
"drools_jpy[tests] == 0.4.1"
Comment on lines +51 to +52

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove version pins for self-referential dev dependencies.

Hardcoding the project's own version (0.4.1) here will cause dependency conflicts during local development. When the project's version is bumped in the future, running pip install -e .[dev] will either fail to resolve or incorrectly fetch the outdated 0.4.1 package from PyPI instead of using your local source code.

🐛 Proposed fix
-  "drools_jpy[local] == 0.4.1",
-  "drools_jpy[tests] == 0.4.1"
+  "drools_jpy[local]",
+  "drools_jpy[tests]"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"drools_jpy[local] == 0.4.1",
"drools_jpy[tests] == 0.4.1"
"drools_jpy[local]",
"drools_jpy[tests]"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pyproject.toml` around lines 51 - 52, Remove the == 0.4.1 version pins from
the self-referential drools_jpy[local] and drools_jpy[tests] dev dependencies in
pyproject.toml, preserving their extras so local development resolves the
current project source.

]

[project.urls]
Expand All @@ -60,6 +69,7 @@ legacy_tox_ini = """
[tox]
isolated_build = True
envlist = py39,py310,py311,py312
skip_missing_interpreters = true

[gh-actions]
python =
Expand Down
2 changes: 2 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sonar.sca.pythonResolveLocal=true
sonar.sca.enabled=false