Skip to content

arch(auth): guard authenticated HTTP egress and credential headers - #3823

Merged
Daniel Meppiel (danielmeppiel) merged 26 commits into
mainfrom
danielmeppiel-t1-pr3-authenticated-egress-guard
Nov 18, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 26 commits into
mainfrom
danielmeppiel-t1-pr3-authenticated-egress-guard

Conversation

@danielmeppiel

@danielmeppiel Daniel Meppiel (danielmeppiel) commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Description

TL;DR

Adds the transport-platform-authenticated-egress architecture guard. Raw HTTP egress (requests verbs/sessions, urllib urlopen) and literal Authorization / PRIVATE-TOKEN header keys can now appear only in their owner modules or in a frozen, reasoned inventory that can only shrink. Every remaining credential-bearing call site moves onto the owners #3785 and #3790 introduced, and lint-auth-signals.sh stops carrying stale exemptions.

Note

Wire change: the install-validation GitHub API probe now sends Authorization: token <t> instead of Bearer <t>. It reuses the shared AuthResolver.github_rest_headers builder, and GitHub's REST API accepts both schemes.

Problem (WHY)

The repo rule this enforces: "Every durable decision ... has exactly ONE canonical owner. Every call site routes THROUGH that owner", and a fix is complete only with "A registered static guard in the architecture linter, referenced by the owner's registry record."

Approach (WHAT)

# Change
1 New AST rule transport-platform-authenticated-egress with two guard ids, one per owner record. The registry rejects one guard id on two owners, so -credential-headers goes on credential-origin-scope.
2 Frozen inventories map (path, enclosing qualname) to an exact site count and a reason. A stale entry or a changed count is a violation, so the inventory only shrinks. The header vocabulary is read from http_credentials.CREDENTIAL_HEADER_NAMES (Authorization, PRIVATE-TOKEN, Proxy-Authorization).
3 Credential headers come from AuthResolver.github_rest_headers / bearer_headers (new, next to gitlab_rest_headers) and RegistryAuthContext.headers().
4 Policy fetches, the Artifactory boundary probe and the Azure DevOps file download go through origin_bounded_request with base_url = the request URL, so "never follow a redirect away from the resource" holds exactly. A new owner helper, unfollowed_redirect_request, follows no redirect at all (max_hops=0) and returns any 3xx to the auth-outcome classifier.
5 Folds the #3785 deferred item: drops the dead final-URL HTTPS recheck in marketplace/client.py::_fetch_url_direct, since the owner already refuses downgrades.

Implementation (HOW)

  • scripts/architecture_linter/checks/transport_authenticated_egress.py (new, under the 2100-line cap; transport_auth_platform.py was already at 1984). It tracks import requests as x, from requests import get, from urllib.request import urlopen, requests.Session subclasses, and verb calls on *session receivers. It skips type annotations and matches header keys case-insensitively in dict keys, subscript stores, kwargs and add_header-style calls.
  • Remaining inventory: anonymous or already origin-scoped egress only. That covers the apm auth status probe, self-update, lifecycle SSRF sessions, the Artifactory no-netrc entry fetch, the shared resilient_get retry transport, the raw CDN fetch, the MCP registry, archive download and the version check. It also has two header exemptions: adapters/client/base.py (MCP config written for the harness; owned by the harness track) and version_checker.
  • src/apm_cli/policy/_policy_http.py (new): policy_get is the single HTTP entry for policy fetches. The ADO path sends authorization_headers(git_env) with ambient_credentials=False, so only the chain-selected credential is sent and anonymous attempts never pick up .netrc.
  • install/artifactory_resolver.py: _head_probe routes the boundary HEAD through the owner; a 3xx still counts as "exists".
  • deps/download_strategies.py: resilient_get takes redirect_base instead of allow_redirects. When it is set, each retry attempt is sent through the owner with ambient netrc excluded. The 429/503/connection retry and backoff loop is unchanged. download_ado_file passes its request URL.
  • install/validation.py: _github_api_get uses base_url = origin_root(url), so same-origin repo renames are still followed and any other origin is refused. A refused redirect counts as an inconclusive probe, so the download step makes the final call and --verbose shows the reason.
  • Sibling guards: fix(registry): follow redirects only within the configured registry origin #3785's redirect inventory drops the policy x4, Artifactory and ADO download entries. fix(auth): route every Azure DevOps egress through one auth chain owner #3790's routed-consumer needle for policy/discovery.py becomes headers=authorization_headers(git_env).
  • scripts/lint-auth-signals.sh: Rule A loses its stale exemptions. Rule B defers to the linter and fails if any deferred guard id (auth-outcome-owner, authenticated-egress, -credential-headers, git-child-environment) leaves the owner registry. The CI entrypoint is unchanged.

Diagrams

Where each kind of HTTP call is allowed to live once this lands:

flowchart LR
    A["HTTP call or credential header in src/apm_cli"] --> B{"Owner module?"}
    B -->|"yes"| OK["allowed"]
    B -->|"no"| C{"In frozen inventory?"}
    C -->|"yes, reasoned"| OK
    C -->|"no"| X["violation: route through owner"]
    INV["inventory entry with no matching site"] --> S["violation: stale exemption"]
