fix(cli): escape hostile values in generated init artifacts - #249
Conversation
Quote doctor workflow names for YAML, JSON-encode check allowlist entries, and escape default-branch metacharacters before they reach protect-branch regexes. Adds regression tests for branch names, workflow titles, and shell commands that used to break parsing silently.
adrian-lorenzo
left a comment
There was a problem hiding this comment.
Thanks for the contribution!
The new encoders fix the specific YAML, JSON, and regex cases, but the default branch is still interpolated directly into privileged workflow shell source. $(id) is a valid Git branch name, and generating the workflows with it produces git show "origin/$(id):..." and ?ref=$(id), both of which execute command substitution.
Please treat the branch as data in every generated workflow: encode YAML fields appropriately and pass it into shell steps through an environment variable rather than embedding it in command text. Apply the fix to both renderers and add a regression using hostile but valid refs such as $(id) and foo"bar. The import-order formatting failure also needs correcting.
Once every output context is covered, this will be a strong security fix.
Refine the project sidebar, Product Owner composer copy, and extension-safe hydration behavior.
BREAKING CHANGE: The Facility CLI now requires Node.js 22.13.0 or Node.js 24.
Address review on theam#249: hostile but valid refs like $(id) and foo"bar must never land in privileged run scripts. YAML contexts use quoted scalars; shell steps read FACILITY_DEFAULT_BRANCH instead.
Address review on theam#249: hostile but valid refs like $(id) and foo"bar must never land in privileged run scripts. YAML contexts use quoted scalars; shell steps read FACILITY_DEFAULT_BRANCH instead.
|
Addressed review: default branch is now passed through |
52a3b42 to
e4bc3d0
Compare
Fixes #228.
Summary
CI: Build) parse correctly..claude/settings.jsonso shell commands with quotes stay valid JSON.protect-branch.mjsregexes (e.g.release/2026).Mirrors the escaping in both
packages/cli/src/init.mjsandpackages/core/src/render.ts.Test plan
pnpm --filter @theagilemonkeys/facility testpnpm --filter @facility/core test