MCPcopy Create free account
hub / github.com/ByConity/ByConity / wipeSensitiveDataAndCutToLength

Function wipeSensitiveDataAndCutToLength

src/Common/SensitiveDataMasker.cpp:195–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195std::string wipeSensitiveDataAndCutToLength(const std::string & str, size_t max_length)
196{
197 std::string res = str;
198
199 if (auto * masker = SensitiveDataMasker::getInstance())
200 masker->wipeSensitiveData(res);
201
202 size_t length = res.length();
203 if (max_length && (length > max_length))
204 {
205 constexpr size_t max_extra_msg_len = sizeof("... (truncated 18446744073709551615 characters)");
206 if (max_length < max_extra_msg_len)
207 return "(removed " + std::to_string(length) + " characters)";
208 max_length -= max_extra_msg_len;
209 res.resize(max_length);
210 res.append("... (truncated " + std::to_string(length - max_length) + " characters)");
211 }
212
213 return res;
214}
215
216}

Callers 1

Calls 5

wipeSensitiveDataMethod · 0.80
lengthMethod · 0.80
to_stringFunction · 0.50
resizeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected