Repository navigation
feat(auth): report helper credential outcomes back to Git - #3818
Daniel Meppiel (danielmeppiel) merged 8 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
APM Review Panel:
|
| Persona | B | R | N | Takeaway |
|---|---|---|---|---|
| Auth Expert | 1 | 2 | 0 | Chain correctly limits reports to helper credentials; a bare 401 text match could misclassify a not-found error (folded). |
| Supply Chain Security Expert | 0 | 3 | 0 | One owner, description replay, no non-helper credentials. Gaps: approve on returned non-2xx and per-path reject (folded). |
| Test Coverage Expert | 0 | 3 | 0 | Every Done-when clause has a trap; e2e approve/reject ran green. Gaps: useHttpPath=false, host:port, concurrency (folded). |
B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.
Top 3 follow-ups
- [Auth Expert] Run a delta review of the fold commits, focused on the 401 wording rules and the same-secret skip guard. -- These folds address the only blocking finding and add a guard on the erase path; they were checked by the author, not by the panel.
- [Auth Expert] Open an issue to decide whether the GitHub/GitLab/generic
fillpaths should report outcomes through the same owner. -- Today only the ADO chain reports; coverage should be extended or explicitly scoped out. - [Test Coverage Expert] Extend the real-binary lifecycle scenario to cover a not-found error with
401inside the URL and an approve-then-401 on another path for the same secret (no erase in both). -- The folds are proven at unit level; an end-to-end trap would catch a regression on this secure-by-default surface.
Recommendation
Ship once the owner PR #3790 lands, since this PR is stacked on it. The blocking finding and every convergent recommendation are folded, and the two declines are reasoned and conservative. Track the auth-expert delta pass on the 401 wording rules and the same-secret guard first.
Full per-persona findings
Auth Expert
- [blocking] Verified-rejection text rule matched a bare 401 anywhere in Git output, including repository URLs, so a not-found error could be treated as a verified rejection. at
src/apm_cli/core/auth_outcome.py
Before this PR such a misclassification only escalated the chain; with reporting it would become destructive, contrary to D3.
Suggested: Verify only from parsed statuses, status-anchored wording, or Git's 401 phrases; never with a 404/not-found signal; add regression cases. Folded. - [recommended] The once-per-process ledger is keyed on (host, port, path) and action, not on the credential. at
src/apm_cli/core/auth_chain.py
A refreshed credential after a reject may not be approved or rejected again in the same process.
Suggested: Add a credential fingerprint to the claim key. Declined (kickoff fixes once per key; reject-loop risk). - [recommended] A returned (not raised) non-2xx response counted as success and triggered approve. at
src/apm_cli/core/auth_chain.py
Latent today (call sites raise), but unguarded.
Suggested: Approve only on a classified OK outcome; add a returned-404 test. Folded.
Supply Chain Security Expert
- [recommended] Approve on a returned non-2xx response. at
src/apm_cli/core/auth_chain.py
Does not match "approve if the credential allowed the operation". Folded.
Proof (missing at):tests/unit/core/test_auth_credential_report.py::test_ambiguous_helper_outcome_is_not_reported-- proves: a returned non-success response does not cause Git to store the credential [secure-by-default] - [recommended] A 401 on a path the user cannot reach could erase a credential that works elsewhere on the host. at
src/apm_cli/core/auth_chain.py
APM acts on URLs from third-party manifests; if the same secret already worked on the host, the 401 means missing authorization.
Suggested: Skip reject after an approve of the same secret on (host, port); document residual risk. Folded (code, test, andenterprise/security.md). - [recommended] Approve ran synchronously with the full fill timeout (default 60s). at
src/apm_cli/core/token_manager.py
Suggested: Give approve/reject a short timeout. Folded (10s cap).
Test Coverage Expert
- [recommended] Default Git config without
useHttpPath(host-wide helper scope) was not tested. Folded:test_host_scoped_helper_without_use_http_path.
Proof (missing at):tests/unit/core/test_auth_credential_report.py[secure-by-default,vendor-neutral] - [recommended] No report test covered an Azure DevOps Server host with a port. Folded:
test_ado_server_host_with_port_reports_port_in_host_field.
Proof (missing at):tests/unit/core/test_auth_credential_report.py[secure-by-default,portability-by-manifest] - [recommended] Once-per-key was only tested sequentially. Folded:
test_concurrent_workers_report_once_per_key.
Proof (missing at):tests/unit/core/test_auth_credential_report.py[secure-by-default,devx]
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.
Co-authored-by: Copilot App <[email protected]>
9ea61ff to
3c45a3b
Compare
Co-authored-by: Copilot App <[email protected]>
3c45a3b to
640ddb1
Compare
Co-authored-by: Copilot App <[email protected]>
8bfa005 to
b66ada0
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Credential handling can erase unrelated or valid secrets and expose secrets in verbose logs, while failed probes may be reported as successful.
10 open issues
Make approval credential checks process-wide and atomic · New Recognize versioned HTTP 403 status lines · New Match the requested HTTPS port when verifying rejection · New Do not erase credentials after redirected sign-in 401s · New Validate replayed credentials against the requested identity · New Prevent helper stderr from leaking credentials · New Compare UTF-8 bytes to support non-ASCII passwords · New Evict each rejected credential even when reporting is claimed · New Treat preflight timeouts as inconclusive, not successful · New Exclude repository URLs from ambiguity text matching · New
What changed in this PR
This PR extends the Azure DevOps authentication chain from #3790 to report helper-sourced credential outcomes back to Git, addressing #3765 so expired credentials can be replaced.
Changes:
- Preserve credential-fill descriptions for approval after success or rejection after a verified authentication failure.
- Add process-wide report tracking, cache invalidation, and architecture ownership checks.
- Expand regression coverage and update authentication documentation.
| File | Description |
|---|---|
tests/unit/scripts/test_architecture_runner.py |
Registers the credential-report ownership rule in the expected inventory. |
tests/unit/core/test_auth_outcome.py |
Tests verified rejection classification and retained fill descriptions. |
tests/unit/core/test_auth_credential_report.py |
Adds reporting, scoping, concurrency, and helper-failure coverage. |
tests/integration/test_architecture_owner_rule_mutations.py |
Tests reporting ownership and rejection guardrails. |
tests/integration/test_ado_credential_helper_install_lifecycle.py |
Adds installed-CLI approval and rejection scenarios. |
src/apm_cli/core/token_manager.py |
Retains fill descriptions and runs bounded Git credential reports. |
src/apm_cli/core/auth.py |
Reuses the shared helper-cache key function. |
src/apm_cli/core/auth_outcome.py |
Adds verified-rejection state and diagnostic checks. |
src/apm_cli/core/auth_chain.py |
Coordinates reporting, deduplication, and rejected-credential eviction. |
scripts/architecture_linter/checks/transport_auth_outcome.py |
Adds static checks for reporting ownership and safeguards. |
packages/apm-guide/.apm/skills/apm-usage/authentication.md |
Documents helper reporting for coding-agent guidance. |
docs/src/content/docs/getting-started/authentication.md |
Explains approval, rejection, and excluded outcomes. |
docs/src/content/docs/enterprise/security.md |
Documents reporting scope and security limits. |
CHANGELOG.md |
Adds the user-facing credential-reporting entry. |
apm.lock.yaml |
Updates hashes for the deployed auth skill. |
.apm/skills/auth/SKILL.md |
Updates canonical auth guidance with reporting ownership. |
.apm/architecture/owners/transport-auth-platform.json |
Records reporting ownership and its guard. |
.agents/skills/auth/SKILL.md |
Synchronizes deployed auth guidance. |
Review effort: Balanced
Co-authored-by: Copilot App <[email protected]>
bc20640 to
b941fbd
Compare
Folded in this run
Deferred (out-of-scope follow-ups)
Regression-trap evidence (mutation-break gate)Each new guard was removed and its test failed: accepted-secret skip, discard on every rejection, preflight timeout outcome, description username match, URL removal before text signals, plus the Lint contractruff check and format --check (0.15.12), pylint R0801, lint-auth-signals and the architecture linter are all silent at b941fbd. CIAll required checks pass at b941fbd (23 pass, 0 fail), 0 open code-scanning alerts and 0 unresolved threads, after 2 CI fix iterations. Generated by autopilot-pr-merge-worker. This comment is AI-generated and may contain errors. |
Co-authored-by: Copilot App <[email protected]>
b941fbd to
930bd1e
Compare
… release Co-authored-by: Copilot App <[email protected]>
Follow the git-credential contract ("TYPICAL USE OF GIT CREDENTIAL",
https://git-scm.com/docs/git-credential): after the Azure DevOps chain
uses a credential from `git credential fill`, run `git credential approve`
when the operation succeeded and `git credential reject` after a verified
HTTP 401 for that credential, each fed the description fill returned.
- auth_outcome: AuthOutcome.rejection_verified / is_verified_rejection;
only HTTP 401 (or Git's 401 wording) for a presented credential sets it.
403, sign-in redirects and sign-in pages never do.
- token_manager: GitHelperCredential keeps fill's description verbatim;
GitHubTokenManager.report_git_helper_credential runs approve/reject with
the fill environment (GCM_INTERACTIVE=0 unattended), stdin only, timeout,
debug-only failures, and only when the description matches the request.
- auth_chain: report_helper_outcome is the only reporter; once per
(host, port, path) and action per process; reject drops the cached
answer. Never for ADO_APM_PAT, az bearer, gh or non-ADO credentials.
- Guard transport-platform-credential-report-owner replaces the
"never call approve/reject" check, with a MutationCase and side-door
mutations.
- Hermetic tests with a real helper configured in an isolated global Git
config, plus a real-binary install lifecycle scenario.
apm-spec-waiver: credential helper outcome reporting follows the git-credential contract and is outside the OpenAPM spec surface
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
- Verify a rejection only from status-anchored 401 wording or Git's 401 phrases, never when a 403 or not-found signal is present (a bare "401" can be part of a repository URL). - Approve only when the helper attempt classified OK; a returned non-2xx response is no longer treated as acceptance. - Never reject a secret this process already saw accepted on the same host (a 401 on another path means no access, not a dead credential). - Cap approve/reject at a 10s timeout. - Tests: concurrent workers, returned responses, cross-path 401, useHttpPath=false, Azure DevOps Server host:port, 401-in-URL cases. apm-spec-waiver: credential helper outcome reporting follows the git-credential contract and is outside the OpenAPM spec surface Co-authored-by: Copilot App <[email protected]>
…3765) Co-authored-by: Copilot App <[email protected]>
Auth delta review folds: - A proxy challenge (proxy wording or 407) or a URL naming a host other than the requested one makes a rejection ambiguous, so a proxy or off-host prompt can never erase the requested host's helper credential. - The status-anchored 401/403 patterns require a separator, so a glued "http401" in a repository URL never counts. - Tests for each case; security page lists the proxy and other-host cases. apm-spec-waiver: credential helper outcome reporting follows the git-credential contract and is outside the OpenAPM spec surface Co-authored-by: Copilot App <[email protected]>
CodeQL flagged the SHA-256 identity digest used to remember secrets that were accepted on a host. Drop it: the report ledger now records only approved (host, port, path) keys, and a verified rejection is skipped when the resolver's helper cache already holds the same secret for an approved key on that host (constant-time comparison). No secret is hashed or copied. apm-spec-waiver: credential helper outcome reporting follows the git-credential contract and is outside the OpenAPM spec surface Co-authored-by: Copilot App <[email protected]>
- Accepted-secret check is process-wide and atomic with the report claim (in-memory only, byte comparison, never hashed or logged). - Every verified rejection drops the cached helper answer, even when the reject report was already sent. - The fill description is reported only when its username, password and any path match the credential actually sent. - Helper stderr is never logged. - Classifier: versioned HTTP 403 status lines veto a rejection; another scheme or port is another endpoint; a response that landed on the ADO sign-in URL is never a verified rejection; repository URLs no longer trip the proxy and not-found checks; without a requested host any URL makes a rejection ambiguous. - Install preflight: an ls-remote timeout reaches the auth chain as an outcome, not as a value it could approve. apm-spec-waiver: credential helper outcome reporting follows the git-credential contract and is outside the OpenAPM spec surface Co-authored-by: Copilot App <[email protected]>
… release Co-authored-by: Copilot App <[email protected]>
930bd1e to
a948e50
Compare
…idance (#3903) * docs(changelog): enforce one-line entries in agent and contributor guidance Make the changelog rule concrete in its single source (.apm/instructions/changelog.instructions.md): one line, user-visible effect first, 25 words or fewer, ending with (#PR); breaking changes in "Breaking changes and upgrade notes" with a one-line migration; never a second line for the same change; no entry for internal-only PRs; two good and two bad examples from the current changelog. cut-release now re-sanitizes the whole [Unreleased] block at release time (dedupe, condense, Highlights, upgrade notes, ref/credit check). The delivery and merge autopilot workers, pr-description-skill, CONTRIBUTING.md, the PR template and the development guide point at the rule. Generated .github/ and .agents/ copies and apm.lock.yaml hashes are re-synced with apm install. Clean the current [Unreleased] block into that shape: drop the long duplicates of #3765/#3818, #3769, #3788, #3865, #3867, #3873, #3875, #3882 and the spec lines, fold their user-relevant caveats into the short lines, and drop test-only #3877. Co-authored-by: Copilot App <[email protected]> * docs(changelog): scope delivery-worker CHANGELOG edits to one task; shorten sanitizer example Address review: only the task whose files_hint owns CHANGELOG.md edits it (wave gate forbids shared-file edits across task branches), and the worked example now fits rule 2 while keeping its caveat and four refs. Co-authored-by: Copilot App <[email protected]> --------- Co-authored-by: danielmeppiel <[email protected]> Co-authored-by: Copilot App <[email protected]>


Description
TL;DR. When the Azure DevOps auth chain uses a credential from
git credential fill, APM now reports the outcome back to the user's credential helper, as Git does:approveafter the operation succeeded,rejectonce after a verified HTTP 401 for that exact credential. Git Credential Manager can then replace an expired credential instead of offering it again on every run. Ambiguous outcomes (403, sign-in redirect or page, not-found, throttle, network, TLS) are never reported, and env PATs,azbearers andgh/non-ADO credentials are never reported. Stacked on #3790 (owner of the chain and the classifier).Problem (WHY)
gitcredentialwill ask for a new password in its next invocation."reject, a dead stored credential keeps being returned byfill, so every install re-sends it and fails the same way.Approach (WHAT)
ok)git credential approve(once per host/port/path per process)credential_rejectedand verified (status-anchored HTTP 401, or Git's 401 wording; never with a 403, not-found, or proxy signal, or an error naming another host)git credential reject(once), drop it fromHelperCredentialCache-- unless this process already saw the same secret accepted on that hostADO_APM_PAT,azbearer, gh token, GitHub/GitLab/generic fillImplementation (HOW)
core/auth_outcome.pyAuthOutcome.rejection_verified+is_verified_rejection. Only HTTP 401 (or Git's 401 wording, never with403) for a presented credential sets it. The classifier stays the single decision owner.core/token_manager.pyGitHelperCredential.descriptionkeeps fill's attribute lines verbatim (repr/compare off).report_git_helper_credentialruns `git credential approvecore/auth_chain.pyreport_helper_outcomeis the only reporter, called once fromrun_ado_chainafter the helper attempt. Process-wideHelperReportLedgerenforces once per (host, port, path) and action; a credential with no fill description (not obtained from the helper) is never reported.scripts/architecture_linter/checks/transport_auth_outcome.pytransport-platform-credential-report-owner: argv only in the runner, runner called only fromreport_helper_outcome, owner called only from the chain, reject gated onis_verified_rejection, 401-only verification in the classifier, once-per-key claim.host-credential-resolutiondecision/owner/guard updated;getting-started/authentication.md, apm-guideauthentication.md, auth skill (+.agentscopy, lock hash) now describe the behavior.Trade-offs
password_expiry_utc/oauth_refresh_tokenif a helper returns them) instead of rebuilding it, per the contract.Benefits
fillcan mint a fresh one instead of resending the dead one forever.store,cache) keep them.Validation
Lint contract (CI mirror)
Tests
Red before the fix: with
src/reverted, the new lifecycle scenario fails (1 failed) and the unit module cannot importreport_helper_outcome.Scenario evidence
storewith fill's host/path/username/password,GCM_INTERACTIVE=0test_ado_helper_credential_outcome_is_reported_back_to_git(real binary),test_accepted_helper_credential_is_approved_once_with_fill_descriptionerase, nostoretest_verified_rejection_rejects_once_and_drops_the_cache[http-401/git-401-prompt/git-authentication-failed]test_ambiguous_helper_outcome_is_not_reported[*](11 cases),test_returned_non_success_response_is_not_approved[*]401in a repo URL never verifies a rejectiontest_secret_accepted_on_this_host_is_not_rejected_for_another_path,test_only_a_401_for_a_presented_credential_verifies_rejection[*]useHttpPath, ADO Serverhost:porttest_concurrent_workers_report_once_per_key,test_host_scoped_helper_without_use_http_path,test_ado_server_host_with_port_reports_port_in_host_fieldADO_APM_PAT,azbearer, GitHub fill: never reportedtest_ado_pat_keeps_precedence_over_credential_helper(helper.events() == ()),test_accepted_env_pat_is_never_reported,test_rejected_pat_and_bearer_are_never_reported,test_accepted_bearer_is_never_reported,test_non_ado_helper_credential_is_never_reportedtest_report_targets_only_the_derived_host,test_credential_for_another_host_is_never_reported,test_credential_not_obtained_from_fill_is_never_reportedtest_hanging_helper_store_never_fails_the_operation,test_report_error_never_fails_the_operationtest_only_a_401_for_a_presented_credential_verifies_rejection[*]How to test
APM_E2E_TESTS=1 APM_BINARY_PATH=$PWD/.venv/bin/apm .venv/bin/python -m pytest tests/integration/test_ado_credential_helper_install_lifecycle.py -k reported_back -p no:xdist -q.venv/bin/python -m pytest tests/unit/core/test_auth_credential_report.py -p no:xdist -qelif outcome.is_verified_rejection:toelif outcome.is_auth_failure:incore/auth_chain.pyand run.venv/bin/python scripts/lint_architecture_boundaries.py --root .-- guardtransport-platform-credential-report-ownerfails.Issue and approved scope
Issue: Fixes #3765
Fixes #3752 (follow-up of the #3752 credential-helper fix; that issue is still open)
Human scope-approval comment: #3765 (comment)
Does this PR complete the issue, or what remains? It completes #3765's Done-when: approve on success, reject only on a classified (verified) credential rejection, no reports for env/gh/az or ambiguous/network/TLS/throttle/not-found/sign-in-redirect outcomes or underived hosts, helper failures never fail an install, hermetic tests for each case, and auth docs updated. Stacked on #3790 (base
danielmeppiel-0361-t1-pr1-auth-owner); rebase ontomainafter v0.36.1 is tagged and #3790 lands.Type of change
Testing
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdated(new/changed
<a id="req-XXX"></a>anchor + prose + Appendix Crow).
docs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.
@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.
apm-spec-waiverline).Co-authored-by: Copilot [email protected]