Files
1c27090fd7 feat(audit): inspect bundled hooks and settings (#752)
* feat(audit): inspect bundled hooks and settings

Bundled declarations can schedule commands and broaden permissions outside SKILL.md, while ordinary scanning skips hidden settings. Inspect the four explicit paths with bounded root-confined reads and structured findings so existing audit policy can review their potential execution.

Keep activation conditional and redact arbitrary arguments before reports. Register rule metadata through the existing structure analyzer and cover benign twins, parse gaps, source links, policy overrides, CLI/API output and a synthetic E2E runbook.

Co-Authored-By: GPT-6.1 Sol <noreply@openai.com>

* refactor(audit): parse bundled hook commands with a shell parser

The hand-written lexer for hook commands grew six similar quote and
paren scanners, and each review round found another shell form it
missed (comments after line continuations, nested backticks, `time -p`).
Parsing with mvdan.cc/sh/v3/syntax follows quoting, comments,
substitutions, loops, functions and heredocs the way bash does, so the
analyzer walks every call in the syntax tree instead. The wrapper table
(sudo, env, timeout, xargs, bash -c, git) and the POST and destination
rules are unchanged, now applied to unquoted argv words. A script fed to
a shell on stdin (`bash <<'EOF'`, `bash <<<`) is parsed like `bash -c`.

Statements before a syntax error are still inspected. bash runs some
forms the parser rejects (an array element assigned before a command),
so a rejected command also gets a word-level network check next to its
coverage gap, rather than dropping to MEDIUM.

The dependency adds about 0.26 MB to the release binary; vendorHash
follows the new go.sum.

* fix(audit): bound nested shell parsing and skip stdin data

A script nested in a substitution was inspected twice, once by reparsing
the outer shell's argument and once by walking the outer syntax tree, so
each `bash <<< "$(...)"` or `bash -c "$(...)"` level doubled the work and
a hook under 1 KB could stall an audit. Results are now remembered per
script text and depth, and one hook command may parse at most 1 MiB of
source in total, since deep nesting still costs quadratic time with the
cache alone. Past the budget the command is classified word by word and
gets a coverage gap, as a rejected command does.

Stdin was also treated as a script whenever a shell had a heredoc or
here-string, but `bash -c 'cat' <<<` or `bash ./script.sh <<<` hands it
to something else as data, which turned a lifecycle hook into a false
HIGH. Stdin is now parsed only for `-s`, or when there is neither `-c`
nor a script file operand. Option values (`-euo pipefail`, `-O extglob`,
`--rcfile f`) are not mistaken for a script file.

---------

Co-authored-by: GPT-6.1 Sol <noreply@openai.com>
Co-authored-by: sim <sim@example.invalid>
2026-11-06 13:56:53 +08:00

74 lines
3.0 KiB
AMPL

module skillshare
go 1.26.10
require (
github.com/charmbracelet/bubbles v1.0.0
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/glamour v0.10.0
github.com/charmbracelet/huh v0.8.0
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/charmbracelet/x/ansi v0.11.6
github.com/gofrs/flock v0.12.1
github.com/mattn/go-runewidth v0.0.19
github.com/modelcontextprotocol/go-sdk v1.8.0
github.com/muesli/termenv v0.16.0
github.com/pelletier/go-toml/v2 v2.2.4
github.com/pterm/pterm v0.12.82
github.com/sergi/go-diff v1.4.0
github.com/tailscale/hujson v0.0.0-20221223112325-20486734a56a
github.com/yuin/goldmark v1.7.17
golang.org/x/sys v0.48.0
golang.org/x/term v0.46.0
golang.org/x/text v0.42.0
gopkg.in/yaml.v3 v3.0.1
mvdan.cc/sh/v3 v3.14.1
)
require (
atomicgo.dev/cursor v0.2.0 // indirect
atomicgo.dev/keyboard v0.2.9 // indirect
atomicgo.dev/schedule v0.1.0 // indirect
github.com/alecthomas/chroma/v2 v2.14.0 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/catppuccin/go v0.3.0 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/exp/slice v0.0.0-20250327172914-2fdc97757edf // indirect
github.com/charmbracelet/x/exp/strings v0.0.0-20240722160745-212f7b056ed0 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/clipperhouse/uax29/v2 v2.5.0 // indirect
github.com/containerd/console v1.0.5 // indirect
github.com/dlclark/regexp2 v1.11.0 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/google/jsonschema-go v0.4.3 // indirect
github.com/gookit/color v1.5.4 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/lithammer/fuzzysearch v1.1.8 // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/microcosm-cc/bluemonday v1.0.27 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.16.0 // indirect
github.com/sahilm/fuzzy v0.1.1 // indirect
github.com/segmentio/asm v1.1.3 // indirect
github.com/segmentio/encoding v0.5.4 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
github.com/yuin/goldmark-emoji v1.0.5 // indirect
golang.org/x/net v0.60.0 // indirect
golang.org/x/oauth2 v0.35.0 // indirect
golang.org/x/sync v0.23.0 // indirect
golang.org/x/time v0.15.0 // indirect
)