Skip to content

Fix/code scanning alerts - #471

Merged
vinitkumar merged 9 commits into
masterfrom
fix/code-scanning-alerts
Oct 26, 2026
Merged

vinitkumar merged 9 commits into
masterfrom
fix/code-scanning-alerts

Conversation

@vinitkumar

@vinitkumar vinitkumar commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Summary by Sourcery

Clean up test fixtures and coverage tests to resolve CodeQL findings while preserving the existing XML conversion behavior.

Enhancements:

  • Align test fixtures and imports with CodeQL expectations so static-analysis findings remain actionable.
  • Document the test-fixture conventions and the unique-ID delegation contract.

Documentation:

  • Document that unique-ID tests must exercise the production make_id delegation and that fixtures should avoid ambiguous import and equality patterns.

Tests:

  • Update XML conversion tests to verify direct delegation to the production unique-ID helper and use consistent module-qualified references.
  • Make custom numeric test fixtures provide matching equality and hashing behavior.

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.
@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Reviewer's Guide

This 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

Change Details Files
Standardize test-module references to avoid CodeQL import and type-resolution findings.
  • Reuse the existing module import when monkeypatching dicttoxml functions.
  • Access private Rust bindings and helpers through the imported module instead of repeated direct imports.
  • Update type annotations and binding comparisons to reference module-qualified symbols.
tests/test_dict2xml.py
tests/test_dicttoxml_fast_fallback.py
tests/test_rust_dicttoxml.py
Make custom numeric test fixtures satisfy equality and hashing expectations.
  • Add equality implementations to custom numeric fixtures while retaining compatible hashes.
tests/test_dicttoxml_unit.py
tests/test_missing_coverage.py
Document the CodeQL-oriented test-fixture conventions and existing CI security assumptions.
  • Document one import form per test module and the equality requirement for custom hashed fixtures.
  • Retain the architecture guidance covering immutable action pins, scoped workflow permissions, and consistent CodeQL action versions.
lat.md/architecture.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T06:43:02.861362Z 519ae6c PR opened
🔒 Security Review ✅ Completed 2026-10-26T06:45:04.544277Z 519ae6c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (da28b18) to head (2c8c9c1).
⚠️ Report is 12 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master      #471   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            7         7           
  Lines         1032      1032           
=========================================
  Hits          1032      1032           
Flag Coverage Δ
unittests 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tests/test_dict2xml.py Outdated
Comment thread lat.md/architecture.md
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.
@vinitkumar
vinitkumar merged commit 61ae159 into master Oct 26, 2026
54 checks passed
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