[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-4' - tools/Config.cpp
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Sun Apr 14 18:58:34 UTC 2019
tools/Config.cpp | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
New commits:
commit fdb6578770cf35a5612e450b0b0dec9513c20bbd
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
AuthorDate: Mon Apr 1 00:13:03 2019 -0400
Commit: Ashod Nakashian <ashnakash at gmail.com>
CommitDate: Sun Apr 14 20:58:15 2019 +0200
looltool: support anonymizing strings
The user is able to override the salt,
or use the one from the config file.
Change-Id: Ida634374549fb490ec2437f557d46c44d4760c56
Reviewed-on: https://gerrit.libreoffice.org/70036
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/tools/Config.cpp b/tools/Config.cpp
index 0e2505283..0f79ea3a6 100644
--- a/tools/Config.cpp
+++ b/tools/Config.cpp
@@ -65,6 +65,8 @@ public:
static std::string ConfigFile;
static std::string SupportKeyString;
static bool SupportKeyStringProvided;
+ static std::uint64_t AnonymizationSalt;
+ static bool AnonymizationSaltProvided;
protected:
void defineOptions(OptionSet&) override;
@@ -82,6 +84,8 @@ std::string Config::ConfigFile =
std::string Config::SupportKeyString;
bool Config::SupportKeyStringProvided = false;
+std::uint64_t Config::AnonymizationSalt = 0;
+bool Config::AnonymizationSaltProvided = false;
void Config::displayHelp()
{
@@ -98,6 +102,7 @@ void Config::displayHelp()
// Command list
std::cout << std::endl
<< "Commands: " << std::endl
+ << " anonymize [string-1]...[string-n]" << std::endl
<< " set-admin-password" << std::endl
#if ENABLE_SUPPORT_KEY
<< " set-support-key" << std::endl
@@ -137,6 +142,11 @@ void Config::defineOptions(OptionSet& optionSet)
.repeatable(false)
.argument("key"));
#endif
+
+ optionSet.addOption(Option("anonymization-salt", "", "Anonymize strings with the given 64-bit salt instead of the one in the config file.")
+ .required(false)
+ .repeatable(false)
+ .argument("salt"));
}
void Config::handleOption(const std::string& optionName, const std::string& optionValue)
@@ -186,6 +196,12 @@ void Config::handleOption(const std::string& optionName, const std::string& opti
SupportKeyString = optionValue;
SupportKeyStringProvided = true;
}
+ else if (optionName == "anonymization-salt")
+ {
+ AnonymizationSalt = std::stoull(optionValue);
+ AnonymizationSaltProvided = true;
+ std::cout << "Anonymization Salt: [" << AnonymizationSalt << "]." << std::endl;
+ }
}
int Config::main(const std::vector<std::string>& args)
@@ -344,6 +360,20 @@ int Config::main(const std::vector<std::string>& args)
if (retval != 0)
std::cerr << "Error when executing command." << std::endl;
}
+ else if (args[0] == "anonymize")
+ {
+ if (!AnonymizationSaltProvided)
+ {
+ const std::string val = _loolConfig.getString("logging.anonymize.anonymization_salt");
+ AnonymizationSalt = std::stoull(val);
+ std::cout << "Anonymization Salt: [" << AnonymizationSalt << "]." << std::endl;
+ }
+
+ for (std::size_t i = 1; i < args.size(); ++i)
+ {
+ std::cout << "[" << args[i] << "]: " << Util::anonymizeUrl(args[i], AnonymizationSalt) << std::endl;
+ }
+ }
else
{
std::cerr << "No such command, \"" << args[0] << "\"" << std::endl;
More information about the Libreoffice-commits
mailing list