feat(cli): implement ts dev audit headers cache-header audit (#834) - #1172
Open
vasujain00 wants to merge 1 commit into
Open
vasujain00 wants to merge 1 commit into
vasujain00 wants to merge 1 commit into
Conversation
Implements the origin cache-header audit from the IABTechLab#834 spec: fetches origin responses (explicit URLs or discovered from the origin root HTML), classifies each by content type, evaluates cache directives, and reports a per-type pass/warn/fail verdict. - rules.rs: ContentTypeGroup taxonomy (MIME param stripping), unit Verdict enum, per-group cacheability rules. no-store alone passes HTML/RTB per RFC 9111 5.2.2.5; s-maxage honored as CDN TTL; Vary checked on all cacheable groups; Surrogate-Key only on cacheable groups. - fetch.rs: AuditHeadersArgs, OriginClient trait + reqwest blocking impl, config-derived origin resolution, HTML-parse discovery (never probes /_ts/). - analyze.rs: worst-of rollup per group + summary + exit-code mapping. - output.rs: writer-injected human table + JSON (bare-string verdicts). - Adds Audit variant to the existing DevCommand enum (cross-platform, unlike the macOS-only proxy). reqwest scoped to cfg(not(target_arch = wasm32)). Follows the CLI's CliResult<T> string-error and writer-injection conventions. 25 unit tests cover classification, rules, discovery, rollup, and rendering. Refs IABTechLab#834
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.
Summary
Implements the origin cache-header audit designed in the #834 spec (PR #930).
ts dev audit headersfetches origin responses — explicit URLs or discovered from the origin root HTML — classifies each by content type, evaluates cache directives, and reports a per-type pass/warn/fail verdict.Changes
commands/dev/audit/mod.rsDevAuditCommandgroup + exit-code dispatchcommands/dev/audit/headers/rules.rsContentTypeGrouptaxonomy, unitVerdictenum, per-group cacheability rulescommands/dev/audit/headers/fetch.rsAuditHeadersArgs,OriginClienttrait + reqwest blocking impl, HTML-parse discoverycommands/dev/audit/headers/analyze.rscommands/dev/audit/headers/output.rscommands/dev/mod.rsAuditvariant to existingDevCommandCargo.tomlreqwest(blocking) scoped tocfg(not(target_arch = "wasm32"))Design fidelity
no-storealone passes HTML/RTB (RFC 9111 §5.2.2.5)s-maxagehonored as CDN TTL;Vary(User-Agent/Cookie) checked on all cacheable groupsSurrogate-Keyonly checked on cacheable groups; MIME params stripped before classification/_ts/routesAuditis available on all host platforms (unlike the macOS-only proxy)Closes
Refs #834
Test plan
cargo test --package trusted-server-cli --target <host>— 105 pass (25 new)cargo clippy --package trusted-server-cli --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleants dev audit headers --helprendersChecklist
unwrap()in production codelogmacros (notprintln!) outside the output sink