Optional homoglyph / confusable-domain detection (opt-in) - #68
Merged
Conversation
withDetectConfusableDomain(true) flags mixed-script "look-alike" domains (e.g. "аpple.com" with a Cyrillic а) via the intl Spoofchecker. This is a security-policy signal, not RFC validity: the address stays valid and the result carries a new ParsedEmailAddress::$domainIsSuspicious field (domain_is_suspicious in the array API). Off by default; single-script international domains (почта.рф, münchen.de) are not flagged. The Spoofchecker is created lazily and reused across a batch, and guarded by class_exists so the build degrades gracefully without intl. 108 tests; PHPStan level 8 / Psalm / cs clean.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #68 +/- ##
============================================
+ Coverage 95.59% 96.01% +0.42%
- Complexity 428 434 +6
============================================
Files 6 6
Lines 1066 1078 +12
============================================
+ Hits 1019 1035 +16
+ Misses 47 43 -4
🚀 New features to boost your workflow:
|
… the target-list follow-up)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds opt-in homoglyph / confusable-domain detection for the 3.8.0 minor.
What
ParseOptions::withDetectConfusableDomain(true)flags mixed-script "look-alike" domains — e.g.аpple.comwhere theаis Cyrillic (U+0430), the classic IDN homograph attack — via theintlSpoofchecker.ParsedEmailAddress::$domainIsSuspicious(anddomain_is_suspiciousin the array API).почта.рф,münchen.de, and CJK are not flagged — only mixed-script confusables are.class_existsso the build degrades gracefully withoutintl.Out of scope
Confusable-against-a-target-list matching ("looks like
paypal.com") — that needs a caller-supplied brand/skeleton set, so it's not part of this self-contained check.Verification
108 tests (new
testConfusableDomainDetectioncovers homograph-flagged-but-valid, opt-in gating, and the legit-domain non-false-positives); PHPStan level 8 / Psalm / CS Fixer clean. The array-shape tests use the existing opt-in key pattern (likeobs_route), so no existing consumer sees a shape change.