Repository navigation
Conversation
… checks JSON read from project archives was passed to `load_metadata_base`, which opens the argument as a file if such path exists (SonarCloud S6096). Add `load_metadata_from_string` that only parses JSON and use it for all archive members. Remove compatibility branches for versions below the current minimum requirements (napari<0.5, pydantic<2, tifffile<=2019.7.26).
Reviewer's GuideAPIAdd a metadata loader that parses JSON content without interpreting it as a filesystem path, and document how it differs from the path-capable loader.
Uses of the APIUse the content-only loader for metadata and history read from project archives, preventing archive contents from being treated as paths.
Update the development archive-processing example to parse metadata bytes with the safe loader.
ImplementationRemove obsolete napari and pydantic compatibility branches and consolidate algorithm-property conversion around the supported pydantic API.
UIDrop outdated napari theme and camera-access fallbacks, the scale-bar compatibility warning, and obsolete warning filters.
Remove the launcher check that rejected old napari versions when paired with pydantic 2.
TestsAdd regression coverage that serialized JSON is parsed as content rather than opened as a path.
Remove test setup for the deleted scale-bar warning state while retaining toggle behavior checks.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 54 minutes. View limit details
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="package/PartSegCore/io_utils.py" line_range="179" />
<code_context>
return False
+def load_metadata_from_string(data: str | bytes):
+ """
+ Load metadata from serialized json content.
</code_context>
<issue_to_address>
**Archive utility still reads local files**
When a crafted archive’s `metadata.json` content is the path of an existing JSON file, `load_metadata_base` treats the extracted `metadata.json` text as a path when that path exists, so the utility imports local JSON into its output archive instead of parsing the archive member.
Use `load_metadata_from_string` for the extracted member in `examples/dev/update_frame_thick.py`.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: package/PartSegCore/io_utils.py:179
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1509 +/- ##
===========================================
+ Coverage 92.63% 92.76% +0.13%
===========================================
Files 211 211
Lines 33247 33156 -91
===========================================
- Hits 30797 30756 -41
+ Misses 2450 2400 -50 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|



Summary
pythonsecurity:S6096, blocker): JSON read from project archives (metadata.json,history/history.json,algorithm.json) was passed toload_metadata_base, which opens its argument as a file when that path exists. A crafted archive could make PartSeg read an arbitrary local file. Addedload_metadata_from_string(purejson.loadswithpartseg_object_hook) and use it for all archive members inmask/io_functions.pyandanalysis/load_functions.py. Added a regression test._napari_ge_5branches (get_theme(..., as_dict=...), oldqt_viewer.viewcamera access) and theColor/Namespacetheme fallback — fixes DeepSourcePYL-E1123.NAPARI_LE_4_16scale-bar warning and the launcher pydantic/napari compatibility exit.smart_unionconfig,*_pydantic_1helpers, andupdate_forward_refsbranch._xml2dictpatch.Test plan
ruff check/ruff format/ mypy (pre-commit)pytest tests/test_PartSegCore tests/test_PartSegImage tests/test_PartSeg/roi_mask tests/test_PartSeg/roi_analysis tests/test_PartSeg/test_main_windows.py tests/test_PartSeg/test_common_backend.py tests/test_PartSeg/test_napari_widgets.py tests/test_PartSeg/test_launcher.py— 3603 passedSummary by Sourcery
Safely parse metadata embedded in archives and remove obsolete dependency-version compatibility code.
Bug Fixes:
Enhancements:
Tests:
Summary by CodeRabbit