Skip to content

Parse shell commands for permission analysis #175

Closed

Description

@hakula139

Goal

bash rules currently match the raw command string, so chaining, substitutions, and wrappers can defeat them, and an allow rule never matches a compound command. Parsing commands into simple segments lets rules evaluate each one and lets the gate recognize commands it cannot analyze.

Acceptance criteria

  • tree-sitter-bash splits commands into simple commands across ;, &&, ||, pipes, and subshells.
  • Leading environment assignments and transparent wrappers (env, nice, nohup, time, timeout) are stripped before matching. Output redirections count as edit accesses to their targets.
  • A command is opaque if it contains command or process substitution, eval, a variable in command position, or a shell reading code (sh -c, | sh). Rules can deny or ask about an opaque command, but never allow it.
  • Deny and ask rules match when any segment matches. Allow requires every segment to match an allow rule or a shipped, known-safe read-only command with argument guards (find without -exec or -delete, sed without -i).
  • Tests cover each separator, wrapper stripping, redirections, every opaque form, and known-safe argument guards.

Notes

Depends on #174. Parsing narrows the ways rules can be fooled, while the OS sandbox (#133) bounds what an allowed command can do.

Activity

  1. self-assigned this
    on Oct 15, 2026
  2. added
    enhancement
    area: permission
    area: tools
    on Oct 15, 2026
  3. added this to the milestone on Oct 15, 2026
  4. modified the milestones: , v0.1.0 on Oct 15, 2026
  5. added 2 commits that reference this issue on Oct 16, 2026
    a3a5221
    71d7b77
  6. added a commit that references this issue on Oct 16, 2026
    f355457
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: permissionarea: toolsenhancement

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions