Repository navigation
fix(shell): close loop, eval, background-job and glob budget bypasses - #893
Merged
Merged
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.
Fixes the internal/shell findings from the second review of main at 19ff56a.
*syntax.CallExprnode (newRunnerConfig.LoopGuardhook), not by the__jb_loop_itername. A literal user call or function with that name fails validation. A dynamic call ($c) is now a normal command lookup that counts toward the command budget (it fails with command not found). Loop counts only use IDs the instrumenter created.RunnerConfig.NestedChunkTransformerrunscompileChunkon chunks parsed at run time, each with a fresh loop namespace. A budget violation inside one exits with 126; a validation error returns 2.exec > >(cat)hang (HIGH): a statement no longer waits for>(…)substitutions thatexeckeeps open. They are joined when the shell exits.exec 3< <(…)still works.Runner.StopJobscancels the background jobs, closes the shell side of each procsubst pipe, and joins every goroutine, all before the procsubst FS scope is restored. This fixes the data race onexec.FS.EstimateGlobOperationseach time a pathname expansion runs, through an optionalexpand.GlobBudgetCallbacksinterface. It raisesinterp.GlobLimitError(exit 126). The parse-time estimate is gone. Small change outside internal/shell:shell/expand/expand.go.evalandsourceframes count towardMaxFunctionDepth. No more than 256 background jobs can be live at once per shell family.kill -9 $$silently ignored (LOW): non-catchable signals now return an error (cannot send SIGKILL in the sandbox, status 1).coprocand mksh|&now fail validation with a clear error.The dedicated
__jb_prefix check is limited to the exact__jb_loop_itername, becauseinternal/runtimehas a test that allows (and charges) user commands with a__jb_prefix.SPEC.md: updated the budget implementation notes (guard identity, nested chunk compilation, runtime glob charging, eval/source depth, background job cap and joining, coproc and non-catchable kill).
Tests:
internal/shell/budget_review_test.gohas one regression test per finding.go test -race ./internal/shell/...andmake lintpass.