Skip to content

Sec/dependencies#332

Merged
helmut-hoffer-von-ankershoffen merged 6 commits intomainfrom
sec/dependencies
Dec 10, 2025
Merged

Sec/dependencies#332
helmut-hoffer-von-ankershoffen merged 6 commits intomainfrom
sec/dependencies

Conversation

@helmut-hoffer-von-ankershoffen
Copy link
Copy Markdown
Contributor

No description provided.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 9, 2025

Codecov Report

❌ Patch coverage is 31.81818% with 15 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/aignostics/wsi/_cli.py 36.84% 10 Missing and 2 partials ⚠️
src/aignostics/utils/_gui.py 0.00% 2 Missing and 1 partial ⚠️
Files with missing lines Coverage Δ
src/aignostics/utils/_gui.py 68.75% <0.00%> (-2.68%) ⬇️
src/aignostics/wsi/_cli.py 73.72% <36.84%> (-7.08%) ⬇️

... and 3 files with indirect coverage changes

@helmut-hoffer-von-ankershoffen helmut-hoffer-von-ankershoffen marked this pull request as ready for review December 9, 2025 22:13
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 9, 2025

Claude finished @helmut-hoffer-von-ankershoffen's task —— View job


PR Review: sec/dependencies

Comprehensive review completed for PR #332. This PR updates security dependencies and adds Python 3.14 compatibility workarounds.


Summary: Approve with One Critical Fix Required

The PR successfully addresses CVE fixes and Python 3.14 compatibility issues, but contains a critical test logic bug that causes test flakiness.


🚨 CRITICAL ISSUE - Test Logic Bug

Location: tests/aignostics/cli_test.py:210-227

Problem: The test has incorrect conditional logic using sequential if statements instead of if-elif-else, causing the else block to execute incorrectly.

Current Code (INCORRECT):

if platform.system() == "Linux":
    assert mock_ui_run_args["native"] is False, "..."
    # ...
if platform.system() == "Windows" and platform.python_version_tuple() >= ("3", "14"):
    assert mock_ui_run_args["native"] is False, "..."
    # ...
else:  # ❌ This else binds ONLY to the second if, not both!
    assert mock_ui_run_args["native"] is True, "..."
    # ...

Why This Fails:

  • On Windows Python 3.14+: The second if is True, so its block executes ✅
  • The else is NOT evaluated (correct behavior)
  • On macOS: First if is False, second if is False → else executes ✅
  • On Windows Python <3.14: First if is False, second if is False → else executes ✅
  • BUT the test is flaky because the logic intent is unclear and fragile

Correct Fix - Use if-elif-else:

if platform.system() == "Linux":
    assert mock_ui_run_args["native"] is False, "native parameter should be False on Linux"
    assert mock_ui_run_args["show_welcome_message"] is True, "..."
    assert mock_ui_run_args["show"] is True, "..."
elif platform.system() == "Windows" and platform.python_version_tuple() >= ("3", "14"):
    assert mock_ui_run_args["native"] is False, "native parameter should be False on Windows 3.14+"
    assert mock_ui_run_args["show_welcome_message"] is True, "..."
    assert mock_ui_run_args["show"] is True, "..."
else:
    # macOS or Windows <3.14
    assert mock_ui_run_args["native"] is True, "native parameter should be True on platforms other than Linux"
    assert mock_ui_run_args["show_welcome_message"] is False, "..."
    assert mock_ui_run_args["show"] is False, "..."

Why the Test Failed: The CodeCov comment shows the test failed with:

AssertionError: native parameter should be True on platforms other than Linux
assert False is True

This happens when the else block executes unexpectedly due to the incorrect if-if-else structure instead of if-elif-else.

Action Required:

# Fix the test logic
# File: tests/aignostics/cli_test.py, line 210-227
# Change second `if` to `elif`

What's Good

1. Security Updates (Excellent)

The PR correctly moves transitive security overrides from override-dependencies to direct dependencies:

Moved to main dependencies (✅ Correct - uvx respects these):

"h11>=0.16.0",          # CVE-2025-43859
"tornado>=6.5.0",       # CVE-2025-47287
"urllib3>=2.5.0",       # CVE-2025-50181, CVE-2025-50182
"pillow>=11.3.0",       # CVE-2025-48379
"aiohttp>=3.12.14",     # CVE-2025-53643
"starlette>=0.47.2",    # CVE-2025-54121
"starlette>=0.49.1",    # GHSA-7f5h-v6xp-fcq8
"lxml>=6.0.2",          # For Python 3.14 pre-built wheels