Loading

Trade-offs

  • Two guard ids, one rule rather than one id on two owners: the registry forbids shared guard ids, and the egress and header facts come from the same AST walk.
  • Qualname-keyed inventory with exact site counts, not line numbers: it survives unrelated edits, and a new call inside an exempt function still changes the count and needs review.
  • resilient_get keeps an egress exemption as the shared retry transport. Only callers that opt in with redirect_base (today the ADO download) send through the owner. Other callers already pass owner-built headers and follow requests defaults; moving them all is a larger change.
  • Validation probe header scheme moves from Bearer to token to share one builder (see the note above).
  • Deferred to follow-ups: routing the remaining credential-bearing resilient_get callers (GitHub contents, generic hosts) through the owner; flagging auth= keywords outside the owners; excluding ambient .netrc from anonymous auth-chain attempts. The last one is deferred because Git itself honors .netrc, so changing only the HTTP probe would make installs fail for users who rely on netrc alone.

Benefits

  1. A new raw requests/urlopen call or literal credential header anywhere in src/apm_cli fails the CI architecture lint.
  2. Credential header formatting lives in 3 builders instead of about a dozen inline f-strings.
  3. Every credential-bearing redirect decision goes through origin_bounded_request: the allow_redirects= inventory shrinks from 7 to 3 entries, and each of those 3 refuses every redirect.
  4. lint-auth-signals.sh drops 3 stale exemptions and a heuristic grep rule.

Issue and approved scope

Refs #3752
Refs #3726

Human scope-approval comments: #3752 (comment) and #3726 (comment)

This PR is the static-guard slice of the 0.36.1 auth track. #3752 was delivered by #3790 and #3726 by #3785; nothing in either issue remains open for this PR.

apm-spec-waiver: ownership consolidation and static guard inside the approved auth and redirect owners; no OpenAPM-observable behaviour change

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass (targeted; see below)
  • Added tests for new functionality (if applicable)

Scenario evidence

