mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 12:01:13 +00:00
* feat(terminal): configurable su/sudo password prompt assist (#2156) Extend the existing confirm-to-fill sudo assist to arm on su as well, and add a Terminal setting for off / quick Enter fill / WindTerm-like credential picker. Picker candidates come from the host password plus keychain password identities; secrets are never shown in the list or sent without confirmation. * fix(terminal): tighten password prompt assist after codex review - Hint mode only uses the session host password, never an arbitrary keychain identity as a silent Enter target. - Build autofill candidates from the effective session host so group- inherited passwords participate. - Clear a stale credential picker when the session disconnects. * fix(terminal): more password-assist polish from codex review - Do not swallow arrow keys while the quick-fill hint is pending; only the multi-credential picker consumes them. - Clear the picker overlay on hibernate and wake so it cannot outlive the autofill controller. - Show the resolved auth username on the host candidate row (identityId / group identity), not a stale host.username after password dedupe. * fix(terminal): keep password picker select callback stable Avoid forcing TerminalView memo invalidation on every Terminal render by using a stable useCallback for credential selection. * fix(terminal): do not offer full keychain on unarmed sudo prompts Picker mode only lists all password identities after a real su/sudo command was armed. Unarmed explicit [sudo] lines still get host-password quick-fill only, blocking remote prompt phishing of other credentials. * fix(terminal): fix picker mode switch and armed picker test Arm before inspecting the picker payload, and when switching settings mid-prompt recompute whether the command arm is still valid so picker mode can open the full list. * fix(terminal): reopen password picker after a wrong credential Keep the su/sudo arm active after confirm-to-fill so a rejected password re-prompt can offer the full credential list again instead of falling back to host-only unarmed assist. * fix(terminal): only re-assist real auth retries after fill Keep a short post-fill arm for wrong-password re-prompts, but require an explicit [sudo] line or authentication-failure text before reopening assist. Prevents sending the host password into child prompts after a successful sudo (e.g. sudo mysql -p). * fix(terminal): scope sudo assist away from child password prompts Track whether the armed command was sudo or su. su still accepts bare Password: lines; sudo only assists on [sudo] tags or user-scoped prompts (password for … / 输入密码), not generic Enter password when sudo is cached. * fix(terminal): tighten when the full credential picker may open Exclude child-program prompts (Enter password, Password for user …). Full keychain picker only for explicit [sudo] lines or armed su Password: prompts; Kylin-style sudo bare prompts still get host-password hint only. * fix(terminal): limit full credential picker to armed su only Multi-identity picker is the WindTerm-style su workflow (#2156). Sudo keeps host-password quick-fill only, so a cached sudo child cannot open the full keychain list via a forged or nested password prompt. * fix(terminal): derive password assist candidates in Terminal + mode gate - Standalone Terminal popups without TerminalLayer now resolve candidates from host/keys/identities so su picker mode still works. - When switching to picker mid-prompt, keep the su-only full-list gate (do not open multi-identity list for an armed sudo prompt). * fix(terminal): reject SSH-style prompts for su assist and drop dupe keys - su bare matching only accepts short Password:/密码 lines, not user@host SSH password prompts after passwordless su -c. - Remove duplicate sudoAutofillCandidates keys that failed eslint. * fix(terminal): cursor-anchor password picker and soft-dismiss Esc Position the su credential picker with the same cursor-relative layout helpers as autocomplete instead of fixed bottom-center. Esc only closes the UI while keeping the arm so Esc/arrows can reopen the list on the same Password: prompt.
117 lines
3.7 KiB
TypeScript
117 lines
3.7 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import React from "react";
|
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
|
|
import { TerminalLayerWorkspaceSection } from "./TerminalLayerWorkspaceSection.tsx";
|
|
|
|
test("workspace section passes resolved session host ids to terminal panes", () => {
|
|
const resolvedSessionHostIds = new Set(["session-1"]);
|
|
let sawResolvedIds = false;
|
|
|
|
const TerminalPanesHost = (props: { resolvedSessionHostIds?: Set<string> }) => {
|
|
sawResolvedIds = true;
|
|
assert.equal(props.resolvedSessionHostIds, resolvedSessionHostIds);
|
|
assert.equal(props.resolvedSessionHostIds?.has("session-1"), true);
|
|
return null;
|
|
};
|
|
|
|
const ref = { current: null };
|
|
const noop = () => {};
|
|
const ctx = {
|
|
workspaceInnerRef: ref,
|
|
workspaceOverlayRef: ref,
|
|
draggingSessionId: null,
|
|
isFocusMode: false,
|
|
dropHint: null,
|
|
setDropHint: noop,
|
|
computeSplitHint: () => null,
|
|
handleWorkspaceDrop: noop,
|
|
TerminalPanesHost,
|
|
sessions: [],
|
|
sessionHostsMap: new Map(),
|
|
sessionChainHostsMap: new Map(),
|
|
sessionSudoAutofillPasswordsMap: new Map(),
|
|
sessionSudoAutofillCandidatesMap: new Map(),
|
|
resolvedSessionHostIds,
|
|
workspaceById: new Map(),
|
|
workspaceRectsById: new Map(),
|
|
isTerminalLayerVisible: true,
|
|
workspaceFocusHandlersRef: { current: new Map() },
|
|
workspaceBroadcastHandlersRef: { current: new Map() },
|
|
splitHorizontalHandlersRef: { current: new Map() },
|
|
splitVerticalHandlersRef: { current: new Map() },
|
|
themePreview: { targetSessionId: null, targetHostId: null, globalPreview: false, themeId: null },
|
|
keys: [],
|
|
identities: [],
|
|
snippets: [],
|
|
knownHosts: [],
|
|
terminalFontFamilyId: "default",
|
|
fontSize: 14,
|
|
terminalTheme: {},
|
|
followAppTerminalTheme: false,
|
|
accentMode: "theme",
|
|
customAccent: "",
|
|
terminalSettings: {},
|
|
hotkeyScheme: "mac",
|
|
disableTerminalFontZoom: false,
|
|
restoreTerminalCwd: false,
|
|
keyBindings: [],
|
|
resizing: null,
|
|
isComposeBarOpen: false,
|
|
sessionLogConfig: undefined,
|
|
sshDebugLogsEnabled: false,
|
|
onHotkeyAction: noop,
|
|
handleTerminalFontSizeChange: noop,
|
|
handleOpenSftp: noop,
|
|
handleTerminalCwdChange: noop,
|
|
handleTerminalTitleChange: noop,
|
|
handleTerminalBell: noop,
|
|
handleTerminalOutput: noop,
|
|
handleOpenScripts: noop,
|
|
handleOpenHistory: noop,
|
|
handleOpenSystem: noop,
|
|
handleOpenTheme: noop,
|
|
handleCloseSession: noop,
|
|
handleStatusChange: noop,
|
|
handleSessionExit: noop,
|
|
handleTerminalDataCapture: noop,
|
|
handleOsDetected: noop,
|
|
handleUpdateHost: noop,
|
|
handleAddKnownHost: noop,
|
|
handleCommandExecuted: noop,
|
|
handleCommandSubmitted: noop,
|
|
onSetWorkspaceFocusedSession: noop,
|
|
onSplitSession: noop,
|
|
isBroadcastEnabled: () => false,
|
|
handleBroadcastInput: noop,
|
|
handleBroadcastInterruptPriorityChange: noop,
|
|
handleToggleWorkspaceComposeBar: noop,
|
|
handleSnippetExecutorChange: noop,
|
|
handleProgrammaticCommandLogRewriteChange: noop,
|
|
handleAddSelectionToAI: noop,
|
|
activeResizers: [],
|
|
activeWorkspace: null,
|
|
composeBarThemeColors: null,
|
|
findSplitNode: () => null,
|
|
focusedSessionId: null,
|
|
handleComposeSend: noop,
|
|
handleSnippetFromPanel: noop,
|
|
refocusTerminalSession: noop,
|
|
setIsComposeBarOpen: noop,
|
|
setResizing: noop,
|
|
TerminalComposeBar: () => null,
|
|
Array,
|
|
cn: (...values: unknown[]) => values.filter(Boolean).join(" "),
|
|
onStartSessionRename: noop,
|
|
onRemoveSessionFromWorkspace: noop,
|
|
onReorderTabs: noop,
|
|
onStartSessionDrag: noop,
|
|
onEndSessionDrag: noop,
|
|
};
|
|
|
|
renderToStaticMarkup(React.createElement(TerminalLayerWorkspaceSection, { ctx }));
|
|
|
|
assert.equal(sawResolvedIds, true);
|
|
});
|