Skip to content

auto-complete tests#1989

Merged
dgageot merged 1 commit intodocker:mainfrom
gtardif:auto_complete_tests
Mar 9, 2026
Merged

auto-complete tests#1989
dgageot merged 1 commit intodocker:mainfrom
gtardif:auto_complete_tests

Conversation

@gtardif
Copy link
Contributor

@gtardif gtardif commented Mar 9, 2026

No description provided.

@gtardif gtardif requested a review from a team as a code owner March 9, 2026 08:01
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Review Summary

Assessment: 🔴 CRITICAL

4 critical issues found - Index out of bounds vulnerabilities in test code

This PR adds autocomplete tests but contains critical bugs that will cause test panics if the autocomplete output doesn't match the expected format. All issues involve accessing slice indices without bounds checking after splitting stdout by newlines.

Critical Issues

The lines() helper function uses strings.Split(s, "\n"), which always returns at least a 1-element slice, but the tests access indices 1, 2, and 3 without verifying the slice has enough elements. If autocomplete returns fewer lines than expected, these tests will panic rather than fail gracefully.

Recommendation: Add length validation before accessing slice indices, for example:

props := lines(res.Stdout)
require.Len(t, props, 4, "expected 4 autocomplete options")
require.Contains(t, props[0], "a2a")
require.Contains(t, props[1], "acp")
require.Contains(t, props[2], "api")
require.Contains(t, props[3], "mcp")

Files Reviewed

  • ✅ e2e/binary/shellout.go - No issues
  • ❌ e2e/binary/binary_test.go - 4 critical issues

This review focuses only on bugs in the changed code. Style and existing code are not evaluated.

@gtardif gtardif force-pushed the auto_complete_tests branch 2 times, most recently from 5b332a8 to 4c5cf92 Compare March 9, 2026 08:52
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
@gtardif gtardif force-pushed the auto_complete_tests branch from 4c5cf92 to ff1d117 Compare March 9, 2026 09:08
@dgageot dgageot merged commit 6ddc0ce into docker:main Mar 9, 2026
5 checks passed
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