bash-ast

Parse Bash commands into an AST and generate JSON safety reports.

4|Updated Apr 3, 2026
One-click install
npx skills add https://github.com/ybbms777/openclaw-claude-code-integration --skill bash-ast
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bash-ast
Source: https://github.com/ybbms777/openclaw-claude-code-integration/tree/main/skills/safe-command-execution/skills/bash_ast
Command: npx skills add https://github.com/ybbms777/openclaw-claude-code-integration --skill bash-ast

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Bash AST parsing layer analyzes shell commands by converting them into an AST to identify dangerous patterns, helping teams enforce safe execution and prevent unsafe actions or injections.

Core Features & Use Cases

  • Lexical analysis of Bash input into tokens
  • Recursive-descent AST parsing to build command trees
  • Dangerous command detection (rm, dd, chmod, curl|wget+pipe to shell)
  • Path traversal detection and screening of sensitive paths
  • Injection-chain and dangerous redirection detection
  • Produces structured reports with threat level and justification for downstream tooling

Quick Start

Run python3 scripts/bash_ast.py '<command>' to analyze the command safety and generate a structured result.

Frequently Asked Questions about bash-ast

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze Bash command safety using an AST?

Detect dangerous Bash commands by parsing the input into an AST to identify patterns like rm, dd, chmod, and curl or wget piped to shell. The analyzer flags these risky commands and outputs a structured threat report.

How does AST parsing detect shell injection chains?

AST parsing detects shell injection chains by performing recursive-descent parsing to build command trees, revealing unsafe command combinations and dangerous redirections. This structured analysis surfaces injection threats with a justification in a JSON report.

Can I check for path traversal in Bash scripts?

Yes, you can screen for path traversal in Bash scripts by parsing commands into an AST to identify access to sensitive paths. The analysis flags these traversal attempts and generates a structured JSON report detailing the threats.

Do I need any dependencies to run the Bash AST parser?

No dependencies are required to run the Bash AST parser. You can execute the standalone Python script directly from the command line by providing a Bash command as an argument to generate the safety analysis report.

What is the best way to identify risky redirections in shell commands?

The best way to identify risky redirections in shell commands is using an AST-based analysis pipeline that tokenizes and parses the input. This approach detects dangerous redirections and outputs a structured JSON report with threat levels and justifications.