Skip to content

fix(interp): add fast pre-check for heredoc size limit#185

Merged
julesmcrt merged 2 commits intomainfrom
jules.macret/fix/TestPentestHeredocSizeLimitRegular
Apr 16, 2026
Merged

fix(interp): add fast pre-check for heredoc size limit#185
julesmcrt merged 2 commits intomainfrom
jules.macret/fix/TestPentestHeredocSizeLimitRegular

Conversation

@julesmcrt
Copy link
Copy Markdown
Collaborator

Summary

  • Fix TestPentestHeredocSizeLimitRegular CI flake — for regular << heredocs, expandWord() on 10 MiB of content is slow enough under the race detector to exceed the test's 5-second context timeout, producing empty stderr instead of the expected "exceeds maximum size" error.
  • Add hdocWordRawSize() pre-check — computes the total byte count of literal parts in the parsed heredoc word (O(n), no allocation). If the raw literals already exceed MaxHeredocBytes, the heredoc is rejected immediately before the expensive expansion pass.
  • The <<- variant was unaffected because it already checks size incrementally per-line.

Test plan

  • TestPentestHeredocSizeLimitRegular passes locally (was timing out in CI)
  • TestPentestHeredocSizeLimitDash still passes
  • TestPentestHeredocSizeLimitUnderLimit still passes (heredoc just under limit succeeds)
  • All interp/tests pass with -race
  • All scenario tests pass with -race

🤖 Generated with Claude Code

For regular << heredocs, expandWord() on the full content is expensive
under the race detector, causing TestPentestHeredocSizeLimitRegular to
exceed its 5s timeout in CI. Add hdocWordRawSize() to compute the raw
literal byte count before expansion — if it already exceeds
MaxHeredocBytes, reject immediately without expanding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt marked this pull request as ready for review April 16, 2026 12:43
The 5-second context was created before parsing, so parsing a 10 MiB
heredoc under the race detector consumed the entire timeout before
execution could start. Move parsing into pentestRedirRun before the
context is created, so the timeout only covers execution.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@julesmcrt julesmcrt added this pull request to the merge queue Apr 16, 2026
Merged via the queue into main with commit f7f06d3 Apr 16, 2026
34 checks passed
@julesmcrt julesmcrt deleted the jules.macret/fix/TestPentestHeredocSizeLimitRegular branch April 16, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants