Repository navigation
Fix/code scanning alerts - #471
Conversation
Define equality for the numeric test helper so its custom hash follows Python's equality and hashing contract.
Compare the numeric test double's stored value so equality remains compatible with its required hash implementation.
Reference Rust binding helpers through the imported module so CodeQL no longer sees duplicate import forms.
Bind backend helpers from the module import so CodeQL no longer reports mixed module and symbol imports.
Patch the existing module binding instead of importing dicttoxml a second way inside the test.
Patch the existing dicttoxml module binding instead of mixing module import forms inside the test.
Record the import and equality conventions that keep test-only helpers from creating noisy scanning alerts.
Reviewer's GuideThis PR resolves CodeQL/code-scanning findings primarily by normalizing test imports and module-qualified references, making custom hashed fixtures define matching equality behavior, and documenting the conventions that keep these findings actionable while preserving the existing CI security model. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #471 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 7 7
Lines 1032 1032
=========================================
Hits 1032 1032
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tests/test_dict2xml.py" line_range="1171" />
<code_context>
- monkeypatch.setattr(module, "make_id", mock_make_id)
- monkeypatch.setattr(module, "get_unique_id", patched_get_unique_id)
+ monkeypatch.setattr(dicttoxml, "make_id", mock_make_id)
+ monkeypatch.setattr(dicttoxml, "get_unique_id", patched_get_unique_id)
result = dicttoxml.get_unique_id("test")
</code_context>
<issue_to_address>
**Duplicate ID handling goes untested**
When the production `get_unique_id` implementation is broken for duplicate IDs, `test_get_unique_id_with_duplicates` replaces `dicttoxml.get_unique_id` with `patched_get_unique_id` at line 1171, then calls that replacement at line 1173. The test’s own duplicate loop supplies the expected ID, so a broken production implementation still passes.
Exercise the production function and patch only its `make_id` dependency.
</issue_to_address>
### Comment 2
<location path="lat.md/architecture.md" line_range="109" />
<code_context>
+Test fixtures keep one import form per module and avoid custom hashes without matching equality so CodeQL findings stay actionable.
</code_context>
<issue_to_address>
**Mixed import alert remains**
When codeQL checks mixed import forms in `tests/test_dict2xml.py`, `tests/test_dict2xml.py` still combines `from json2xml import dicttoxml` at line 8 with local `from json2xml.dicttoxml import ...` imports at lines 349 and 1521, so the mixed-import finding remains and the documented cleanup is incomplete.
Reuse the existing `dicttoxml` module binding for those remaining imports, or otherwise use one import form consistently in that test module.
</issue_to_address>Patch only make_id so the test calls get_unique_id itself and can fail when its production delegation changes.
Route the remaining helper calls through the existing module binding so CodeQL sees one import form in the test module.
Summary by Sourcery
Clean up test fixtures and coverage tests to resolve CodeQL findings while preserving the existing XML conversion behavior.
Enhancements:
Documentation:
make_iddelegation and that fixtures should avoid ambiguous import and equality patterns.Tests: