Skip to content

Harden Zip CLI against malformed and oversized input - #94

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-zip-cli-stdin-input-validation
Closed

Harden Zip CLI against malformed and oversized input#94
krotname wants to merge 1 commit into
mainfrom
codex/fix-zip-cli-stdin-input-validation

Conversation

@krotname

@krotname krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Motivation

  • The CLI entry point for algorithms.sprint0.Zip accepted unbounded sizes and input lines and trusted n and list contents, allowing EOF/NumberFormat/IndexOutOfBounds exceptions or large allocations from attacker-controlled stdin.
  • The change aims to make the CLI robust against malformed, short, or excessively large input while preserving the existing zip behavior for valid inputs.

Description

  • Add explicit limits (MAX_LIST_SIZE, MAX_INPUT_LINE_LENGTH) and validate n is within bounds before materializing lists.
  • Introduce process(BufferedReader, BufferedWriter) as a guarded CLI processing entry and have main catch and report IllegalArgumentException and EOFException instead of letting those exceptions crash the process.
  • Implement readBoundedLine to read lines character-by-character with length checks, and parseList to reuse Utils.readList on bounded input strings.
  • Add regression tests in ZipTest covering valid input, missing/short lists, oversized n, and overly long input lines.

Testing

  • Ran mvn -q -Dtest=algorithms.sprint0.ZipTest test and the test suite for Zip passed.
  • Ran mvn -q verify and the project verification completed successfully.

Codex Task

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e9aa16d5ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/algorithms/sprint0/Zip.java
@krotname

krotname commented Aug 1, 2026

Copy link
Copy Markdown
Owner Author

Закрываю как superseded by #116: изменения перенесены в одну проверенную ветку, все review findings учтены; локальный mvn verify прошёл полностью.

@krotname krotname closed this Aug 1, 2026
@krotname
krotname deleted the codex/fix-zip-cli-stdin-input-validation branch August 1, 2026 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant