safe-chains 0.239.0

Auto-allow safe bash commands in agentic coding tools
Documentation
[[command]]
writes_cwd = "named"
name = "sort"
aliases = ["gsort"]
description = "Sorts lines from its inputs into stdout. Without -o it observes: it opens each operand for reading (`-` is standard input) and writes only to stdout, and a credential file named as an operand is read in full and its lines shown. Several flags reach beyond that: -o and --output write the result to a named file, which can create or overwrite any file the user may write, irreversibly; --compress-program runs a named program on temporary files, which is arbitrary execution; --files0-from reads the operand list from a second file, so the files read cannot be known from the command line; --random-source reads a file for randomness. Large inputs spill to temporary files in $TMPDIR or the -T directory, removed on exit. It makes no network connection. Part of GNU coreutils (9.12), which has a stable release cadence of a few releases a year; the sort interface is stable. macOS ships its own sort (2.3-Apple) with the same ordering flags and -o, but not every GNU long option."
researched_version = "GNU coreutils 9.12"
url = "https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-invocation"
level = "Inert"
bare = true
standalone = [
    "--check", "--debug", "--dictionary-order",
    "--general-numeric-sort", "--help", "--human-numeric-sort",
    "--ignore-case", "--ignore-leading-blanks",
    "--ignore-nonprinting", "--merge", "--month-sort",
    "--numeric-sort", "--random-sort", "--reverse",
    "--stable", "--unique", "--version", "--version-sort", "--zero-terminated",
    "-C", "-M", "-R", "-V", "-b", "-c", "-d",
    "-f", "-g", "-h", "-i", "-m", "-n", "-r", "-s", "-u", "-z",
]
valued = [
    "--batch-size", "--buffer-size", "--field-separator",
    "--key", "--parallel",
    "--random-source", "--sort", "--temporary-directory",
    "-S", "-T", "-k", "-t",
]
examples_safe = ["sort ./a.txt", "sort -u -k2,2 ./a.txt", "sort -t: -k3 -n ./a.txt", "sort -rh ./sizes.txt", "sort --check ./a.txt", "sort --version"]
examples_denied = ["sort -o ./a.txt ./a.txt", "sort --output=./a.txt ./a.txt", "sort --compress-program=sh ./a.txt", "sort --files0-from=list.txt", "sort ~/.ssh/id_rsa"]

# Sorting reorders the piped lines without inventing new ones, so stdout is a permutation of the
# input and carries that stage's locus — `$(fd … | sort | head -1)`. The invalidating flags are the
# ones that stop the output being the input: `--files0-from` reads its line set from a FILE rather
# than the stream, `-o`/`--output` diverts stdout to a file (leaving nothing to substitute), and
# `-c`/`-C`/`--check` print a diagnostic instead of the lines.
[command.output]
locus_from = "stdin"
valued = [
    "--batch-size", "--buffer-size", "--field-separator", "--key", "--parallel",
    "--random-source", "--sort", "--temporary-directory",
    "-S", "-T", "-k", "-t",
]
invalidated_by = ["--files0-from", "-o", "--output", "-c", "-C", "--check", "--help", "--version", "-h", "-V"]