← Back to Pull requests

List safe subresources instead of sensitive ones #25

Closed
unknown closed this pull request without merging on Sep 29, 2026 17:17 UTC
View on GitHub
unknown unknown commented on Aug 12, 2026 00:43 UTC
Author

Follow-up to #22, addressing @enj's review comment: https://github.com/Azure/guard/pull/22#discussion_r3761244900

This is not the right approach. It should be inverted to define what is safe (i.e. the status sub-resource), not what is unsafe.

Why

getResourceAndAction listed the subresources that must keep their own DataAction and collapsed everything else into the parent resource action. That default is the wrong way round - a subresource nobody has classified yet is silently covered by the parent resource's permission, so the list has to grow every time someone notices a new one. That list has in fact grown three times (exec, then nodeclient, then proxy, then attach/portforward), each time after the gap was found rather than before.

What changed

Collapse only the subresources upstream treats as part of the parent resource's permission, and give every other subresource its own <resource>/<subresource>/action.

The safe set is taken from the upstream view ClusterRole (bootstrappolicy.viewRules), which grants exactly these subresource kinds alongside their parent: status, scale, and pods/log. So safeSubresources = {status, scale, log, logs} (logs because guard has historically seen the plural spelling).

Unchanged by design:

  • Wildcard requests ( resource/subresource/verb) - expanded from the operations map elsewhere.

  • Special verbs (bind, escalate, use, impersonate, inference) - there the verb, not the subresource, identifies the operation, so userextras/scopes + impersonate stays userextras/impersonate/action.
  • Behavioral impact - please review

    Anything not on the safe list now resolves to <resource>/<subresource>/action. The Microsoft.ContainerService operations registry currently defines only managedClusters/pods/{read,write,delete} and managedClusters/pods/exec/action, so these actions match only roles carrying a wildcard (managedClusters/, pods/*) and are denied for roles that enumerate leaf actions. That is the intended fail-closed direction, but it is a behavioral change.

    Two points that need an explicit decision:

    1. CSR subresources are now gated. certificatesigningrequests/approval and /approvals no longer collapse into the parent write/delete, and the same rule would apply to /nodeclient. #23 reverted #12, which had gated nodeclient, so this rule partially re-applies what that revert removed. If CSR should stay collapsed until the corresponding DataActions exist in the registry, say so and I will add the CSR subresources to the safe set explicitly.
    2. Safe-set completeness. If any other subresource is expected to be covered by the parent permission today, it should be added to safeSubresources rather than discovered through a denial.

    Testing

  • go build ./..., gofmt -l, golangci-lint run in ghcr.io/appscode/golang-dev:1.25 - 0 issues

  • go test ./authz/providers/azure/rbac/... ./auth/providers/azure/graph/... - all pass

  • Added coverage for: status/log/scale collapsing, an unclassified subresource getting its own action (the fail-closed default), and the existing exec/attach/portforward/proxy and special-verb cases.
  • Diff: 399 lines (+299 / -100) across 4 files Reviewer: stlaz Review duration: 70114m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.43) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 399 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    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
    Diff Size diff_size
    0.358
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #25"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% 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: 43.2% (MEDIUM) · Higher = larger blast radius
    43.2%
    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: 56.8% · Lower = rushed or shallow review
    56.8%
    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: 18.7% · Safe to merge
    18.7%
    Repository