← Back to Pull requests

fix(coverage): reject package: and dart: URIs outside known roots in Resolver #2640

Open
unknown opened this pull request with 279 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 04, 2026 21:35 UTC
Author

Summary

Completes the containment check added in #2534.

#2534 added _isWithinKnownRoots to the file: branch of Resolver.resolve(), on the basis — stated in its own _knownRoots doc comment — that coverage source entries are untrusted and their resolved contents are read into formatter output. The package: and dart: branches were left without the same check, so they can still resolve outside the known roots.

The gap

Plain .. does not traverse, because Uri.parse performs RFC 3986 dot-segment removal before the resolver sees the path. But Uri.pathSegments percent-decodes after that, so an encoded separator survives as a single segment:

package:foo/..%2f..%2foutside.txt  ->  pathSegments = [foo, ../../outside.txt]

packageName stays foo (the package lookup succeeds), and p.join(packagePath, ...) + resolveSymbolicLinks then walk out of the package root. The same applies to dart:. The resolved path's contents are read by format_coverage --pretty-print and filterIgnored, so wherever coverage JSON crosses a trust boundary this reads files outside the roots.

Change

  • Apply the existing _isWithinKnownRoots check to the package: and dart: branches, mirroring file:.

  • Canonicalize the known roots with 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/var on macOS) would never contain its own files and legitimate resolution would start returning null.
  • Tests

    Three added: a package: encoded-separator escape returns null, a dart: escape returns null, and a package: URI through a symlinked root still resolves. dart analyze, dart format --set-exit-if-changed, and the full coverage suite pass.

    Notes

  • Scoped to Resolver. BazelResolver returns 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.

  • Severity is modest and already bounded by the trust model the #2534 comment describes; this just extends the same check to the remaining branches it logically covers.
  • Diff: 279 lines (+209 / -70) across 3 files Reviewer: liamappelbe Review duration: 30396m
    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
    0.40
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 39.6% (MEDIUM) · Higher = larger blast radius
    39.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 21.1% · Safe to merge
    21.1%