Skip to content

Commit

Permalink
feat: hide sensitive data from log
Browse files Browse the repository at this point in the history
  • Loading branch information
Curve committed May 2, 2023
1 parent 706bd3a commit c144a8c
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,18 @@ namespace chalchiu
m_impl->state["print"] = [print, this](const sol::variadic_args &args) {
using std::views::transform;

auto to_string = m_impl->state["tostring"];
auto to_string = [this](const auto &x) -> std::string {
std::string rtn = m_impl->state["tostring"](x);

if (rtn.find("authentication.prod") != std::string::npos ||
rtn.find("user-blob-storage") != std::string::npos)
{
return "<redacted>";
}

return rtn;
};

auto str_args = args | transform([&](const auto &x) { return to_string(x); });

std::vector<std::string> to_print{str_args.begin(), str_args.end()};
Expand Down

0 comments on commit c144a8c

Please sign in to comment.