Files
ObsidianDragon/src/ui/windows/console_tab_helpers.h
T
DanSandClaude Opus 4.8 83ce73f26b security(console): mask key-dump command RESULTS in the scrollback
The console redacted secret command ARGS but showed the OUTPUT of key-revealing
commands (dumpprivkey / z_exportkey / z_exportviewingkey / z_exportmnemonic /
dumpwallet / z_exportwallet, and the lite seed/export verbs) in full — visible
in the scrollback, Copy All, Ctrl+C and the filter. Now, when the submitted
command is key-revealing, its result is held ONLY in a member buffer (never in
the scrollback model, so Copy-All etc. can't leak it) and a masked placeholder
is shown. An explicit "Copy secret" button routes through the auto-clearing
clipboard; the buffer auto-wipes after 60s, on Clear, and on wallet lock
(via wipeDisplayedSecrets). The command string passed to the executor is
byte-identical. New pure helper ConsoleCommandRevealsSecret is unit-testable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-10-19 11:39:38 -05:00

44 lines
2.3 KiB
C++

#pragma once
#include <string>
namespace dragonx {
namespace ui {
float ComputeConsoleInputHeight(float frameHeightWithSpacing,
float itemSpacingY,
float spacingSm,
float spacingXs,
float cursorOffset);
float ComputeConsoleOutputHeight(float availableHeight,
float inputHeight,
float minHeight,
float minHeightRatio);
float ClampConsoleWrapWidth(float contentWidth, float paddingX);
// The console's daemon-error line prints once per error: on entering the Error state, when the
// reason changes while still in it, or when the daemon crashed again meanwhile (the console only polls
// while its tab is shown, so it can miss the Running state between two identical crashes). It used to
// print on every poll, i.e. every frame, while in Error.
bool ShouldPrintDaemonErrorLine(bool wasError, bool isError,
const std::string& error, const std::string& lastPrinted,
bool newUnexpectedExit = false);
// True if `cmd`'s first token names a console/RPC command that carries a SECRET on its command line
// (passphrase, private/spending/viewing key, mnemonic). Output-secret commands (dumpprivkey,
// z_exportkey, z_exportmnemonic) are NOT covered — their secret is in the result, a separate concern.
bool ConsoleCommandCarriesSecret(const std::string& cmd);
// True when the command's RESULT (not its args) reveals key material — dumpprivkey / z_exportkey /
// z_exportviewingkey / z_exportmnemonic / dumpwallet / z_exportwallet on the full node, or the lite
// `seed` / `export` verbs. Used to mask the output in the console scrollback. `fullNode` selects the
// command set (the bare lite verbs `seed`/`export` must not match full-node commands).
bool ConsoleCommandRevealsSecret(const std::string& cmd, bool fullNode);
// A display/history-safe copy of `cmd`: the command name with its arguments replaced by "****" when
// it carries a secret, else `cmd` unchanged. The real command is still executed unredacted.
std::string RedactConsoleCommand(const std::string& cmd);
} // namespace ui
} // namespace dragonx