Skip to content

Validate DorogayaSet input bounds - #82

Closed
krotname wants to merge 1 commit into
mainfrom
codex/fix-unchecked-input-in-dorogayaset
Closed

Validate DorogayaSet input bounds#82
krotname wants to merge 1 commit into
mainfrom
codex/fix-unchecked-input-in-dorogayaset

Conversation

@krotname

Copy link
Copy Markdown
Owner

Motivation

  • Prevent crashes and heap exhaustion when the CLI is fed malicious or malformed stdin by validating graph sizes and vertex IDs before allocating arrays or calling DSU operations.

Description

  • Add bounded limits MAX_VERTICES and MAX_EDGES and helper methods isValidGraph and isValidVertex to centralize validation.
  • Check graph validity at the start of solve(int, Edge[]) and validate n and m in run() before allocating Edge[], returning the existing failure result for invalid input.
  • While reading edges, check each endpoint and avoid invoking solve when any endpoint is out of range to prevent ArrayIndexOutOfBoundsException or large allocations.
  • Add two CLI regression test cases in AlgorithmCliTest covering a negative edge count and an out-of-range endpoint that both expect the existing failure message.

Testing

  • Ran the full test suite with mvn test and the build succeeded with all tests passing (Tests run: 548, Failures: 0, Errors: 0, Skipped: 0).
  • The updated algorithms.AlgorithmCliTest and algorithms.EmbeddedAlgorithmSelfChecksTest were exercised as part of the run and passed.

Codex Task

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 59.09091% with 9 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/main/java/algorithms/sprint6/DorogayaSet.java 59.09% 3 Missing and 6 partials ⚠️

📢 Thoughts on this report? Let us know!

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
69.2% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@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: d271178165

ℹ️ 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/sprint6/DorogayaSet.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-unchecked-input-in-dorogayaset 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