Fix reversed str_ends_with in localhost detection - #102
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #102 +/- ##
=========================================
Coverage 81.48% 81.48%
Complexity 343 343
=========================================
Files 33 33
Lines 994 994
=========================================
Hits 810 810
Misses 184 184 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
WildcardRelyingPartydetermines whether an rpId is local (and therefore exempt from thehttpsrequirement) with:The arguments are transposed. This asks whether the literal string
.localhostends with$rpId, not whether$rpIdis a.localhostsubdomain.Two consequences:
.localhostsubdomains are not recognized as local.new WildcardRelyingParty('app.localhost')getsisLocal = false, somatchesOrigin('http://app.localhost:3000')returnsfalse. This is the case the match arm exists to support.A narrow set of rpIds are wrongly treated as local. The only values that satisfy the reversed check are suffixes of
.localhost:t,st,ost,host,lhost,alhost,calhost,ocalhost,localhost,.localhost. An RP configured with rpIdhostgetsisLocal = trueand accepts plaintexthttp://origins.The fix restores the intended direction, using named arguments to match the call already on line 56 of the same file.
Existing coverage passed because every
localhostvector in the data provider uses rpIdlocalhostexactly, which the preceding$rpId === 'localhost'arm already handles — the reversed arm was never exercised for its intended purpose. Three vectors are added: two.localhostsubdomain rpIds, andhostas a guard against the suffix behavior.🤖 Generated with Claude Code