fix: bound failure response output - #159
Open
sylvesterkaczmarek 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.
Summary
Apply the fixed response-size limit to structured failure output as well as successful output.
Problem
success()already falls back toreport_too_largewhen its serialized envelope exceedsMAX_REPORT_BYTES, butfailure()serialized and returned its envelope without the same bound.failure()andErrorDetail::field()are public, so a caller can construct error context large enough to bypass the response-size guarantee. An oversized command name can also make the normal fallback oversized.Evidence / reproduction
src/output.rson the base commit,success()serializes the envelope, compares its length withMAX_REPORT_BYTES, and substitutes areport_too_largeenvelope when necessary.failure()path simply returnsserialize_envelope(&envelope)with no size check.ErrorDetail::field()accepts caller-provided string data, andfailure()also accepts the command string, so the failure envelope has caller-controlled fields large enough to exceed the same fixed report limit.MAX_REPORT_BYTES, use it as the command and as anErrorDetailfield, then callfailure(...). The returnedCommandOutput.jsoncan exceedMAX_REPORT_BYTES, while an equivalent oversized success response is bounded.MAX_REPORT_BYTES, and carriesreport_too_large.The fallback uses the fixed command name
responsedeliberately. Reusing the caller-provided oversized command in the fallback would recreate the same oversized-output condition.Change
MAX_REPORT_BYTESreport_too_largeerror envelope when the original failure response exceeds the boundExisting bounded responses and exit codes are unchanged.