Repository navigation
Drop the Owner Half of the Dot-Segment Guard, Which the URL Grammar Already Refuses - #1515
Conversation
…lready Refuses Copilot raised both of these as suppressed low-confidence findings on the #1513 promotion pull request, and both hold. The owner half of the guard is unreachable. GITHUB_URL_RE's owner group is `[A-Za-z0-9-]+`, which cannot match a dot at all, so `owner.strip(".")` is never empty and the branch says an owner can be a dot segment when the grammar two lines above already settles that it cannot. The comment's example was misattributed for the same reason. `https://github.com/../rate_limit` no longer reaches the guard, it is refused by the owner class, so citing it as a url that "passed the gate" next to the guard credited the wrong half of the fix. The comment now names each position with the evidence that belongs to it, and the two differ. The owner position is where the traversal actually resolved: `repos/../rate_limit` returns 200 with the rate-limit document and `repos/../..` returns the API root. The repo position is refused for a narrower reason, measured while answering this: `repos/ptr727/../rate_limit` returns 404 rather than a different document, so the claim is not that it traverses but that the normalization eats a segment either way, which leaves what a read addresses decided by the shape of that read rather than by the declaration. The test corpus keeps both positions rather than trusting whichever half holds, since they are now refused by different halves. Dropping the remaining guard fails three of its cases.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Approval recommended
It removes dead code that cannot be reached given the current URL grammar and updates comments/tests to match the verified behavior without changing the effective validation outcomes.
Pull request overview
This PR tightens and clarifies the GitHub URL dot-segment handling in github_identity() by removing an unreachable owner-side guard (since the owner regex already forbids dots) and updating the explanatory comments and test corpus to reflect the measured behavior at each path segment position.
Changes:
- Remove the unreachable
owner.strip(".") == ""branch inspec/validate.pyand keep the dot-only guard only for the repo segment. - Rewrite the in-code comment to accurately attribute which half of the grammar refuses which dot-only cases, including the measured API behavior.
- Expand/reorder the dot-only segment test cases to cover both owner-position and repo-position variants explicitly.
File summaries
| File | Description |
|---|---|
| spec/validate.py | Drops the unreachable owner-side dot-only check and updates the rationale comment for the remaining repo-side guard. |
| scripts/tests/test_spec_validate.py | Updates the dot-segment test docstring and extends the URL corpus to cover both dot-only positions. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Copilot raised both of these as suppressed low-confidence findings on the
#1513 promotion pull request, and both hold.
The owner half of the guard is unreachable. GITHUB_URL_RE's owner group is
[A-Za-z0-9-]+, which cannot match a dot at all, soowner.strip(".")is never empty and the branch says an owner can be a dot segment when the
grammar two lines above already settles that it cannot.
The comment's example was misattributed for the same reason.
https://github.com/../rate_limitno longer reaches the guard, it isrefused by the owner class, so citing it as a url that "passed the gate"
next to the guard credited the wrong half of the fix.
The comment now names each position with the evidence that belongs to it,
and the two differ. The owner position is where the traversal actually
resolved:
repos/../rate_limitreturns 200 with the rate-limit documentand
repos/../..returns the API root. The repo position is refused for anarrower reason, measured while answering this:
repos/ptr727/../rate_limitreturns 404 rather than a different document, so the claim is not that it
traverses but that the normalization eats a segment either way, which
leaves what a read addresses decided by the shape of that read rather than
by the declaration.
The test corpus keeps both positions rather than trusting whichever half
holds, since they are now refused by different halves. Dropping the
remaining guard fails three of its cases.
Both were suppressed findings, which open no thread, so this pull request is where they are answered.
🤖 Generated with Claude Code