test: add coverage for audit build-URL host-validation guard - #2214
Closed
github-actions[bot] wants to merge 1 commit into
Closed
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
resolve_audit_context / validate_audit_url_host stops `ado-aw audit <url>` from sending ADO credentials to an attacker-controlled or mismatched host, but every prior tests/audit_it.rs case only passed a bare numeric build ID. The guard itself was only exercised by unit tests calling the function directly, so a regression dropping the parsed.host wiring in resolve_audit_context would not be caught by any subprocess-level test. Add two subprocess tests that invoke the real ado-aw binary with a full build URL: - audit_rejects_untrusted_host_in_build_url_without_org_override: an attacker.example.com URL with no --org must fail with the PAT-exfiltration guard message. - audit_rejects_build_url_host_mismatched_with_trusted_org: an on-prem URL host that differs from a trusted --org host must still be refused. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: 2 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Collaborator
|
Integrated into #2238 and validated there. Closing this source PR as superseded by the aggregate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Test Gap Fixes
Test suite snapshot: 3361 unit tests, 7 integration tests in
audit_it.rs(2 new), 3325+ tests overall across the suite (unchanged pass count elsewhere).Added Coverage
src/audit/cli.rsvalidate_audit_url_hostviaado-aw audit <full-build-url>(untrusted host, no--org)parse_build_ref→resolve_audit_context→validate_audit_url_host) had zero end-to-end coverageaudit_rejects_untrusted_host_in_build_url_without_org_overridesrc/audit/cli.rsvalidate_audit_url_hoston-prem host mismatch against a trusted--org--organchoraudit_rejects_build_url_host_mismatched_with_trusted_orgBoth tests invoke the real
ado-awbinary as a subprocess (matching the existing pattern intests/audit_it.rs) and assert the process exits non-zero with the guard's stderr message, exactly reproducing what an attacker-craftedado-aw audit <malicious-url>invocation would trigger.I also audited
src/audit/analyzers/{ado_proxy,custom_jobs,missing,otel}.rsandsrc/compile/codemods/*.rs(this cycle's assigned modules per cache-memory) and found they already have solid in-module unit coverage (6-15 tests per file) — no meaningful gap there, so I redirected to this higher-value CLI-boundary gap instead.Validation
cargo test(3361 + 7 + other suites, 0 failures)cargo clippy --all-targets --all-features(0 warnings)This PR was created by the automated test gap finder. Previous run: 2026-09-14. Modules audited this cycle: audit/analyzers/ado_proxy.rs, audit/analyzers/custom_jobs.rs, audit/analyzers/missing.rs, audit/analyzers/otel.rs, compile/codemods/, audit/url.rs, audit/cli.rs.*
Warning
Firewall blocked 3 domains
The following domains were blocked by the firewall during workflow execution:
onprem.example.comspsprodeus21.vssps.visualstudio.comspsprodsbr1.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.