Harden Bash tool: preflight sanitizer for Windows portability and inline-source guards, plus output truncation#318
Open
mmprotest wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
bashexecution usedcmd.exesemantics and Unix utilities or PowerShell cmdlets were being mixed incorrectly.python -cand here-string style commands caused brittle quoting/terminator failures and long feedback thrash.| headto limit output, which should be handled by the runner instead of by agent-inserted Unix toolchains.Description
_preflight_shell_commandinvillani_code/tools.pythat rejects brittle inline source-writing patterns (long or multi-linepython -c, here-strings, large inline redirects) with an actionable recovery hint.| head,| tail,grep,sed, heredocs,cat >,rm -rf,touch,pwd) when running under awin*platform, and detect PowerShell cmdlets used without an explicit PowerShell invocation.MODEL_OUTPUT_CHAR_LIMIT) returning a truncated model-facingstdout/stderrwith markers like[stdout truncated to N chars]while preserving full outputs in debug callback payloads and settingtruncatedappropriately.Write/Patchfor file edits and simpler Bash commands; updated tests intests/test_tools_hardening.pyto cover the new guards.Testing
pytest -q tests/test_tools_hardening.pyand all tests passed (8 passed) validating sanitizer behavior and truncation.pytest -q tests/test_tools_schema.pyand it passed (1 passed).villani_code/tools.pyandtests/test_tools_hardening.py.Codex Task