# Scenario (user promise) Principle(s) Test(s) proving it Type
1 A new raw HTTP call or credential header outside the owners fails CI Secure by default, Governed by policy tests/unit/scripts/test_architecture_authenticated_egress.py; tests/integration/test_architecture_owner_rule_mutations.py (both guard ids) unit / integration
2 An org policy fetch never follows a redirect away from the policy file, and a sign-in 3xx still reaches the auth chain Secure by default tests/unit/policy/test_policy_http.py::test_sign_in_redirect_is_returned_unfollowed; tests/unit/policy/test_extends_host_pin.py::TestFetchFromUrlRedirectRefusal unit
3 ADO policy sends only the auth-chain-selected credential, and never ambient netrc Secure by default, Vendor-neutral tests/unit/policy/test_policy_http.py::test_ado_policy_sends_only_the_chain_selected_credential, ::test_anonymous_attempt_keeps_ambient_netrc_out unit
4 The Artifactory boundary probe never follows a proxy redirect Secure by default tests/unit/install/test_artifactory_resolver.py::TestRedirectLeakGuard::test_probe_never_follows_a_redirect unit
5 The install validation probe keeps its token on the GitHub API origin Secure by default tests/unit/install/test_validation_transient_probe.py::test_github_api_probe_keeps_its_credential_on_the_api_origin unit
6 An ADO file download that hits a sign-in redirect is classified auth_required and never followed Secure by default, Vendor-neutral tests/unit/deps/test_download_strategies_phase3.py::test_ado_download_sign_in_redirect_is_classified_not_followed unit
Validation output (this branch merged with main 155a2d7, which includes #3790)
$ uvx [email protected] check src/ tests/ scripts/lint_architecture_boundaries.py scripts/architecture_linter/ scripts/windows_native_symlink_probe_entry.py
All checks passed!
$ uvx [email protected] format --check (same paths)
2359 files already formatted
$ .venv/bin/python -m pylint --disable=all --enable=R0801 --min-similarity-lines=10 --fail-on=R0801 src/apm_cli/ scripts/...
Your code has been rated at 10.00/10
$ bash scripts/lint-auth-signals.sh
[*] Rule A: get_bearer_provider boundary (any reference)
[*] Rule B: credential routing deferred to the architecture linter
[+] auth-signal lint clean
$ bash scripts/lint-architecture-boundaries.sh
(exit 0)
$ pytest -p no:xdist <policy, marketplace, validation, artifactory, registry, auth command, guard, runner, related integration files>
4357 passed, 1 xfailed, 66 subtests passed in 61.75s
$ pytest -p no:xdist tests/integration/test_architecture_owner_rule_mutations.py -k 'authenticated-egress or auth-outcome-owner or origin-bounded-redirect or credential-origin-scope or matrix'
17 passed, 667 deselected

No live Azure DevOps org or Artifactory proxy was used; behaviour is pinned by hermetic tests.

How to test

  • bash scripts/lint-architecture-boundaries.sh passes.
  • Add requests.get(u, headers={"Authorization": t}) to any src/apm_cli/utils/*.py function; the lint reports both guard ids. Revert.
  • Delete any entry from _EGRESS_EXEMPTIONS; the lint reports the site. Delete a site instead; the lint reports a stale exemption.
  • pytest -p no:xdist tests/unit/policy/test_policy_http.py tests/unit/scripts/test_architecture_authenticated_egress.py

Spec conformance (OpenAPM v0.1)

  • Spec edit
  • Manifest edit
  • Test edit
  • CONFORMANCE.{md,json} regenerated
  • N/A -- this PR does not change OpenAPM-observable behaviour.

Co-authored-by: Copilot [email protected]

AuthResolver.try_with_fallback is now the single entry for authenticated
host access. A new core/auth_outcome.py owns auth-outcome classification
(401/403, a redirect to the ADO sign-in service, an HTML sign-in page, Git
auth errors) and core/auth_chain.py walks ADO_APM_PAT -> az bearer ->
path-scoped git credential fill, recording an AuthAttemptLog that
diagnostics render.

- Route install validation, clone, ref resolution, install --update
  preflight, ADO file downloads, org policy discovery (ADO, GitHub with
  per-org PAT, GitLab) and marketplace REST/ref paths through the chain.
- Helper credentials keep their username (GitHelperCredential) and are
  sent as Basic username:password, cached per (host, port, path).
- git credential fill sets GCM_INTERACTIVE=0 when stdin is not a TTY or
  CI is set; APM never calls credential approve/reject.
- Azure DevOps requests use only the credential chosen by the auth chain.
- #3753: az token failures show the Azure CLI reason; the exhausted chain
  lists every step in order; "bearer token" is no longer redacted.
- Remove execute_with_bearer_fallback; is_ado_auth_failure_signal and
  is_public_github_auth_failure become thin classifier wrappers.
- Static guard transport-platform-auth-outcome-owner on the
  host-credential-resolution owner record, with a mutation case.

No live Azure DevOps organization was available: behavior follows the
documented contracts and is validated by hermetic tests.

Fixes #3752
Fixes #3758
Fixes #3753

apm-spec-waiver: auth chain owner refactor with no spec surface change

Co-authored-by: Copilot App <[email protected]>
…ject guard

Fold panel follow-ups on #3790: RefResolver converts an exhausted ADO
chain into GitLsRemoteError naming every step (new integration test), and
transport-platform-auth-outcome-owner also rejects shell-string forms of
git credential approve/reject.

Co-authored-by: Copilot App <[email protected]>
…-in redirects

- Legacy *.visualstudio.com remotes query the credential helper with the
  Project/_git/repo path the helper stores.
- Tenant id lookup is single-flight under a lock.
- ADO file downloads and marketplace ADO REST fetches no longer follow
  redirects; a sign-in 3xx reaches the classifier and the chain escalates.

apm-spec-waiver: review folds inside the approved auth owner scope

Co-authored-by: Copilot App <[email protected]>
The cause-chain walk follows __cause__/__context__ only through real
exceptions, and any other error value is read as text.

apm-spec-waiver: hardening inside the approved auth classifier owner

Co-authored-by: Copilot App <[email protected]>
Add transport-platform-authenticated-egress, an AST architecture-linter
rule that keeps HTTP egress primitives (requests verbs and sessions,
urllib urlopen) and literal credential header keys in their owner
modules or in a frozen, reasoned inventory that can only shrink.

The rule carries two guard ids registered on host-credential-resolution
and credential-origin-scope. lint-auth-signals.sh drops stale Rule A
exemptions and Rule B now defers to the architecture linter.

Refs #3752, #3726

Co-authored-by: Copilot App <[email protected]>
…he redirect owner

The ADO items fetch sends only the chain-selected Authorization header,
disables ambient credentials, and refuses the cross-origin sign-in
redirect so the auth chain classifies the 3xx and escalates.

apm-spec-waiver: adapts the approved auth owner to the redirect owner API

Co-authored-by: Copilot App <[email protected]>
…lls; widen resolve fakes

- Add RT1's lock replay (0.35.1 / 0.36.0 locks) and ADO adjacent-egress
  installed-CLI scenarios byte-for-byte.
- Resolver test doubles accept the port/host_type keywords the chain now
  passes.

Co-authored-by: Copilot App <[email protected]>
…n fallback

- Every ADO chain step's git env carries only its own Authorization header,
  suppresses credential helpers, and holds no PAT, bearer, or ambient
  GitHub token from another step (PAT -> bearer -> helper and tokenless).
- A failing AuthResolver never lets the GitHub policy fetch fall back to
  GITHUB_TOKEN, GITHUB_APM_PAT, or GH_TOKEN from the environment.

Co-authored-by: Copilot App <[email protected]>
…uthenticated-egress-guard

# Conflicts:
#	.apm/architecture/owners/transport-auth-platform.json
#	scripts/architecture_linter/groups/transport_platform.py
#	scripts/lint-auth-signals.sh
#	tests/integration/test_architecture_owner_rule_mutations.py
#	tests/unit/scripts/test_architecture_runner.py
Policy fetches (URL, GitHub, Azure DevOps, GitLab), the Artifactory
boundary probe and the install validation GitHub probe now send through
origin_bounded_request. Policy and probe redirects away from the
requested resource stay unfollowed and are reported as before.
Literal credential headers move to AuthResolver.github_rest_headers,
AuthResolver.bearer_headers and RegistryAuthContext.headers.

The authenticated-egress inventory drops every pending entry; the
origin-bounded-redirect inventory drops the policy and Artifactory
entries; lint-auth-signals Rule B also defers auth-outcome-owner.

Refs #3752, #3726

Co-authored-by: Copilot App <[email protected]>
…d_request

The origin-bounded owner sends every hop without automatic redirects and
refuses HTTPS downgrades, so the response URL check in _fetch_url_direct
could never fire. The test now drives a downgrade redirect through the
owner instead of faking a final URL.

Refs #3726

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.36.1 milestone Nov 17, 2026
DownloadDelegate.resilient_get takes redirect_base instead of
allow_redirects; when set, every retry attempt goes through
origin_bounded_request bounded to that base, with ambient netrc
excluded. download_ado_file passes its request URL, so no redirect is
followed and a sign-in 3xx still reaches the auth-outcome classifier.
The 429/503/connection retry and backoff loop is unchanged.

A shared owner helper, unfollowed_redirect_request, returns the
refused 3xx instead of raising; policy fetches and the Artifactory
boundary probe use it too. The download_strategies entry leaves the
origin-bounded-redirect inventory.

apm-spec-waiver: redirect routing inside the approved auth and redirect owners

Refs #3752, #3726

Co-authored-by: Copilot App <[email protected]>
The authenticated-egress owner case now reintroduces urllib.request.urlopen
in the marketplace metadata fetch; direct requests.get egress stays covered
by the rule's unit tests.

Refs #3726

Co-authored-by: Copilot App <[email protected]>
…ted-egress-guard

#3790's squash differs from the previously merged head 74ef67d only in
three test files; those deltas are applied here.

Co-authored-by: Copilot App <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Unresolved issues allow redirects to unintended resources, break policy URLs using HTTP Basic credentials, and let raw session HTTP calls bypass the egress guard.

3 open issues
What changed in this PR

This PR adds static enforcement for APM’s shared authentication and HTTP transport owners, building on #3785 and #3790.

Changes:

  • Adds an AST guard for raw HTTP calls and credential-header construction, with reasoned exemption inventories.
  • Centralizes header builders and routes policy fetches, validation probes, Artifactory probes and ADO downloads through shared HTTP helpers.
  • Updates lint registration, adds regression coverage and retargets existing test mocks.
File Description
tests/​unit/​test_install_command.py Retargets validation mocks.
tests/​unit/​test_audit_policy_command.py Retargets policy-fetch mocks.
tests/​unit/​test_artifactory_support.py Retargets boundary-probe mocks.
tests/​unit/​scripts/​test_architecture_runner.py Registers the new rule in the expected inventory.
tests/​unit/​scripts/​test_architecture_authenticated_egress.py Tests egress/header detection and stale exemptions.
tests/​unit/​policy/​test_policy_serialization_properties.py Retargets policy transport mocks.
tests/​unit/​policy/​test_policy_http.py Tests redirect responses and selected credentials.
tests/​unit/​policy/​test_extends_host_pin.py Exercises redirect refusal through the HTTP owner.
tests/​unit/​policy/​test_discovery.py Updates provider-specific policy mocks.
tests/​unit/​policy/​test_discovery_policy_resolution.py Updates resolution and authenticated-URL mocks.
tests/​unit/​policy/​test_discovery_phase3w4.py Retargets policy discovery mocks.
tests/​unit/​policy/​test_cache_merged_effective.py Updates transport mocks for cache tests.
tests/​unit/​marketplace/​test_marketplace_client.py Tests HTTPS downgrade refusal through the owner.
tests/​unit/​install/​test_validation_transient_probe.py Adds API-origin redirect coverage.
tests/​unit/​install/​test_validation_tls.py Retargets TLS validation mocks.
tests/​unit/​install/​test_validation_rate_limit.py Retargets rate-limit validation mocks.
tests/​unit/​install/​test_validation_proxy.py Retargets proxy-mode validation mocks.
tests/​unit/​install/​test_artifactory_resolver.py Adds owner-level boundary redirect coverage.
tests/​unit/​deps/​test_download_strategies_phase3.py Tests ADO sign-in redirect classification.
tests/​spec_conformance/​test_policy_reqs.py Retargets fail-closed policy transport mocking.
tests/​integration/​test_uninstall_policy_pack_flow.py Updates policy-fetch mocks.
tests/​integration/​test_policy_url_chain_parity.py Updates URL-chain transport mocking.
tests/​integration/​test_policy_coverage.py Retargets transport-failure mocking.
tests/​integration/​test_integrators_validation_rules.py Retargets package-validation mocking.
tests/​integration/​test_ghe_marketplace_install_e2e.py Updates outbound-probe mocks and explanatory comment.
tests/​integration/​test_credential_fill_disambiguation.py Retargets credential-fallback validation mocks.
tests/​integration/​test_artifactory_probe_pipeline_e2e.py Retargets pipeline boundary-probe mocks.
tests/​integration/​test_architecture_owner_rule_mutations.py Adds mutations for both new guard IDs.
tests/​integration/​test_ado_policy_project_coordinate.py Retargets ADO policy transport mocks.
src/​apm_cli/​utils/​http_credentials.py Adds a helper returning refused redirect responses.
src/​apm_cli/​policy/​discovery.py Routes policy requests through the shared helper.
src/​apm_cli/​policy/​_policy_http.py Adds the common policy HTTP entry point.
src/​apm_cli/​policy/​_gitlab.py Uses the shared policy transport.
src/​apm_cli/​marketplace/​client.py Reuses header construction; removes redundant HTTPS checking.
src/​apm_cli/​marketplace/​builder.py Reuses GitHub header construction.
src/​apm_cli/​install/​validation.py Adds origin-bounded GitHub API requests.
src/​apm_cli/​install/​artifactory_resolver.py Routes HEAD probes through the HTTP owner.
src/​apm_cli/​deps/​registry/​client.py Uses registry-owned credential headers.
src/​apm_cli/​deps/​registry/​auth.py Adds a credential-header mapping builder.
src/​apm_cli/​deps/​github_downloader.py Forwards the new redirect-base option.
src/​apm_cli/​deps/​github_downloader_validation.py Reuses GitHub header construction.
src/​apm_cli/​deps/​git_reference_resolver.py Reuses GitHub header construction.
src/​apm_cli/​deps/​download_strategies.py Adds bounded retry transport and shared headers.
src/​apm_cli/​core/​auth.py Adds GitHub and bearer header builders.
src/​apm_cli/​commands/​auth.py Reuses GitHub headers for token checks.
scripts/​lint-auth-signals.sh Removes stale exemptions and verifies deferred guards.
scripts/​architecture_linter/​groups/​transport_platform.py Loads the new egress rule.
scripts/​architecture_linter/​checks/​transport_origin_bounded_redirect.py Removes migrated redirect exemptions.
scripts/​architecture_linter/​checks/​transport_authenticated_egress.py Implements egress and credential-header ownership checks.
scripts/​architecture_linter/​checks/​transport_auth_outcome.py Updates the policy credential-routing check.
.apm/​architecture/​owners/​transport-auth-platform.json Registers both guard IDs on their owners.

Review effort: Balanced

Comment thread src/apm_cli/policy/_policy_http.py Resolved
Comment thread src/apm_cli/utils/http_credentials.py Resolved
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

APM Review Panel: ship_with_followups

Adds an AST guard that limits authenticated HTTP egress and literal credential headers to a small set of owner modules, and moves policy, ADO, Artifactory and validation fetches onto the redirect-safe owner.

panel-mode=lean; personas=python-architect,test-coverage-expert,auth-expert,supply-chain-security-expert,apm-ceo

cc Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

This is the static-guard slice of the 0.36.1 T1 auth track. It turns the redirect and credential-owner work from #3785 and #3790 into a rule the linter enforces. All four panelists agree that token precedence is unchanged and that the migrated policy, ADO, Artifactory and validation fetches keep credentials on their origin. No finding is blocking.

The panel converges on three points. First, auth-expert, supply-chain-security-expert and test-coverage-expert independently found that unfollowed_redirect_request, with the default base_url=url, still follows a redirect that stays on the same origin and the same path or below it, while its docstring promises no follow. The risk is low because credentials stay on that origin and path, but the code and its contract disagree and no test pins either behavior. Second, the resilient_get exemption reason claims more containment than the code delivers, and the qualname-keyed inventory has no per-entry site counts, unlike the sibling redirect inventory. Third, the header vocabulary omits Proxy-Authorization, which the owner's CREDENTIAL_HEADER_NAMES already contains.

Three changes in this PR are user-visible and should be pinned by tests: the validation probe header changes from 'Bearer' to 'token', resilient_get gains a new redirect_base retry branch, and a cross-origin redirect on the GitHub API validation probe now fails validation with only a generic message. They are small and in scope.

Dissent. There is no substantive dissent. The panelists differ only on the remedy for resilient_get: route credential-bearing calls through the owner, or correct the exemption reason and file a follow-up. I side with correcting the reason and pinning site counts in this PR, and moving owner routing to a tracked follow-up, because routing changes retry and transport behavior beyond a static-guard slice.

Aligned with: Secure by default -- credentialed egress and literal credential headers become a linter-enforced owner boundary; two gaps remain (same-path follow in the unfollowed helper, ambient netrc on anonymous chain attempts).; Governed by policy -- policy fetches go through a single policy_get consumer of the owner, and the ADO path sends only the chain-selected credential.; Pragmatic as npm -- no user-visible change except a cross-origin redirect on the validation probe, which needs an actionable diagnostic.

Panel summary

Persona B R N Takeaway
Python Architect 0 3 0 Owner placement is sound: unfollowed_redirect_request lives in http_credentials and policy_get is a thin consumer. Tighten the resilient_get exemption, credential-header vocabulary, and owner registration.
Test Coverage Expert 0 3 0 Guard teeth and cross-origin refusal have regression traps (195 tests run, green). Gaps: the same-path bound of base_url=url, retries on redirect_base, and the probe token header.
Auth Expert 0 3 0 Token precedence and credential selection are unchanged; the ADO header change matches the old behavior and sign-in 3xx still reaches the classifier. Remaining issues are hardening and behavior edges.
Supply Chain Security Expert 0 3 0 Policy/ADO/Artifactory/probe migrations keep credentials on-origin. Fix the resilient_get inventory claim and make unfollowed mode truly unfollowed.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 5 follow-ups

  1. [auth-expert, supply-chain-security-expert, test-coverage-expert] IN THIS PR: make unfollowed_redirect_request truly unfollowed when base_url is not given (for example max_hops=0), and pin it with a real-socket same-origin same-path 302 test plus same-path cases for the ADO download and Artifactory probe. -- Three panelists converge; the fix(registry): follow redirects only within the configured registry origin #3785 inventory retirement and the ADO/Artifactory comments rely on refusing every redirect, and Artifactory existence semantics depend on it.
  2. [test-coverage-expert] IN THIS PR: parametrize the resilient_get 503/connection retry tests over redirect_base, assert the Authorization header the validation probe sends, and add a direct test for github_rest_headers and bearer_headers. -- The redirect_base branch and the Bearer-to-token change have no assertions; a regression would silently break ADO download retries or GitHub validation.
  3. [supply-chain-security-expert, python-architect] IN THIS PR: correct the resilient_get exemption reason and pin a site count per egress inventory key. POST-MERGE: route credential-bearing resilient_get calls through the owner with an origin-root base and ambient credentials off. -- A qualname-keyed exemption with no count would admit future credential-bearing egress inside resilient_get without review.
  4. [supply-chain-security-expert, python-architect] IN THIS PR: derive or pin the guard's credential-header key set to CREDENTIAL_HEADER_NAMES so Proxy-Authorization is covered. POST-MERGE: flag non-None auth= keywords outside the owners. -- The header vocabulary exists in three places and already disagrees.
  5. [auth-expert] IN THIS PR: pass ambient_credentials=False inside try_with_fallback callbacks (validation probe, GitHub and GitLab policy), surface RedirectRefusedError on the validation probe as an inconclusive probe or a verbose reason, and update the owner-record prose for the new helpers and consumers. -- Anonymous chain attempts should not pick up credentials outside AuthResolver precedence, and GHES users behind redirecting gateways need an actionable message.

Recommendation

Fold the in-PR items before the reviewer pass, highest priority first: the unfollowed_redirect_request contract fix and its real-socket test, the missing tests for the new wire behaviors, the resilient_get reason and site counts, the shared header vocabulary, the redirect-refused diagnostic and the owner-record prose. Track routing resilient_get through the owner and auth= keyword detection as post-merge issues. With those folds, this slice is ready for the 0.36.1 auth track.


Full per-persona findings

Python Architect

  • [recommended] The function-wide exemption for resilient_get hides credential-bearing egress that skips the owner, and its stated reason does not match the code. at scripts/architecture_linter/checks/transport_authenticated_egress.py:98
    Same facts as the supply-chain finding 1. The sibling redirect check pins a site count per path; this one does not.
    Suggested: Make the owner the default for credential-bearing resilient_get calls, or at minimum correct the reason and pin a site count per inventory key.
  • [recommended] The credential-header vocabulary now exists in three places and they disagree: the new guard omits Proxy-Authorization. at scripts/architecture_linter/checks/transport_authenticated_egress.py:46
    Split authority applied to linter vocabulary.
    Suggested: Use one shared constant derived from or pinned to CREDENTIAL_HEADER_NAMES; add a proxy-authorization snippet test.
  • [recommended] Guard 2's owner allowlist covers files no owner record selects, and the owner records do not name the new helpers or consumers. at .apm/architecture/owners/transport-auth-platform.json
    deps/registry/auth.py is not selected by any record; the owner prose omits unfollowed_redirect_request, the new consumers, and the header builders.
    Suggested: Update the owner/consumer prose in both records; scope deps/registry/auth.py ownership to RegistryAuthContext.auth_header/headers.

Test Coverage Expert

  • [recommended] unfollowed_redirect_request says 'no redirect is followed at all', but a same-origin same-path redirect is followed; no test pins either behavior. at src/apm_cli/utils/http_credentials.py:349
    Verified on the head: origin_bound_refusal returns None for a different query or a sub-path. All new consumer tests use a cross-origin Location.
    Suggested: Pick a contract and pin it with a real-socket test in tests/unit/utils/test_http_credentials.py plus an Artifactory same-path case.
    Proof (missing at): tests/unit/utils/test_http_credentials.py -- proves: The documented redirect contract for credentialed policy/ADO/Artifactory fetches holds against a real HTTP server. [secure-by-default,governed-by-policy]
  • [recommended] The redirect_base branch of resilient_get has no test for the 503/ConnectionError retry loop. at src/apm_cli/deps/download_strategies.py:130
    All TestResilientGet cases patch requests.get, which this branch never calls; grep for redirect_base in tests/ returns 0 hits.
    Suggested: Parametrize the retry tests over redirect_base, patching CredentialScopedSession.request.
    Proof (missing at): tests/unit/deps/test_download_strategies_phase3.py -- proves: ADO file downloads still retry on a transient 503 or a dropped connection. [devx,secure-by-default]
  • [recommended] The validation GitHub probe's Bearer->token header change has no assertion on the header actually sent; the new header builders have no direct tests. at src/apm_cli/install/validation.py:709
    Updated tests patch _github_api_get but never check headers.
    Suggested: Assert the Authorization header in a validation test; add a parametrized test for github_rest_headers and bearer_headers.
    Proof (missing at): tests/unit/install/test_validation_tls.py -- proves: The validation probe sends the chosen GitHub credential scheme. [secure-by-default,devx]

Auth Expert

  • [recommended] The helper documented as following no redirects still follows redirects that stay on the same path, and sends credentials on them. at src/apm_cli/utils/http_credentials.py:364
    unfollowed_redirect_request defaults base_url=url, and origin_bound_refusal accepts a same-origin target on the same path or below it (any query), for up to MAX_REDIRECT_HOPS. The old allow_redirects=False never followed anything. Credentials stay on the same origin and path, so the risk is low, but the docstring and the ADO/Artifactory comments promise no follow. The Artifactory probe also changes: an in-path 3xx was existence proof, and now the final status decides.
    Suggested: When base_url is None, pass max_hops=0 so any 3xx comes back unfollowed. Add a same-path 302 test for the ADO download and the Artifactory probe.
  • [recommended] Anonymous auth-chain attempts in install validation and in GitHub/GitLab policy fetches can still pick up ambient netrc credentials. at src/apm_cli/policy/_policy_http.py:25
    _github_api_get and policy_get leave ambient_credentials at its default of True. With unauth_first=True, an anonymous attempt can be authenticated from .netrc, a source outside the AuthResolver precedence. Not a regression; the ADO policy path already opts out.
    Suggested: Pass ambient_credentials=False for every request made inside a try_with_fallback callback (_github_api_get, _fetch_github_contents, _authenticated_gitlab_request). Keep netrc only for the plain policy URL fetch. Add a test.
  • [recommended] A cross-origin redirect on the GitHub API validation probe now fails validation with a generic message. at src/apm_cli/install/validation.py:712
    RedirectRefusedError is not recognized by _inconclusive_github_probe_detail, so validation returns False with no hint that a redirect was refused. Refusing it is correct for credential safety, but the diagnostic regresses for GHES gateways that redirect to another host.
    Suggested: Treat RedirectRefusedError as an inconclusive probe, or log its reason through verbose_log. Add a test.

Supply Chain Security Expert

  • [recommended] The resilient_get exemption reason overstates containment: GitHub Contents API and generic-host credential calls still use bare requests.get with ambient netrc and default redirect following. at src/apm_cli/deps/download_strategies.py:179
    With redirect_base None and allow_netrc True, resilient_get calls plain requests.get with token headers; netrc can override the explicit header and redirects are auto-followed. This predates the PR, but the qualname-keyed exemption admits any future credential-bearing caller.
    Suggested: In resilient_get, route credential-bearing headers through the owner with base_url=origin_root(url) and ambient credentials off, or correct the inventory reason and file a follow-up.
  • [recommended] unfollowed_redirect_request with the default base_url=url still follows same-origin redirects to the same path or a sub-path; the docstring says no redirect is followed. at src/apm_cli/utils/http_credentials.py:364
    Same as auth-expert finding 1. The fix(registry): follow redirects only within the configured registry origin #3785 inventory retirement assumed 'refuses every redirect'.
    Suggested: max_hops=0 when base_url is None; add a test.
  • [recommended] Guard blind spots: header keys omit Proxy-Authorization and ignore auth= kwargs, and qualname-keyed exemptions admit additional egress inside an exempted scope. at scripts/architecture_linter/checks/transport_authenticated_egress.py:46
    The owner's CREDENTIAL_HEADER_NAMES includes Proxy-Authorization. The egress inventory has no site counts, unlike the fix(registry): follow redirects only within the configured registry origin #3785 redirect inventory. No current violation found.
    Suggested: Derive the key set from CREDENTIAL_HEADER_NAMES, flag a non-None auth= keyword outside the owners, and pin a site count per exemption.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

- unfollowed_redirect_request now follows no redirect (max_hops=0), so a
  same-path 3xx is returned like any other; pinned with a real-socket
  test plus Artifactory and ADO download retry cases.
- The validation GitHub probe treats a refused redirect as inconclusive
  and leaves the decision to the download step, with a verbose reason.
- The egress guard reads its credential header vocabulary from
  CREDENTIAL_HEADER_NAMES (adds Proxy-Authorization) and pins an exact
  site count per inventory entry; the resilient_get reason now states
  what the code does.
- deps/registry/auth.py header ownership narrows to RegistryAuthContext;
  owner records name the new helpers and consumers.
- Tests assert the probe's token header and the REST header builders.

apm-spec-waiver: review folds inside the approved auth and redirect owners

Refs #3752, #3726

Co-authored-by: Copilot App <[email protected]>
…ess prefilter

- policy_get moves userinfo from a direct policy URL into an explicit Basic
  header through the new http_credentials.split_url_credentials owner
  helper, matching the previous requests behaviour. Redirect targets that
  embed userinfo stay refused. Covered by a transport-level test that only
  mocks the adapter send.
- The egress guard prefilter also matches 'session', so session-receiver
  calls in modules without other HTTP tokens are scanned.
- The no-follow regression test covers query and descendant-path shapes.

apm-spec-waiver: review folds inside the approved auth and redirect owners

Refs #3726

Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator Author

Merge worker: ready for maintainer review

Head ad3282f166: CI green, lint silent, canonical-owner gate verified (7 owners touched, exact-head functional evidence). Merge remains a maintainer decision.

Folded in this run

  • (panel) unfollowed_redirect_request follows no redirect (max_hops=0); real-socket query and descendant-path tests -- resolved in 46f92b4, 1cadbff.
  • (panel) Egress guard reads its header vocabulary from CREDENTIAL_HEADER_NAMES (adds Proxy-Authorization) and pins an exact site count per exemption; resilient_get reason corrected -- resolved in 46f92b4.
  • (panel) Validation probe treats a refused redirect as inconclusive with a verbose reason; tests assert the token header and the REST header builders; redirect_base retry tests -- resolved in 46f92b4.
  • (panel) Owner records name the new helpers and consumers; deps/registry/auth.py header ownership narrowed to RegistryAuthContext -- resolved in 46f92b4.
  • (copilot) Prefilter covers session receivers; direct policy URL credentials preserved as an explicit Basic header -- resolved in 1cadbff.

Copilot signals reviewed

  • scripts/architecture_linter/checks/transport_authenticated_egress.py -- LEGIT: Prefilter skipped session-receiver calls in modules without other HTTP tokens; folded in 1cadbff with an isolated fixture test.
  • src/apm_cli/policy/_policy_http.py -- LEGIT: Direct policy URLs with userinfo were rejected; folded in 1cadbff via http_credentials.split_url_credentials and a transport-level test.
  • src/apm_cli/utils/http_credentials.py -- LEGIT: base_url=url still followed same-path redirects; folded in 46f92b4 (max_hops=0) with query and descendant-path regression cases.

Deferred (out-of-scope follow-ups)

  • (panel) Route remaining credential-bearing resilient_get callers (GitHub contents, generic hosts) through origin_bounded_request with an origin-root base and ambient credentials off. -- scope boundary: Changes download retry/transport behaviour beyond the static-guard slice; exemption reason corrected and site-count pinned instead.; suggested follow-up: Route credential-bearing resilient_get calls through the redirect owner.
  • (panel) Flag non-None auth= keywords on HTTP calls outside the owner modules. -- scope boundary: Extends the guard to a new credential shape with no current violations; separate guard extension.; suggested follow-up: Egress guard: detect auth= keyword credentials.
  • (panel) Exclude ambient netrc from anonymous auth-chain HTTP attempts (validation probe, GitHub/GitLab policy). -- scope boundary: Behaviour change for netrc-only users because Git also honours .netrc; needs a product decision on netrc precedence.; suggested follow-up: Decide netrc precedence for anonymous auth-chain HTTP attempts.

Regression-trap evidence (mutation-break gate)

  • tests/unit/utils/test_http_credentials.py::test_unfollowed_redirect_request_never_follows_a_same_path_redirect -- removed max_hops=0 in unfollowed_redirect_request; test failed as expected; guard restored.
  • tests/unit/install/test_artifactory_resolver.py::TestRedirectLeakGuard::test_same_path_redirect_is_existence_proof_not_followed -- removed max_hops=0 in unfollowed_redirect_request; test failed as expected; guard restored.
  • tests/unit/policy/test_policy_http.py::test_url_credentials_become_an_explicit_basic_header -- removed split_url_credentials call in policy_get; test failed as expected; guard restored.
  • tests/unit/scripts/test_architecture_authenticated_egress.py::test_session_call_is_flagged_in_a_module_without_other_egress_tokens -- removed 'session' in _PREFILTER_EGRESS; test failed as expected; guard restored.
  • tests/unit/install/test_validation_transient_probe.py::test_refused_cross_origin_redirect_defers_to_download -- removed RedirectRefusedError branch in _inconclusive_github_probe_detail; test failed as expected; guard restored.
  • tests/unit/deps/test_download_strategies_phase3.py::test_ado_download_sign_in_redirect_is_classified_not_followed -- removed redirect_base=url in download_ado_file; test failed as expected; guard restored.
  • tests/integration/test_architecture_owner_rule_mutations.py::test_owner_rule_catches_its_guard_mutation[transport-platform-authenticated-egress] -- removed origin_bounded_request replaced by urllib.request.urlopen in marketplace/builder.py (RT1 gap: urlopen vector pinned in the single allowed case per guard id); test failed as expected; guard restored.

Lint contract

ruff check and ruff format --check (ruff 0.15.12, CI paths) silent; pylint R0801 clean; lint-auth-signals.sh and lint-architecture-boundaries.sh exit 0.

CI

gh pr checks 3823 at ad3282f: 27 pass, 3 skipping, 0 failing, 0 pending (CI, Lint, Merge Gate, Spec conformance, CodeQL, NOTICE Drift, CRLF Invariance).


Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors.

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 70554b6 into main Nov 18, 2026
30 checks passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-t1-pr3-authenticated-egress-guard branch November 18, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants