SIGN IN SIGN UP

Add glob limits and other hardening (#88)

* Add glob limits and other hardening

 1. Glob Operation Counter (maxGlobOperations: 100,000)

  - Added to src/shell/glob.ts - GlobExpander class tracks operations
  - Checks limit in expandSegments(), walkDirectory(), walkDirectoryMultiGlobstar()

  2. maxStringLength Limit (maxStringLength: 10,485,760 - 10MB)

  - Added to src/interpreter/expansion.ts
  - checkStringLength() helper validates string sizes after expansion
  - Throws ExecutionLimitError when exceeded

  3. maxArrayElements Limit (maxArrayElements: 100,000)

  - Added to src/interpreter/builtins/mapfile.ts - checks during line iteration
  - Added to src/interpreter/builtins/read.ts - checks for read -a

  4. maxHeredocSize Limit (maxHeredocSize: 10,485,760 - 10MB)

  - Added to src/parser/lexer.ts in readHeredocContent()
  - Throws LexerError when heredoc content exceeds limit

  5. Command Substitution Nesting Limit (maxSubstitutionDepth: 50)

  - Added to src/interpreter/expansion.ts
  - Tracks depth via ctx.substitutionDepth in InterpreterContext
  - Prevents deep $(...) nesting that could exhaust stack

  6. Null Byte Validation in Filesystems

  - Added validatePath() to src/fs/in-memory-fs/in-memory-fs.ts
  - Added validatePath() to src/fs/overlay-fs/overlay-fs.ts
  - Rejects paths containing null bytes with "path contains null byte" error

* Address comment
M
Malte Ubl committed
e05309e221d31c7c156c6d1bd9f8ad06b1ba479a
Parent: 7f3f7a4
Committed by GitHub <noreply@github.com> on 2/4/2026, 3:13:02 PM