Skip to content

API Reference parrot_tools.shell_tool.security

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.shell_tool.security

View source

ShellTool Security — re-export shim (FEAT-252).

The generic security engine (CommandSanitizer / SecurityPolicy / SecurityLevel / ValidationResult / CommandVerdict / CommandRule / CommandSecurityError) has been relocated into core parrot.security.command_sanitizer so that PythonCodeSanitizer and OutputScrubber can depend on it without creating an upward import.

All public names are re-exported verbatim here so every existing import of the form from parrot_tools.shell_tool.security import ... keeps working without any change at the call-site.

Alias CommandRule

Re-exported from parrot.security.command_sanitizer.CommandRule.

Alias CommandSanitizer

Re-exported from parrot.security.command_sanitizer.CommandSanitizer.

Alias CommandSecurityError

Re-exported from parrot.security.command_sanitizer.CommandSecurityError.

Alias CommandVerdict

Re-exported from parrot.security.command_sanitizer.CommandVerdict.

Class SecureShellMixin

Mixin that adds security validation to ShellTool via composition.

Provides three public methods:

  • set_security_policy(policy) — attach a SecurityPolicy; creates a CommandSanitizer internally.
  • validate_command(command) — return a ValidationResult.
  • assert_command_safe(command) — raise CommandSecurityError if the command is denied or requires review.

Backward-compatible design: if no policy has been set (_sanitizer is None), validate_command returns ALLOWED for every command, matching the old no-security behaviour.

Method SecureShellMixin.set_security_policy

Attach a security policy, replacing any previously set policy.

set_security_policy(policy: SecurityPolicy) -> None

Parameter Type Default Description
policy SecurityPolicy The SecurityPolicy to enforce on subsequent calls.

Method SecureShellMixin.validate_command

Validate a command string against the active security policy.

If no policy has been set, every command is ALLOWED (backward compat).

validate_command(command: str) -> ValidationResult

Parameter Type Default Description
command str The raw command string to validate.

Returns: ValidationResult — A ValidationResult with the verdict, reasons, and risk score.

Method SecureShellMixin.assert_command_safe

Validate and raise if the command is denied or needs review.

NEEDS_REVIEW is treated as DENIED in automated contexts (per Open Q1 resolution in FEAT-038 spec).

assert_command_safe(command: str) -> None

Parameter Type Default Description
command str The raw command string to validate.

Raises:

  • CommandSecurityError — If the command verdict is DENIED or NEEDS_REVIEW.

Alias SecurityLevel

Re-exported from parrot.security.command_sanitizer.SecurityLevel.

Alias SecurityPolicy

Re-exported from parrot.security.command_sanitizer.SecurityPolicy.

Alias ValidationResult

Re-exported from parrot.security.command_sanitizer.ValidationResult.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally