From 1073626f8ec4e4b9300f0dd44b4aade37b5a0f01 Mon Sep 17 00:00:00 2001 From: kssenii Date: Mon, 21 Nov 2022 22:30:20 +0100 Subject: [PATCH] Mask secrets in log --- src/Parsers/ASTAlterNamedCollectionQuery.cpp | 5 ++++- src/Parsers/ASTCreateNamedCollectionQuery.cpp | 6 +++++- src/Storages/NamedCollectionUtils.cpp | 4 ++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Parsers/ASTAlterNamedCollectionQuery.cpp b/src/Parsers/ASTAlterNamedCollectionQuery.cpp index d1c55dc8573..7e95147ad75 100644 --- a/src/Parsers/ASTAlterNamedCollectionQuery.cpp +++ b/src/Parsers/ASTAlterNamedCollectionQuery.cpp @@ -29,7 +29,10 @@ void ASTAlterNamedCollectionQuery::formatImpl(const IAST::FormatSettings & setti first = false; formatSettingName(change.name, settings.ostr); - settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value); + if (settings.show_secrets) + settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value); + else + settings.ostr << " = '[HIDDEN]'"; } } if (!delete_keys.empty()) diff --git a/src/Parsers/ASTCreateNamedCollectionQuery.cpp b/src/Parsers/ASTCreateNamedCollectionQuery.cpp index 1c802abf667..97e83541f05 100644 --- a/src/Parsers/ASTCreateNamedCollectionQuery.cpp +++ b/src/Parsers/ASTCreateNamedCollectionQuery.cpp @@ -32,7 +32,11 @@ void ASTCreateNamedCollectionQuery::formatImpl(const IAST::FormatSettings & sett first = false; formatSettingName(change.name, settings.ostr); - settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value); + + if (settings.show_secrets) + settings.ostr << " = " << applyVisitor(FieldVisitorToString(), change.value); + else + settings.ostr << " = '[HIDDEN]'"; } } diff --git a/src/Storages/NamedCollectionUtils.cpp b/src/Storages/NamedCollectionUtils.cpp index 02f548a979b..75d5aace664 100644 --- a/src/Storages/NamedCollectionUtils.cpp +++ b/src/Storages/NamedCollectionUtils.cpp @@ -25,7 +25,7 @@ namespace DB namespace ErrorCodes { extern const int NAMED_COLLECTION_ALREADY_EXISTS; - extern const int NAMED_COLLECTION_DOESNT_EXISTS; + extern const int NAMED_COLLECTION_DOESNT_EXIST; extern const int BAD_ARGUMENTS; } @@ -269,7 +269,7 @@ public: if (!removeIfExists(collection_name)) { throw Exception( - ErrorCodes::NAMED_COLLECTION_DOESNT_EXISTS, + ErrorCodes::NAMED_COLLECTION_DOESNT_EXIST, "Cannot remove collection `{}`, because it doesn't exist", collection_name); }