mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
Qt/RPCConsole: Refactor command_may_contain_sensitive_data function out of RPCConsole::on_lineEdit_returnPressed
This commit is contained in:
parent
de8980df9d
commit
afde12f265
@ -63,14 +63,28 @@ const struct {
|
|||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
// don't add private key handling cmd's to the history
|
// don't add private key handling cmd's to the history
|
||||||
const QStringList RPCConsole::historyFilter = QStringList()
|
const QStringList historyFilter = QStringList()
|
||||||
<< "importprivkey"
|
<< "importprivkey"
|
||||||
<< "signrawtransaction"
|
<< "signrawtransaction"
|
||||||
<< "walletpassphrase"
|
<< "walletpassphrase"
|
||||||
<< "walletpassphrasechange"
|
<< "walletpassphrasechange"
|
||||||
<< "encryptwallet";
|
<< "encryptwallet";
|
||||||
|
|
||||||
|
bool command_may_contain_sensitive_data(const QString cmd)
|
||||||
|
{
|
||||||
|
Q_FOREACH(QString unallowedCmd, historyFilter) {
|
||||||
|
if (cmd.trimmed().startsWith(unallowedCmd)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* 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
|
||||||
@ -764,15 +778,7 @@ void RPCConsole::on_lineEdit_returnPressed()
|
|||||||
message(CMD_REQUEST, cmd);
|
message(CMD_REQUEST, cmd);
|
||||||
Q_EMIT cmdRequest(cmd);
|
Q_EMIT cmdRequest(cmd);
|
||||||
|
|
||||||
bool storeHistory = true;
|
bool storeHistory = !command_may_contain_sensitive_data(cmd);
|
||||||
Q_FOREACH(QString unallowedCmd, historyFilter)
|
|
||||||
{
|
|
||||||
if (cmd.trimmed().startsWith(unallowedCmd))
|
|
||||||
{
|
|
||||||
storeHistory = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (storeHistory)
|
if (storeHistory)
|
||||||
{
|
{
|
||||||
|
@ -140,7 +140,6 @@ 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;
|
||||||
|
Loading…
Reference in New Issue
Block a user