Kept in dev dependencies (✅ Correct - dev-only):

"pip>=5.3",             # CVE-2025-8869
"uv>=0.9.7",            # CVE-2025-54368
"fonttools>=4.60.2",    # CVE-2025-66034

Moved to optional dependencies (✅ Correct - jupyter extra):

"jupyter-core>=5.8.1",  # CVE-2025-30167
"jupyterlab>=4.4.9",    # CVE-2025-59842

2. Python 3.14 Compatibility (Good)

  • highdicom>=0.26.1,<1; python_version < '3.14' - Conditional dependency
  • ✅ Added @SKIP_HIGHDICOM_PYTHON_314 decorator to 7 tests
  • ✅ Runtime check in wsi/_cli.py with helpful error message
  • ✅ GUI native mode disabled on Windows Python 3.14+ (pythonnet issue)

3. Lint & Test Markers (Perfect)

  • ✅ All lint checks pass (ruff, mypy, pyright)
  • All tests have proper markers (unit, integration, or e2e)
    • Verified: 0 tests collected (647 deselected) when checking unmarked tests
  • ✅ No type checking errors

4. Architecture Compliance (Good)

  • ✅ Changes follow modulith principles
  • ✅ No circular dependencies introduced
  • ✅ Proper separation of concerns (CLI detects highdicom availability)

⚠️ Suggestions for Improvement

1. Commit Message Format (Minor)

One commit doesn't follow conventional commit spec:

Current:

sec(deps): don't use override-dependencies as this is not respected by uvx

Issue: Type sec is not in the conventional commit spec. Should be:

  • fix(deps): or chore(deps): for security fixes
  • Or use security(deps): if your repo extends the spec

Other commits are correct:

  • chore: Don't depend on highdicom...
  • test(core): adapt test
  • chore(windows): native mode not supported...

2. PR Description Missing

The PR has no description explaining:

  • Why these changes were made
  • What CVEs are being fixed
  • Impact of Python 3.14 compatibility changes
  • Testing approach

Suggested description template:

## Summary
Move transitive security dependency overrides from `override-dependencies` to direct dependencies to ensure they're respected by `uvx`.

## Security Fixes
- CVE-2025-43859 (h11)
- CVE-2025-47287 (tornado)
- CVE-2025-50181, CVE-2025-50182 (urllib3)
- CVE-2025-48379 (pillow)
- CVE-2025-53643 (aiohttp)
- CVE-2025-54121 (starlette)
- GHSA-7f5h-v6xp-fcq8 (starlette)

## Python 3.14 Compatibility
- Disable highdicom on Python 3.14+ (transitive dependency pyjpegls not yet supporting 3.14)
- Disable GUI native mode on Windows Python 3.14+ (pythonnet not yet supported)
- Add runtime checks with helpful error messages

## Testing
- All lint checks pass
- All test markers properly applied
- Added `@SKIP_HIGHDICOM_PYTHON_314` to 7 tests

3. Documentation Update (Optional)

Consider updating CLAUDE.md or module docs to mention:

  • Python 3.14 limitations (highdicom unavailable)
  • Workaround: uvx -p 3.13 aignostics wsi dicom <command>

📋 Action Items

Must Fix (Blocking)

  1. Fix test logic bug in tests/aignostics/cli_test.py:216
    • Change second if to elif
    • Verify fix: uv run pytest tests/aignostics/cli_test.py::test_cli_gui_run -v

Should Fix (Recommended)

  1. Add PR description explaining changes
  2. Fix commit message: sec(deps)fix(deps) or chore(deps)

Nice to Have (Optional)

  1. Document Python 3.14 limitations in CLAUDE.md

🔍 Verification Commands

# Fix the test and verify
uv run pytest tests/aignostics/cli_test.py::test_cli_gui_run -v --tb=short

# Verify all tests still pass
make test_unit
make test_integration

# Verify lint still passes
make lint

# Test on different platforms (if available)
# Windows Python 3.14+: Should use native=False
# macOS: Should use native=True
# Linux: Should use native=False

Approval Status

Status: ⚠️ Approve with required fix

Once the test logic bug is fixed (change if to elif on line 216), this PR is ready to merge.

Why This Matters: Medical device software requires highest reliability. A flaky test undermines confidence in the test suite and could mask real issues.


@helmut-hoffer-von-ankershoffen helmut-hoffer-von-ankershoffen merged commit 66688c6 into main Dec 10, 2025
20 checks passed
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
46.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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

Successfully merging this pull request may close these issues.

1 participant