GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(sanic): Add `sentry.is_localhost` for inbound filters by sentrivana · Pull Request #7783 · getsentry/sentry-python

Conversation

@sentrivana

@sentrivana sentrivana commented Sep 30, 2026

Copy link
Copy Markdown
Collaborator

Mirrors https://github.com/getsentry/relay/blob/master/relay-filter/src/localhost.rs

Part 3 of #7727

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentrivana
sentrivana force-pushed the ivana/is-localhost-3-sanic branch from 6a48aa5 to 316a463 Compare September 30, 2026 08:31
@sentrivana sentrivana changed the title Ivana/is localhost 3 sanic feat(sanic): Add sentry.is_localhost for inbound filters Sep 30, 2026
@sentrivana
sentrivana added this pull request to stack #7782 September 30, 2026 08:33
@sentrivana
sentrivana marked this pull request as ready for review September 30, 2026 08:37
@sentrivana
sentrivana requested a review from a team as a code owner September 30, 2026 08:37
@github-actions

github-actions Bot commented Sep 30, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Codecov Results 📊

✅ 130355 passed | ⏭️ 7185 skipped | Total: 137540 | Pass Rate: 94.78% | Execution Time: 438m 12s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +78
Passed Tests 📈 +62
Failed Tests —
Skipped Tests 📈 +16

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2554 uncovered lines.
✅ Project coverage is 90.26%. Comparing base (4e6beb8) to head (96286e3).

Coverage diff
@@            Coverage Diff             @@
##        master       #PR       +/-##
==========================================
+ Coverage    90.26%    90.26%        —%
==========================================
  Files          195       195         —
  Lines        26225     26226        +1
  Branches      9776      9776         —
==========================================
+ Hits         23672     23672         —
- Misses        2553      2554        +1
- Partials      1483      1484        +1

Generated by Codecov Action

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@sentrivana
sentrivana force-pushed the ivana/is-localhost-3-sanic branch from 316a463 to 3d65d79 Compare September 30, 2026 08:49
alexander-alderman-webb
alexander-alderman-webb approved these changes Sep 30, 2026
View reviewed changes
sentry-warden[bot]
sentry-warden Bot reviewed Sep 30, 2026
View reviewed changes
Comment thread sentry_sdk/integrations/sanic.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@sentrivana
sentrivana force-pushed the ivana/is-localhost-3-sanic branch 5 times, most recently from b6a44e8 to eac5409 Compare September 30, 2026 09:31
Base automatically changed from ivana/is-localhost-2-asgi to master September 30, 2026 09:39
@sentrivana
sentrivana force-pushed the ivana/is-localhost-3-sanic branch from eac5409 to bfc7e34 Compare September 30, 2026 09:40
sentrivana added 2 commits September 30, 2026 11:47
@sentrivana
feat(sanic): Add sentry.is_localhost for inbound filters
9fc74a4
@sentrivana
fix
96286e3
sentry-warden[bot]
sentry-warden Bot reviewed Sep 30, 2026
View reviewed changes
Comment thread sentry_sdk/integrations/sanic.py
from sentry_sdk.utils import (
CONTEXTVARS_ERROR_MESSAGE,
HAS_REAL_CONTEXTVARS,
_is_localhost,

@sentry-warden sentry-warden Bot Sep 30, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

IPv6 localhost hosts are not recognized by the localhost helper

When the client IP is absent or non-loopback, _is_localhost() can miss requests whose URL or host header identifies IPv6 loopback. url_host="::1" does not match _LOCAL_DOMAINS, and splitting a header such as [::1]:8000 at the first colon produces [ rather than a hostname. Add IPv6 loopback to the host checks and parse header authorities in a way that handles bracketed IPv6 addresses.

Evidence
  • _is_localhost() checks the client IP first, then checks url_host against _LOCAL_DOMAINS, which contains localhost and 127.0.0.1 but not ::1.
  • For host headers, the split(":")[0] operation turns [::1]:8000 into [, so it cannot match a local domain.
  • The ASGI, WSGI, and Sanic integrations pass URL hosts and host headers to this helper; existing helper tests cover IPv6 client IPs but not IPv6 URL or header hosts.
  • The Sanic test explicitly expects a localhost host header to identify localhost even with a non-local forwarded client IP, so the host-only case is reachable.

Identified by Warden · find-bugs · 9XF-TTE

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sentry-warden sentry-warden Bot Sep 30, 2026

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Fix attempt detected (commit 96286e3)

The change adds bracket stripping for IPv6 client IPs, but _is_localhost() still does not recognize ::1 as a URL host and still splits bracketed IPv6 host headers at the first colon, so the reported host-only cases persist.

The original issue appears unresolved. Please review and try again.

Evaluated by Warden

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@sentrivana sentrivana Sep 30, 2026

Copy link
Copy Markdown
Collaborator Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

#7786

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@sentrivana
sentrivana force-pushed the ivana/is-localhost-3-sanic branch from bfc7e34 to 96286e3 Compare September 30, 2026 09:47
@sentrivana sentrivana mentioned this pull request Sep 30, 2026
feat: Better IPv6 localhost detection #7786
Merged
@sentrivana
sentrivana merged commit e1f5e70 into master Sep 30, 2026
314 of 316 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@sentrivana
sentrivana deleted the ivana/is-localhost-3-sanic branch September 30, 2026 10:09
sentrivana added a commit that referenced this pull request Sep 30, 2026
@sentrivana
feat: Better IPv6 localhost detection (#7786)
bd05d43
#7783 (comment)
@sentry-release-bot sentry-release-bot Bot mentioned this pull request Oct 12, 2026
publish: getsentry/[email protected] getsentry/publish#9830
Closed
6 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@sentry-warden sentry-warden[bot] sentry-warden[bot] left review comments
@alexander-alderman-webb alexander-alderman-webb alexander-alderman-webb approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@sentrivana @alexander-alderman-webb
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.