Qt/RPCConsole: Don't store commands with potentially sensitive information in the history

Filters importprivkey, signrawtransaction, walletpassphrase, walletpassphrasechange, and encryptwallet
This commit is contained in:
Jonas Schnelli authored and Luke Dashjr committed 2016-12-29 11:43:28 +00:00
1 parent fc95daa97f
commit 9044908636
2 files changed
+20

No files matched your search

+19
View File
@@ -63,6 +63,14 @@ const struct {
{NULL, NULL} {NULL, NULL}
}; };
// don't add private key handling cmd's to the history
const QStringList RPCConsole::historyFilter = QStringList()
<< "importprivkey"
<< "signrawtransaction"
<< "walletpassphrase"
<< "walletpassphrasechange"
<< "encryptwallet";
/* Object for executing console RPC commands in a separate thread. /* Object for executing console RPC commands in a separate thread.
*/ */
class RPCExecutor : public QObject class RPCExecutor : public QObject
@@ -755,6 +763,16 @@ void RPCConsole::on_lineEdit_returnPressed()
message(CMD_REQUEST, cmd); message(CMD_REQUEST, cmd);
Q_EMIT cmdRequest(cmd); Q_EMIT cmdRequest(cmd);
bool storeHistory = true;
Q_FOREACH(QString unallowedCmd, historyFilter)
{
if (cmd.trimmed().startsWith(unallowedCmd))
storeHistory = false; break;
}
if (storeHistory)
{
// Remove command, if already in history // Remove command, if already in history
history.removeOne(cmd); history.removeOne(cmd);
// Append command to history // Append command to history
@@ -764,6 +782,7 @@ void RPCConsole::on_lineEdit_returnPressed()
history.removeFirst(); history.removeFirst();
// Set pointer to end of history // Set pointer to end of history
historyPtr = history.size(); historyPtr = history.size();
}
// Scroll console view to end // Scroll console view to end
scrollToEnd(); scrollToEnd();
} }
+1
View File
@@ -140,6 +140,7 @@ private:
ClientModel *clientModel; ClientModel *clientModel;
QStringList history; QStringList history;
int historyPtr; int historyPtr;
const static QStringList historyFilter;
QString cmdBeforeBrowsing; QString cmdBeforeBrowsing;
QList<NodeId> cachedNodeids; QList<NodeId> cachedNodeids;
const PlatformStyle *platformStyle; const PlatformStyle *platformStyle;