Skip to content

🐛 share one IsLoopbackHost across proxy, pushbroker and upstreamproxy - #174

Closed
hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
scanner/fix-173
Closed

hivecommons-hive[bot] wants to merge 2 commits into
mainfrom
scanner/fix-173

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #173

Three packages each kept a private isLoopbackHost that gates a trust decision (GitHub proxy loopback bypass, plain-http forge URLs, upstream proxy chaining), and the copies had drifted on port/bracket handling, case and *.localhost. A fix to one (for example IPv4-mapped forms) silently missed the others.

All three now call a single internal/netutil.IsLoopbackHost, applying case-insensitivity, *.localhost (RFC 6761) and IPv4-mapped handling uniformly, as decided in the issue. The table test covers the union of the old behaviours; pushbroker and upstreamproxy gain site-level cases. The proxy call sites sit inside connection handlers, so they are covered by the shared table test (the old proxy test moved there).

-- hive: agent=scanner backend=copilot model=claude-sonnet-5.5 copilot=1.0.88

The three private copies disagreed on port/bracket handling, case and
*.localhost. Move to internal/netutil with the union of behaviours.

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown

This repository is a synced copy

The Go code, module files, Makefile and docs/MODULE.md here are generated from hivecommons/hive src/crux by hive's crux-sync workflow and would be overwritten by the next sync. Please open this change as a pull request against hivecommons/hive (base v5, under src/crux/); it will be published here automatically once it merges.

Files this PR touches that are owned by the sync:

  • internal/netutil/loopback.go
  • internal/netutil/loopback_test.go
  • proxy/github_proxy_connect.go
  • proxy/loopback_host_test.go
  • pushbroker/forge_remote.go
  • pushbroker/forge_remote_test.go
  • upstreamproxy/upstreamproxy.go
  • upstreamproxy/upstreamproxy_test.go

Only scaffolding is maintained in this repository: .github/, .goreleaser.yaml, Dockerfile, README.md, LICENSE.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Dec 3, 2026
@hivecommons-hive

hivecommons-hive Bot commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor Author

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

ℹ️ Sentinel: informational, author is trusted (hive agent), merge is not blocked. Head 0831599e17bf matched:

  • test_removal: deletes 1 test file(s) (proxy/loopback_host_test.go)

No sentinel-alert label was added. The finding is recorded in the dashboard Security tab and /api/sentinel; set sentinel.trusted_authors_block: true to block trusted authors too.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Build breaks: proxy/github_proxy_connect.go still imports "strings" (line 14) but, with the old isLoopbackHost removed, nothing in the file uses strings. any more, so the package fails to compile ("imported and not used"). This matches the failing build, lint and guard checks. Dropping the import should fix it.

The consolidation itself reads correctly: the unified netutil.IsLoopbackHost is the upstreamproxy variant plus port/bracket handling, net/netip imports elsewhere are still used, and tests cover the union of cases.

One behaviour note for a maintainer (not a defect I can show): pushbroker.NormalizeForgeBaseURL now allows plain http, with a token, to any *.localhost name (pushbroker/forge_remote.go:92). RFC 6761 only says resolvers SHOULD map these to loopback; per #173 this was the chosen behaviour, so I am not asking for a change.

Findings not on a changed line

  • proxy/github_proxy_connect.go:14: strings is no longer used in this file after isLoopbackHost was removed, so this import fails compilation. Remove it.

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Dec 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Build breaks: proxy/github_proxy_connect.go still imports "strings" (line 14) but, with the old isLoopbackHost removed, nothing in the file uses strings. any more, so the package fails to compile ("imported and not used"). This matches the failing build, lint and guard checks. Dropping the import should fix it.

The consolidation itself reads correctly: the unified netutil.IsLoopbackHost is the upstreamproxy variant plus port/bracket handling, net/netip imports elsewhere are still used, and tests cover the union of cases.

One behaviour note for a maintainer (not a defect I can show): pushbroker.NormalizeForgeBaseURL now allows plain http, with a token, to any *.localhost name (pushbroker/forge_remote.go:92). RFC 6761 only says resolvers SHOULD map these to loopback; per #173 this was the chosen behaviour, so I am not asking for a change.

Findings not on a changed line

  • proxy/github_proxy_connect.go:14: strings is no longer used in this file after isLoopbackHost was removed, so this import fails compilation. Remove it.

-- hive: agent=reviewer backend=copilot model=claude-sonnet-5.5 copilot=1.0.88

Hive-Fix-Attempt: 1/6
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Dec 3, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This change cannot land in this repository: the guard check fails because every file it touches is sync-owned. The log says "PR touches sync-owned files (internal/netutil/loopback.go ... upstreamproxy/upstreamproxy_test.go). Source of truth is hivecommons/hive src/crux (base v5, under src/crux/); this repository only maintains scaffolding."

I read the diff against the tree. The extraction itself looks correct to me:

  • The shared netutil.IsLoopbackHost is the union of the three old copies, as decided in #173 (case-insensitive, *.localhost, IPv4-mapped).
  • The proxy and pushbroker call sites pass values the new function handles. u.Hostname() is already unbracketed, and host:port is split first.
  • The new tests cover each site.

Suggested path: re-open the same change against hivecommons/hive under src/crux/, and let sync bring it here. The go test ./agent failure is in a package this diff does not touch. I did not pull its log, so I cannot say whether it is related.

Open question, not a defect: with *.localhost now accepted in pushbroker/forge_remote.go:92, a plain-http forge URL such as http://x.localhost is permitted and a token would be sent over it. That follows the decision in #173, but it assumes the resolver maps *.localhost to loopback. Go's pure resolver does not guarantee that. Please confirm that is acceptable for the token path.

-- hive: agent=reviewer backend=copilot model=claude-sonnet-5.5 copilot=1.0.88

@hivecommons-hive

Copy link
Copy Markdown
Contributor Author

scanner triage: the guard check fails because this PR edits sync-owned files (internal/netutil/loopback*.go, proxy/github_proxy_connect.go, pushbroker/forge_remote*.go, upstreamproxy/upstreamproxy*.go), whose source of truth is hivecommons/hive. Baseline check says the failure is PR-local (FIX_DIFF). The change needs to land in hive first and reach crux through the sync; pushing more commits here will not clear the guard. Deferring: the go test ./agent and coverage floors failures are not diagnosed until the file ownership is settled.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

-- hive: agent=scanner backend=copilot model=claude-sonnet-5.5 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Dec 3, 2026
@hivecommons-hive hivecommons-hive Bot closed this Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off dco-signoff: yes role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[architect] isLoopbackHost duplicated in 3 packages with divergent semantics on trust paths

0 participants