fix(zip): fail closed on MAR handler parse errors#896
fix(zip): fail closed on MAR handler parse errors#896mldangelo-oai wants to merge 3 commits intomainfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughUpdates ZIP scanner behavior to propagate a failed Python static analysis from nested Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/scanners/test_zip_scanner.py`:
- Around line 343-354: The test currently verifies the warning details for a
malformed TorchServe handler but doesn't assert the overall scan failed; update
the assertions in test_zip_scanner.py around the block using result =
self.scanner.scan(str(mar_path)) to include an explicit failure contract by
asserting result.success is False immediately after the scan call (before
checking individual checks), ensuring the fail-closed behavior for parse errors
is enforced.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: f9358464-bf9e-49dd-858f-3951c0ed57b5
📒 Files selected for processing (1)
tests/scanners/test_zip_scanner.py
Performance BenchmarksCompared
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/scanners/test_zip_scanner.py`:
- Around line 343-345: Add an explicit assertion that the scan failed closed by
checking result.has_errors is True alongside the existing success check: after
calling self.scanner.scan(str(mar_path)) and the existing assert result.success
is False, add assert result.has_errors is True to make the operational failure
signal explicit (referencing the scanner.scan call and the result object).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 017042c8-e3b8-44c6-923a-84e7dd6c45e0
📒 Files selected for processing (2)
modelaudit/scanners/zip_scanner.pytests/scanners/test_zip_scanner.py
Summary
.marhandler static analysis parse-error pathTorchServe Handler Static Analysiswarning check with entry contextValidation
UV_CACHE_DIR=/tmp/uv-cache uv run pytest tests/scanners/test_zip_scanner.py -k malformed_python_handler --maxfail=1UV_CACHE_DIR=/tmp/uv-cache uv run ruff check modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/UV_CACHE_DIR=/tmp/uv-cache uv run ruff format --check modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/UV_CACHE_DIR=/tmp/uv-cache uv run mypy modelaudit/ packages/modelaudit-picklescan/src packages/modelaudit-picklescan/tests tests/UV_CACHE_DIR=/tmp/uv-cache uv run pytest -n auto -m "not slow and not integration" --maxfail=1Summary by CodeRabbit