Repository navigation
fix: executor keeps evidence, handles binary output, stops timed-out commands (Fixes #206) - #218
Merged
Merged
Conversation
…out commands (#206) - Output is decoded with errors="replace": one non-UTF-8 byte no longer turns a successful command into an error with no output. - Long output keeps the start AND the end with a "[truncated N characters]" marker (was: last 3000 chars only), plus stdout_truncated_chars. EXECUTOR_MAX_OUTPUT_CHARS (default 4000) and EXECUTOR_TIMEOUT_SEC (60). - run()/_exec() take timeout and max_output; containment evidence uses EVIDENCE_TIMEOUT_SEC (180) and EVIDENCE_MAX_OUTPUT_CHARS (1,000,000), so stored forensic evidence is no longer cut to a page. - Commands run in their own process group; on timeout the whole group is killed instead of being left running in the background. Fixes #206
Merged
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.
Fixes #206.
Problems
…[truncated N characters]…in between andstdout_truncated_charsin the result. Size set byEXECUTOR_MAX_OUTPUT_CHARS(default 4000).kubectl logs --tail=2000,describeand pod YAML were stored cut down to 3000 charactersmax_output=EVIDENCE_MAX_OUTPUT_CHARS(1,000,000) andtimeout=EVIDENCE_TIMEOUT_SEC(180). It's stored, not sent to the model.dmesg)UnicodeDecodeError, so a successful command came back as an error with no outputerrors="replace"timeoutper call orEXECUTOR_TIMEOUT_SEC. Commands run in their own process group, and the whole group is killed on timeout, children included.Changes
tools/executor.py:clip_output(): about a quarter of the limit for the start and the rest for the end.run(..., timeout=, max_output=)and_exec(...). The keyword arguments are only passed through when set, so existing fakes of_exec(command, host)keep working.start_new_session=Trueandos.killpgon timeout.tools/containment.py: evidence capture asks for the full output and a longer timeout..env.example: the four new settings.Tests
tests/test_executor_output.py, 9 tests, using real subprocesses:printf '\377\376'succeeds.seq 1 20000keeps the first and last lines and shows the marker; with an evidence-size limit it's kept whole; the env setting changes the limit.sh -c 'sleep 2; touch marker'withtimeout=1returns in under 4s, and the marker is never created, so the child was killed.Full suite: 1457 passed, 4 skipped. Flake8 (CI selection) and bandit are clean.