shouldUseSandbox function

bool shouldUseSandbox(
  1. String command,
  2. SandboxConfig config
)

Check if a command should use sandbox.

Implementation

bool shouldUseSandbox(String command, SandboxConfig config) {
  if (!config.enabled) return false;

  final baseCmd = command.trim().split(RegExp(r'\s+')).first;

  // Check excluded commands
  for (final excluded in config.excludedCommands) {
    if (excluded.endsWith(':*')) {
      // Prefix match: "docker:*" matches "docker" and "docker ..."
      final prefix = excluded.substring(0, excluded.length - 2);
      if (baseCmd == prefix) return false;
    } else if (excluded == baseCmd || excluded == command.trim()) {
      return false;
    }
  }

  return true;
}