Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve log scrubbing: #2358

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Builds/VisualStudio2015/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3091,10 +3091,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\rpc\handlers\WalletPropose.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\rpc\handlers\WalletSeed.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\rpc\impl\Handler.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
Expand Down
3 changes: 0 additions & 3 deletions Builds/VisualStudio2015/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -3717,9 +3717,6 @@
<ClInclude Include="..\..\src\ripple\rpc\handlers\WalletPropose.h">
<Filter>ripple\rpc\handlers</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\rpc\handlers\WalletSeed.cpp">
<Filter>ripple\rpc\handlers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\rpc\impl\Handler.cpp">
<Filter>ripple\rpc\impl</Filter>
</ClCompile>
Expand Down
4 changes: 0 additions & 4 deletions src/ripple/basics/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,6 @@ class Logs
maximumMessageCharacters = 12 * 1024
};

static
std::string
scrub (std::string s);

static
void
format (std::string& output, std::string const& message,
Expand Down
55 changes: 34 additions & 21 deletions src/ripple/basics/impl/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,26 +289,6 @@ Logs::fromString (std::string const& s)
return lsINVALID;
}

// Replace the first secret, if any, with asterisks
std::string
Logs::scrub (std::string s)
{
using namespace std;
char const* secretToken = "\"secret\"";
// Look for the first occurrence of "secret" in the string.
size_t startingPosition = s.find (secretToken);
if (startingPosition != string::npos)
{
// Found it, advance past the token.
startingPosition += strlen (secretToken);
// Replace the next 35 characters at most, without overwriting the end.
size_t endingPosition = std::min (startingPosition + 35, s.size () - 1);
for (size_t i = startingPosition; i < endingPosition; ++i)
s [i] = '*';
}
return s;
}

void
Logs::format (std::string& output, std::string const& message,
beast::severities::Severity severity, std::string const& partition)
Expand All @@ -334,13 +314,46 @@ Logs::format (std::string& output, std::string const& message,
case kFatal: output += "FTL "; break;
}

output += scrub (message);
output += message;

// Limit the maximum length of the output
if (output.size() > maximumMessageCharacters)
{
output.resize (maximumMessageCharacters - 3);
output += "...";
}

// Attempt to prevent sensitive information from appearing in log files by
// redacting it with asterisks.
auto scrubber = [&output](char const* token)
{
auto first = output.find(token);

// If we have found the specified token, then attempt to isolate the
// sensitive data (it's enclosed by double quotes) and mask it off:
if (first != std::string::npos)
{
first = output.find ('\"', first + std::strlen(token));

if (first != std::string::npos)
{
auto last = output.find('\"', ++first);

if (last == std::string::npos)
last = output.size();

output.replace (first, last - first, last - first, '*');
}
}
};

scrubber ("\"seed\"");
scrubber ("\"seed_hex\"");
scrubber ("\"secret\"");
scrubber ("\"master_key\"");
scrubber ("\"master_seed\"");
scrubber ("\"master_seed_hex\"");
scrubber ("\"passphrase\"");
}

//------------------------------------------------------------------------------
Expand Down
12 changes: 0 additions & 12 deletions src/ripple/net/impl/RPCCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,17 +1000,6 @@ class RPCParser
return jvRequest;
}

// wallet_seed [<seed>|<passphrase>|<passkey>]
Json::Value parseWalletSeed (Json::Value const& jvParams)
{
Json::Value jvRequest{Json::objectValue};

if (jvParams.size ())
jvRequest[jss::secret] = jvParams[0u].asString ();

return jvRequest;
}

// parse gateway balances
// gateway_balances [<ledger>] <issuer_account> [ <hotwallet> [ <hotwallet> ]]

Expand Down Expand Up @@ -1138,7 +1127,6 @@ class RPCParser
{ "validation_seed", &RPCParser::parseValidationSeed, 0, 1 },
{ "version", &RPCParser::parseAsIs, 0, 0 },
{ "wallet_propose", &RPCParser::parseWalletPropose, 0, 1 },
{ "wallet_seed", &RPCParser::parseWalletSeed, 0, 1 },
{ "internal", &RPCParser::parseInternal, 1, -1 },

