fix(coverage): reject package: and dart: URIs outside known roots in Resolver #2640
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.40) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 279 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.337
Real PR Conversation Timeline
1 comments
"Review active on #2640"
general
weight: 0.35
liamappelbe
Summary
Completes the containment check added in #2534.
#2534 added
_isWithinKnownRootsto thefile:branch ofResolver.resolve(), on the basis — stated in its own_knownRootsdoc comment — that coveragesourceentries are untrusted and their resolved contents are read into formatter output. Thepackage:anddart:branches were left without the same check, so they can still resolve outside the known roots.The gap
Plain
..does not traverse, becauseUri.parseperforms RFC 3986 dot-segment removal before the resolver sees the path. ButUri.pathSegmentspercent-decodes after that, so an encoded separator survives as a single segment:packageNamestaysfoo(the package lookup succeeds), andp.join(packagePath, ...)+resolveSymbolicLinksthen walk out of the package root. The same applies todart:. The resolved path's contents are read byformat_coverage --pretty-printandfilterIgnored, so wherever coverage JSON crosses a trust boundary this reads files outside the roots.Change
_isWithinKnownRootscheck to thepackage:anddart:branches, mirroringfile:.resolveSymbolicLinks, since the paths they are compared against are canonicalized the same way. Without this, a root reached through a symlink (a symlinked pub cache, or/var->/private/varon macOS) would never contain its own files and legitimate resolution would start returningnull.Tests
Three added: a
package:encoded-separator escape returnsnull, adart:escape returnsnull, and apackage:URI through a symlinked root still resolves.dart analyze,dart format --set-exit-if-changed, and the fullcoveragesuite pass.Notes
Resolver.BazelResolverreturns relative paths (resolved by the caller against the cwd) rather than paths within these roots, so it is a different shape — happy to follow up on it separately if you'd like.