mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
Merge pull request #1445 from Zarthus/fix/debug-shows-pass
debugging: Add Filter method to hide filter sensitive data
This commit is contained in:
@@ -47,6 +47,8 @@ class CDebug {
|
||||
static void SetDebug(bool b) { debug = b; }
|
||||
static bool Debug() { return debug; }
|
||||
|
||||
static CString Filter(const CString& sUnfilteredLine);
|
||||
|
||||
protected:
|
||||
static bool stdoutIsTTY;
|
||||
static bool debug;
|
||||
|
||||
+5
-2
@@ -20,6 +20,7 @@
|
||||
#include <znc/User.h>
|
||||
#include <znc/IRCNetwork.h>
|
||||
#include <znc/Query.h>
|
||||
#include <znc/ZNCDebug.h>
|
||||
|
||||
using std::set;
|
||||
using std::map;
|
||||
@@ -105,7 +106,8 @@ void CClient::ReadLine(const CString& sData) {
|
||||
|
||||
sLine.TrimRight("\n\r");
|
||||
|
||||
DEBUG("(" << GetFullName() << ") CLI -> ZNC [" << sLine << "]");
|
||||
DEBUG("(" << GetFullName() << ") CLI -> ZNC ["
|
||||
<< CDebug::Filter(sLine) << "]");
|
||||
|
||||
MCString mssTags;
|
||||
if (sLine.StartsWith("@")) {
|
||||
@@ -586,7 +588,8 @@ bool CClient::PutClient(const CMessage& Message) {
|
||||
&bReturn);
|
||||
if (bReturn) return false;
|
||||
|
||||
DEBUG("(" << GetFullName() << ") ZNC -> CLI [" << sCopy << "]");
|
||||
DEBUG("(" << GetFullName() << ") ZNC -> CLI ["
|
||||
<< CDebug::Filter(sCopy) << "]");
|
||||
Write(sCopy + "\r\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
+7
-6
@@ -20,6 +20,7 @@
|
||||
#include <znc/IRCNetwork.h>
|
||||
#include <znc/Server.h>
|
||||
#include <znc/Query.h>
|
||||
#include <znc/ZNCDebug.h>
|
||||
#include <time.h>
|
||||
|
||||
using std::set;
|
||||
@@ -1128,8 +1129,8 @@ void CIRCSock::PutIRC(const CString& sLine) {
|
||||
// TrySend()!)
|
||||
if (m_bFloodProtection && m_iSendsAllowed <= 0) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/"
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine
|
||||
<< "] (queued)");
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC ["
|
||||
<< CDebug::Filter(sLine) << "] (queued)");
|
||||
}
|
||||
m_vsSendQueue.push_back(sLine);
|
||||
TrySend();
|
||||
@@ -1140,8 +1141,8 @@ void CIRCSock::PutIRCQuick(const CString& sLine) {
|
||||
// TrySend()!)
|
||||
if (m_bFloodProtection && m_iSendsAllowed <= 0) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/"
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC [" << sLine
|
||||
<< "] (queued to front)");
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC ["
|
||||
<< CDebug::Filter(sLine) << "] (queued to front)");
|
||||
}
|
||||
m_vsSendQueue.push_front(sLine);
|
||||
TrySend();
|
||||
@@ -1164,8 +1165,8 @@ void CIRCSock::TrySend() {
|
||||
IRCSOCKMODULECALL(OnSendToIRC(sCopy), &bSkip);
|
||||
if (!bSkip) {
|
||||
DEBUG("(" << m_pNetwork->GetUser()->GetUserName() << "/"
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC [" << sCopy
|
||||
<< "]");
|
||||
<< m_pNetwork->GetName() << ") ZNC -> IRC ["
|
||||
<< CDebug::Filter(sCopy) << "]");
|
||||
Write(sCopy + "\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,22 @@ bool CDebug::debug =
|
||||
false;
|
||||
#endif
|
||||
|
||||
CString CDebug::Filter(const CString& sUnfilteredLine) {
|
||||
CString sFilteredLine = sUnfilteredLine;
|
||||
|
||||
// If the line is a PASS command to authenticate to a server / znc
|
||||
if (sUnfilteredLine.StartsWith("PASS ")) {
|
||||
VCString vsSafeCopy;
|
||||
sUnfilteredLine.Split(":", vsSafeCopy);
|
||||
|
||||
if (vsSafeCopy.size() > 1) {
|
||||
sFilteredLine = vsSafeCopy[0] + ":<censored>";
|
||||
}
|
||||
}
|
||||
|
||||
return sFilteredLine;
|
||||
}
|
||||
|
||||
CDebugStream::~CDebugStream() {
|
||||
timeval tTime = CUtils::GetTime();
|
||||
time_t tSec = (time_t)tTime.tv_sec; // some systems (e.g. openbsd) define
|
||||
|
||||
Reference in New Issue
Block a user