policy-demo / safe

safe - cli-guard examples/policy

NAME

safe - validates a single positional arg

SYNOPSIS

safe

DESCRIPTION

Validates a single positional argument against the ShellMeta byte set. Prints the accepted value on success. Returns ErrShellMeta on rejection (exit 2).

Examples:

# accepted - no metacharacters
policy-demo safe hello
# accepted: [hello]

# accepted - whitespace inside a single arg is fine, only \t \n \r reject
policy-demo safe "hello world"
# accepted: [hello world]

# rejected - same code path as `unsafe`, demonstrating the gate
# is content-driven, not name-driven
policy-demo safe 'hello; rm -rf /'
# policy: shell metacharacter rejected: arg positional[0] contains ';' at index 5

The empty string passes the gate. Required-ness is a separate concern; check len(args) before calling ValidateArgSlice if the verb needs at least one value.

Usage:

safe [GLOBAL OPTIONS] [command [COMMAND OPTIONS]] [ARGUMENTS...]