// Evented methods
Expand Down
9 changes: 4 additions & 5 deletions src/ripple/protocol/JsonFields.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ JSS ( account_objects ); // out: AccountObjects
JSS ( account_root ); // in: LedgerEntry
JSS ( accounts ); // in: LedgerEntry, Subscribe,
// handlers/Ledger, Unsubscribe
// out: WalletAccounts
JSS ( accounts_proposed ); // in: Subscribe, Unsubscribe
JSS ( action );
JSS ( acquiring ); // out: LedgerRequest
Expand Down Expand Up @@ -139,7 +138,7 @@ JSS ( dbKBTotal ); // out: getCounts
JSS ( dbKBTransaction ); // out: getCounts
JSS ( debug_signing ); // in: TransactionSign
JSS ( delivered_amount ); // out: addPaymentDeliveredAmount
JSS ( deprecated ); // out: WalletSeed
JSS ( deprecated ); // out
JSS ( descending ); // in: AccountTx*
JSS ( destination_account ); // in: PathRequest, RipplePathFind, account_lines
// out: AccountChannels
Expand Down Expand Up @@ -217,7 +216,7 @@ JSS ( issuer ); // in: RipplePathFind, Subscribe,
// out: paths/Node, STPathSet, STAmount
JSS ( jsonrpc ); // json version
JSS ( jq_trans_overflow ); // JobQueue transaction limit overflow.
JSS ( key ); // out: WalletSeed
JSS ( key ); // out
JSS ( key_type ); // in/out: WalletPropose, TransactionSign
JSS ( latency ); // out: PeerImp
JSS ( last ); // out: RPCVersion
Expand Down Expand Up @@ -370,10 +369,10 @@ JSS ( role ); // out: Ping.cpp
JSS ( rt_accounts ); // in: Subscribe, Unsubscribe
JSS ( sanity ); // out: PeerImp
JSS ( search_depth ); // in: RipplePathFind
JSS ( secret ); // in: TransactionSign, WalletSeed,
JSS ( secret ); // in: TransactionSign,
// ValidationCreate, ValidationSeed,
// channel_authorize
JSS ( seed ); // in: WalletAccounts, out: WalletSeed
JSS ( seed ); //
JSS ( seed_hex ); // in: WalletPropose, TransactionSign
JSS ( send_currencies ); // out: AccountCurrencies
JSS ( send_max ); // in: PathRequest, RipplePathFind
Expand Down
6 changes: 0 additions & 6 deletions src/ripple/rpc/handlers/Handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ Json::Value doRandom (RPC::Context&);
Json::Value doRipplePathFind (RPC::Context&);
Json::Value doServerInfo (RPC::Context&); // for humans
Json::Value doServerState (RPC::Context&); // for machines
Json::Value doSessionClose (RPC::Context&);
Json::Value doSessionOpen (RPC::Context&);
Json::Value doSign (RPC::Context&);
Json::Value doSignFor (RPC::Context&);
Json::Value doStop (RPC::Context&);
Expand All @@ -80,11 +78,7 @@ Json::Value doUnlList (RPC::Context&);
Json::Value doUnsubscribe (RPC::Context&);
Json::Value doValidationCreate (RPC::Context&);
Json::Value doValidationSeed (RPC::Context&);
Json::Value doWalletLock (RPC::Context&);
Json::Value doWalletPropose (RPC::Context&);
Json::Value doWalletSeed (RPC::Context&);
Json::Value doWalletUnlock (RPC::Context&);
Json::Value doWalletVerify (RPC::Context&);
Json::Value doValidators (RPC::Context&);
Json::Value doValidatorListSites (RPC::Context&);
} // ripple
Expand Down
54 changes: 0 additions & 54 deletions src/ripple/rpc/handlers/WalletSeed.cpp

This file was deleted.

1 change: 0 additions & 1 deletion src/ripple/rpc/impl/Handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ Handler handlerArray[] {
{ "validators", byRef (&doValidators), Role::ADMIN, NO_CONDITION },
{ "validator_list_sites", byRef (&doValidatorListSites), Role::ADMIN, NO_CONDITION },
{ "wallet_propose", byRef (&doWalletPropose), Role::ADMIN, NO_CONDITION },
{ "wallet_seed", byRef (&doWalletSeed), Role::ADMIN, NO_CONDITION },

// Evented methods
{ "subscribe", byRef (&doSubscribe), Role::USER, NO_CONDITION },
Expand Down
1 change: 0 additions & 1 deletion src/ripple/unity/rpcx2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <ripple/rpc/handlers/Validators.cpp>
#include <ripple/rpc/handlers/ValidatorListSites.cpp>
#include <ripple/rpc/handlers/WalletPropose.cpp>
#include <ripple/rpc/handlers/WalletSeed.cpp>

#include <ripple/rpc/impl/Handler.cpp>
#include <ripple/rpc/impl/LegacyPathFind.cpp>
Expand Down