Skip to content

fix: preserve built-in login prompts with custom rules (v0.1.2) - #16

Merged
LeeEirc merged 1 commit into
masterfrom
fix/additive-login-prompts
Nov 4, 2026
Merged

LeeEirc merged 1 commit into
masterfrom
fix/additive-login-prompts

Conversation

@LeeEirc

@LeeEirc LeeEirc commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Why

Koko's historical platform configuration added custom login patterns without disabling standard prompts. In v0.1.0 and v0.1.1, a custom username, password, or shell expression replaced the built-in matcher, so one shared configuration could stop recognizing otherwise supported devices.

This change prioritizes connection compatibility while retaining the current stream handling and diagnostic precedence.

Changes

  • Make UsernamePrompt, PasswordPrompt, and ShellPrompt supplement the built-in matcher: either branch can recognize the prompt.
  • Keep ordinary regexp.Match semantics, explicit anchors, and case flags. Expressions are not rewritten, and no matching-mode parameter is added.
  • Keep the complete built-in shell matcher, including its shape, length, and banner checks.
  • Recognize a bounded set of bare username/password words on completed CRLF/LF lines. Existing colon-terminated prompts and explicit custom expressions still work without a newline.
  • Keep FailurePrompt, PasswordChangePrompt, and ContinuePrompt replacement behavior, diagnostic completion/precedence, UTF-8 checks, line limits, and session-data preservation.
  • Update configuration comments, README, stream documentation, and migration notes.

Why bare defaults require a completed line

A read ending at User may continue as Username:; a read ending at Password may continue as Password expired policy: disabled. Acting on those prefixes can consume a prompt early, send credentials prematurely, or report a repeated-prompt failure.

The new bare defaults therefore wait for CRLF/LF. Devices that deliberately wait at a bare prompt without a newline can use an explicit expression such as (?i)^Password$. No extra timer or delay is introduced.

Compatibility and Koko integration

  • A custom expression now adds recognition for username, password, and shell events; it cannot disable their built-in alternatives. Anchors limit only the custom branch. For example, ShellPrompt: ^READY>$ also accepts a built-in router# prompt.
  • Callers no longer need to copy built-in rules, combine expressions, or add .* wrappers.
  • Broad built-in success keywords such as Last login, success, and 成功 are not restored.
  • Koko should retain its exact known legacy-default migration and application-side validation of expressions that match the empty string.
  • This PR changes the library. It does not claim to have modified or tested Koko's separate adapter branch, or to reproduce every behavior of the old library.

Release intent

This PR updates VERSION and the changelog to v0.1.2. Merging into master starts the existing release workflow; publication proceeds only after its checks pass. Opening the PR does not publish a release.

Validation

  • go test -race -timeout=3m ./... passed.

  • go vet ./... passed.

  • All 13 release-target tests passed with VERSION=v0.1.2.

  • Targeted regression tests and git diff --check passed.

  • Six new regression groups cover all eight built-in/custom combinations across four read sizes, ANSI normalization and preserved session data, completed-line bare prompts, fragmented prompt/banner prefixes, explicit custom prompts without newlines, built-in shell boundaries, and diagnostic precedence.

  • Existing six-field regexp tests now distinguish the three supplemental fields from the three replacement fields.

  • Independent implementation, test, and documentation review found no blocking issues.

  • All five PR CI jobs passed for 03942085c25981daf3dc2f07d1f7fd1d546c2055: Linux/Windows × Go 1.20.x/stable and the release snapshot. Race tests, vet, Linux PTY/TCP checks, release archive checksums, and the extracted Linux CLI smoke checks passed.

  • GitHub automatically requested Copilot review, but Copilot reported insufficient account quota and did not produce a code review. Independent review completed with no blocking findings.

Copilot AI balanced review requested due to automatic review settings November 4, 2026 09:06

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@LeeEirc
LeeEirc merged commit ca959b8 into master Nov 4, 2026
5 checks passed
@LeeEirc
LeeEirc deleted the fix/additive-login-prompts branch November 4, 2026 09:35
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