Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AI Shell Team Aish analyze sandbox degraded

From Leeroopedia
Knowledge Sources
Domains Security, Sandboxing, Error_Handling
Last Updated 2026-10-29 00:00 GMT

Overview

Concrete tool for handling sandbox unavailability with reason-routed fallback to policy rules or configurable action provided by the aish-security crate.

= Description

The analyze_sandbox_degraded function categorizes the sandbox failure reason and routes to the appropriate fallback strategy:

  • Disabled/IPC unavailable: try FallbackRuleEngine first, then apply sandbox_off_action
  • Execution/timeout/protocol errors: force Confirm (medium risk)
  • Environment issues (CWD, mount): apply sandbox_off_action

The analyze_with_optional_fallback helper tries the fallback engine first, and if no rule matches, applies the sandbox_off_action. The analyze_with_action helper maps the action (Allow/Confirm/Block) to a risk level and analysis.

Usage

This function is called internally by analyze_with_sandbox when the sandbox cannot run the command. No direct call is needed by external code.

Code Reference

Source Location

  • Repository: aish
  • File: crates/aish-security/src/sandbox/degraded.rs

Signature

pub(crate) fn analyze_sandbox_degraded(
    policy: &SecurityPolicy,
    fallback_engine: &FallbackRuleEngine,
    command: &str,
    reason: SandboxReason,
    details: SandboxDegradedDetails,
) -> SecurityAnalysis

fn analyze_with_optional_fallback(
    policy: &SecurityPolicy,
    fallback_engine: &FallbackRuleEngine,
    command: &str,
    reason: SandboxReason,
    details: SandboxDegradedDetails,
) -> SecurityAnalysis

fn analyze_with_action(
    effective_action: SandboxOffAction,
    reason: SandboxReason,
    details: SandboxDegradedDetails,
) -> SecurityAnalysis

Import

// Internal to the security pipeline
use aish_security::sandbox::degraded::analyze_sandbox_degraded;

I/O Contract

Inputs

Name Type Required Description
policy &SecurityPolicy Yes For fallback rules and sandbox_off_action
fallback_engine &FallbackRuleEngine Yes For policy rule matching
command &str Yes Command being evaluated
reason SandboxReason Yes Why the sandbox is degraded
details SandboxDegradedDetails Yes Exit code, cwd, repo_root

Outputs

Name Type Description
return SecurityAnalysis Risk from fallback rules or sandbox_off_action

Usage Examples

Degraded Mode Handling (Internal)

// Called internally when sandbox cannot run:
// e.g., CWD outside repo root:
let analysis = analyze_sandbox_degraded(
    &policy,
    &fallback_engine,
    command,
    SandboxReason::CwdOutsideRepoRoot,
    details.with_cwd(&cwd).with_repo_root(&repo_root),
);
// Routes to analyze_with_action(policy.sandbox_off_action, ...)

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment