Improve JSON sanitization in reporting mode

This commit is contained in:
Nathan Nichols
2022-07-13 20:35:31 -07:00
committed by Nik Bougalis
parent b0b44d32bd
commit d458e9972b
2 changed files with 16 additions and 2 deletions

View File

@@ -72,7 +72,7 @@ shouldForwardToP2p(RPC::JsonContext& context)
if (params.isMember(jss::ledger_index))
{
auto indexValue = params[jss::ledger_index];
if (!indexValue.isNumeric())
if (indexValue.isString())
{
auto index = indexValue.asString();
return index == "current" || index == "closed";

View File

@@ -873,9 +873,23 @@ ServerHandlerImp::processRequest(
params,
{user, forwardedFor}};
Json::Value result;
auto start = std::chrono::system_clock::now();
RPC::doCommand(context, result);
try
{
RPC::doCommand(context, result);
}
catch (std::exception const& ex)
{
result = RPC::make_error(rpcINTERNAL);
JLOG(m_journal.error()) << "Internal error : " << ex.what()
<< " when processing request: "
<< Json::Compact{Json::Value{params}};
}
auto end = std::chrono::system_clock::now();
logDuration(params, end - start, m_journal);
usage.charge(loadType);