bashCommandIsSafe function

SecurityResult bashCommandIsSafe(
  1. String command
)

Run all security checks on a command. Returns the first non-passthrough result, or passthrough if all pass.

Implementation

SecurityResult bashCommandIsSafe(String command) {
  final ctx = buildValidationContext(command);

  // Early validators — allow/ask short-circuits.
  for (final validator in _earlyValidators) {
    final result = validator(ctx);
    if (!result.isPassthrough) return result;
  }

  // Main validators — ask short-circuits.
  for (final validator in _mainValidators) {
    final result = validator(ctx);
    if (!result.isPassthrough) return result;
  }

  return const SecurityResult.passthrough(
    message: 'All security checks passed',
  );
}