Skip to content

fix(rules): locate() skips matches inside XML comments - #35

Merged
PopovVA merged 1 commit into
mainfrom
fix/locate-skip-comments
Jul 17, 2026
Merged

fix(rules): locate() skips matches inside XML comments#35
PopovVA merged 1 commit into
mainfrom
fix/locate-skip-comments

Conversation

@PopovVA

@PopovVA PopovVA commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

locate() recovered positions with a plain content.indexOf(needle). If a commented-out copy of a setting appeared earlier in the file (e.g. <!-- android:debuggable="true" --> above the active attribute), the finding pointed at the comment line instead of the active node.

The rule semantics were never affected — they come from the parsed XML DOM, so no false positives or negatives — but the wrong line confuses users and destabilizes baseline fingerprints, which hash the finding's line text.

locate() now walks matches in order and skips any that sit inside an unclosed <!--. One deliberate trade-off: if the only raw-text match lives in a comment (active setting formatted differently), the position is now null rather than wrong.

Tests

SD005 (plist) and SD006 (manifest) get a case where a commented-out copy precedes the active setting; both assert the reported line is the active one. Both fail on the previous implementation (line 2 instead of 3).

Closes #32

@PopovVA
PopovVA merged commit a429cac into main Jul 17, 2026
1 check passed
@PopovVA
PopovVA deleted the fix/locate-skip-comments branch July 17, 2026 19:53
PopovVA added a commit that referenced this pull request Jul 17, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](v0.5.1...v0.6.0)
(2026-07-17)


### Features

* **sd001:** detect secrets in map entries, parameter defaults and named
arguments ([#36](#36))
([6658f0a](6658f0a)),
closes [#33](#33)


### Bug Fixes

* **rules:** locate() skips matches inside XML comments
([#35](#35))
([a429cac](a429cac)),
closes [#32](#32)


### Performance Improvements

* **engine:** skip ignored directories before descending into them
([#34](#34))
([2911ae9](2911ae9)),
closes [#31](#31)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

Bug: Fragile XML line locating strategy matching commented-out content

1 participant