Skip to content

feat: Context-aware command restrictions #129

@lykinsbd

Description

@lykinsbd

Currently all commands in command_transcripts are available regardless of the current CLI context. On real network equipment, commands like show running-config require privileged exec (#) and are not available from user exec (>).

Proposed design

Add an optional context_commands map to Platform config that whitelists which commands are available in each context:

context_commands:
  ">": ["enable", "exit"]
  "#": ["show version", "show running-config", "configure terminal", "exit", "end"]
  "(config)#": ["interface", "hostname", "exit", "end"]
  "(config-if)#": ["ip address", "no shutdown", "exit", "end"]

When a command is entered in a context where it is not whitelisted, return the standard IOS error:

% Invalid input detected at '^' marker.

If context_commands is not set for a platform, all commands remain available in all contexts (backward compatible).

Notes

  • This is a significant architectural addition
  • Platforms without context_commands are unaffected
  • Useful for testing tools that validate they are in the correct context before issuing commands

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions