Skip to content

Commit 2d5e493

Browse files
committed
update(crashreporter): Redacting sensible data
1 parent 1a9e419 commit 2d5e493

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

src/dumps/CrashDump.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ std::string get_uuid()
4141

4242
std::string startup_cmd = "None";
4343

44+
const char *ws = " \t\n\r\f\v";
45+
46+
// trim from end of string (right)
47+
inline std::string &rtrim(std::string &s, const char *t = ws)
48+
{
49+
s.erase(s.find_last_not_of(t) + 1);
50+
return s;
51+
}
52+
53+
// trim from beginning of string (left)
54+
inline std::string &ltrim(std::string &s, const char *t = ws)
55+
{
56+
s.erase(0, s.find_first_not_of(t));
57+
return s;
58+
}
59+
60+
// trim from both ends of string (right then left)
61+
inline std::string &trim(std::string &s, const char *t = ws)
62+
{
63+
return ltrim(rtrim(s, t), t);
64+
}
65+
4466
void signal_handler(int signumber)
4567
{
4668
try
@@ -101,8 +123,23 @@ bool BeginCrashListener()
101123
}
102124

103125
startup_cmd = CommandLine()->GetCmdLine();
126+
std::vector<std::string> exp = explode(startup_cmd, " ");
127+
std::vector<std::string> exp2;
128+
for (int i = 1; i < exp.size(); i++)
129+
{
130+
std::string str = trim(exp[i]);
131+
if (str.length() == 0)
132+
continue;
133+
if (exp2.size() > 0)
134+
if (ends_with(exp2[exp2.size() - 1], "sv_setsteamaccount") || ends_with(exp2[exp2.size() - 1], "authkey"))
135+
str = "REDACTED";
136+
137+
exp2.push_back(str);
138+
}
139+
startup_cmd = implode(exp2, " ");
104140

105141
::signal(SIGSEGV, &signal_handler);
142+
106143
return true;
107144
}
108145

0 commit comments

Comments
 (0)