diff --git a/Makefile.am b/Makefile.am index 237c35891c49..b796db211e7e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -360,7 +360,8 @@ wsd_headers = wsd/Admin.hpp \ wsd/wopi/WopiProxy.hpp \ wsd/wopi/WopiStorage.hpp -shared_headers = common/Common.hpp \ +shared_headers = common/Anonymizer.hpp \ + common/Common.hpp \ common/CharacterConverter.hpp \ common/Clipboard.hpp \ common/Crypto.hpp \ diff --git a/common/Anonymizer.hpp b/common/Anonymizer.hpp new file mode 100644 index 000000000000..d02cf4eaddd3 --- /dev/null +++ b/common/Anonymizer.hpp @@ -0,0 +1,101 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * Copyright the Collabora Online contributors. + * + * SPDX-License-Identifier: MPL-2.0 + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include +#include + +#include +#include +#include +#include + +extern std::unordered_map AnonymizedStrings; +extern std::mutex AnonymizedMutex; + +/// Responsible for annonymizing names and URLs. +/// The anonymized version is always the same for +/// a given value, provided the salt is identical. +class Anonymizer +{ +public: + /// Sets the anonymized version of a given plain-text string. + /// After this, 'anonymize(plain)' will return 'anonymized'. + static void mapAnonymized(const std::string& plain, const std::string& anonymized) + { + if (plain.empty() || anonymized.empty()) + return; + + if (plain != anonymized) + LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "]."); + + std::unique_lock lock(AnonymizedMutex); + + AnonymizedStrings[plain] = anonymized; + } + + /// Anonymize a sensitive string to avoid leaking it. + /// Called on strings to be logged or exposed. + static std::string anonymize(const std::string& text, const std::uint64_t nAnonymizationSalt) + { + { + std::unique_lock lock(AnonymizedMutex); + + const auto it = AnonymizedStrings.find(text); + if (it != AnonymizedStrings.end()) + { + if (text != it->second) + LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "]."); + return it->second; + } + } + + // Modified 64-bit FNV-1a to add salting. + // For the algorithm and the magic numbers, see http://isthe.com/chongo/tech/comp/fnv/ + std::uint64_t hash = 0xCBF29CE484222325LL; + hash ^= nAnonymizationSalt; + hash *= 0x100000001b3ULL; + for (const char c : text) + { + hash ^= static_cast(c); + hash *= 0x100000001b3ULL; + } + + hash ^= nAnonymizationSalt; + hash *= 0x100000001b3ULL; + + // Generate the anonymized string. The '#' is to hint that it's anonymized. + // Prepend with count to make it unique within a single process instance, + // in case we get collisions (which we will, eventually). N.B.: Identical + // strings likely to have different prefixes when logged in WSD process vs. Kit. + static std::atomic AnonymizationCounter(0); + std::string res = + '#' + Util::encodeId(AnonymizationCounter++, 0) + '#' + Util::encodeId(hash, 0) + '#'; + mapAnonymized(text, res); + return res; + } + + /// Clears the shared state of mapAnonymized() / anonymize(). + static void clearAnonymized() { AnonymizedStrings.clear(); } + + /// Anonymize the basename of filenames only, preserving the path and extension. + static std::string anonymizeUrl(const std::string& url, const std::uint64_t nAnonymizationSalt) + { + std::string base; + std::string filename; + std::string ext; + std::string params; + std::tie(base, filename, ext, params) = Util::splitUrl(url); + + return base + anonymize(filename, nAnonymizationSalt) + ext + params; + } +}; diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp index af3e12c53781..abe2e7208c62 100644 --- a/common/FileUtil.cpp +++ b/common/FileUtil.cpp @@ -13,6 +13,11 @@ #include "FileUtil.hpp" +#include +#include +#include +#include + #include #include #include @@ -43,10 +48,6 @@ #include #include -#include "Log.hpp" -#include "Util.hpp" -#include "Unit.hpp" - namespace FileUtil { std::string createRandomDir(const std::string& path) @@ -621,14 +622,14 @@ namespace FileUtil /// Anonymize the basename of filenames, preserving the path and extension. std::string anonymizeUrl(const std::string& url) { - return AnonymizeUserData ? Util::anonymizeUrl(url, AnonymizationSalt) : url; + return AnonymizeUserData ? Anonymizer::anonymizeUrl(url, AnonymizationSalt) : url; } /// Anonymize user names and IDs. /// Will use the Obfuscated User ID if one is provided via WOPI. std::string anonymizeUsername(const std::string& username) { - return AnonymizeUserData ? Util::anonymize(username, AnonymizationSalt) : username; + return AnonymizeUserData ? Anonymizer::anonymize(username, AnonymizationSalt) : username; } std::string extractFileExtension(const std::string& path) diff --git a/common/Session.cpp b/common/Session.cpp index 03175d39fe43..253a42f8228e 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -13,16 +13,17 @@ #include "Session.hpp" +#include +#include +#include +#include +#include + #include #include #include #include -#include -#include "Protocol.hpp" -#include "Log.hpp" -#include "Util.hpp" - using namespace COOLProtocol; using Poco::Exception; @@ -240,9 +241,9 @@ void Session::parseDocOptions(const StringVector& tokens, int& part, std::string } } - Util::mapAnonymized(_userId, _userIdAnonym); - Util::mapAnonymized(_userName, _userNameAnonym); - Util::mapAnonymized(_jailedFilePath, _jailedFilePathAnonym); + Anonymizer::mapAnonymized(_userId, _userIdAnonym); + Anonymizer::mapAnonymized(_userName, _userNameAnonym); + Anonymizer::mapAnonymized(_jailedFilePath, _jailedFilePathAnonym); if (tokens.size() > offset) { diff --git a/common/Util.cpp b/common/Util.cpp index 469652943d11..22f59c8544d8 100644 --- a/common/Util.cpp +++ b/common/Util.cpp @@ -80,6 +80,9 @@ #include "Protocol.hpp" #include "TraceEvent.hpp" +std::unordered_map AnonymizedStrings; +std::mutex AnonymizedMutex; + namespace Util { namespace rng @@ -481,77 +484,6 @@ namespace Util return std::make_tuple(base, filename, ext, params); } - static std::unordered_map AnonymizedStrings; - static std::atomic AnonymizationCounter(0); - static std::mutex AnonymizedMutex; - - void mapAnonymized(const std::string& plain, const std::string& anonymized) - { - if (plain.empty() || anonymized.empty()) - return; - - if (Log::traceEnabled() && plain != anonymized) - LOG_TRC("Anonymizing [" << plain << "] -> [" << anonymized << "]."); - - std::unique_lock lock(AnonymizedMutex); - - AnonymizedStrings[plain] = anonymized; - } - - std::string anonymize(const std::string& text, const std::uint64_t nAnonymizationSalt) - { - { - std::unique_lock lock(AnonymizedMutex); - - const auto it = AnonymizedStrings.find(text); - if (it != AnonymizedStrings.end()) - { - if (Log::traceEnabled() && text != it->second) - LOG_TRC("Found anonymized [" << text << "] -> [" << it->second << "]."); - return it->second; - } - } - - // Modified 64-bit FNV-1a to add salting. - // For the algorithm and the magic numbers, see http://isthe.com/chongo/tech/comp/fnv/ - std::uint64_t hash = 0xCBF29CE484222325LL; - hash ^= nAnonymizationSalt; - hash *= 0x100000001b3ULL; - for (const char c : text) - { - hash ^= static_cast(c); - hash *= 0x100000001b3ULL; - } - - hash ^= nAnonymizationSalt; - hash *= 0x100000001b3ULL; - - // Generate the anonymized string. The '#' is to hint that it's anonymized. - // Prepend with count to make it unique within a single process instance, - // in case we get collisions (which we will, eventually). N.B.: Identical - // strings likely to have different prefixes when logged in WSD process vs. Kit. - std::string res - = '#' + Util::encodeId(AnonymizationCounter++, 0) + '#' + Util::encodeId(hash, 0) + '#'; - mapAnonymized(text, res); - return res; - } - - void clearAnonymized() - { - AnonymizedStrings.clear(); - } - - std::string anonymizeUrl(const std::string& url, const std::uint64_t nAnonymizationSalt) - { - std::string base; - std::string filename; - std::string ext; - std::string params; - std::tie(base, filename, ext, params) = Util::splitUrl(url); - - return base + Util::anonymize(filename, nAnonymizationSalt) + ext + params; - } - std::string getTimeNow(const char* format) { char time_now[64]; diff --git a/common/Util.hpp b/common/Util.hpp index 6785312466cc..5f9dc7d9edb7 100644 --- a/common/Util.hpp +++ b/common/Util.hpp @@ -1163,20 +1163,6 @@ int main(int argc, char**argv) /// either for a URL or for a file path std::string cleanupFilename(const std::string &filename); - /// Anonymize a sensitive string to avoid leaking it. - /// Called on strings to be logged or exposed. - std::string anonymize(const std::string& text, const std::uint64_t nAnonymizationSalt); - - /// Sets the anonymized version of a given plain-text string. - /// After this, 'anonymize(plain)' will return 'anonymized'. - void mapAnonymized(const std::string& plain, const std::string& anonymized); - - /// Clears the shared state of mapAnonymized() / anonymize(). - void clearAnonymized(); - - /// Anonymize the basename of filenames only, preserving the path and extension. - std::string anonymizeUrl(const std::string& url, const std::uint64_t nAnonymizationSalt); - /// Return true if the subject matches in given set. It uses regex /// Mainly used to match WOPI hosts patterns bool matchRegex(const std::set& set, const std::string& subject); diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index dd929343fcbc..7196300e9c4c 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -11,16 +11,17 @@ #include -#include "Kit.hpp" #include "ChildSession.hpp" -#include "MobileApp.hpp" -#include "COOLWSD.hpp" + +#include +#include +#include +#include #include #include #include #include -#include #define LOK_USE_UNSTABLE_API #include @@ -49,10 +50,7 @@ #include #include #include "KitHelper.hpp" -#include #include -#include -#include #include #include #include @@ -1281,7 +1279,7 @@ bool ChildSession::downloadAs(const StringVector& tokens) } // Obfuscate the new name. - Util::mapAnonymized(Uri::getFilenameFromURL(name), _docManager->getObfuscatedFileId()); + Anonymizer::mapAnonymized(Uri::getFilenameFromURL(name), _docManager->getObfuscatedFileId()); getTokenString(tokens[3], "format", format); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 4439e5e79342..00a50c4fbb83 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -15,6 +15,8 @@ #include +#include + #include #include #include @@ -1971,7 +1973,7 @@ std::shared_ptr Document::load(const std::shared_ptrdocumentLoad(pURL, options.c_str())); #ifdef __ANDROID__ @@ -1979,8 +1981,7 @@ std::shared_ptr Document::load(const std::shared_ptr(duration); - LOG_DBG("Returned lokit::documentLoad(" << FileUtil::anonymizeUrl(pURL) << ") in " - << elapsed); + LOG_DBG("Returned lokit::documentLoad(" << anonymizeUrl(pURL) << ") in " << elapsed); #ifdef IOS DocumentData::get(_mobileAppDocId).loKitDocument = _loKitDocument.get(); #endif @@ -3814,7 +3815,7 @@ TileWireId getCurrentWireId(bool increment) std::string anonymizeUrl(const std::string& url) { #ifndef BUILDING_TESTS - return AnonymizeUserData ? Util::anonymizeUrl(url, AnonymizationSalt) : url; + return AnonymizeUserData ? Anonymizer::anonymizeUrl(url, AnonymizationSalt) : url; #else return url; #endif @@ -3966,7 +3967,7 @@ bool globalPreinit(const std::string &loTemplate) std::string anonymizeUsername(const std::string& username) { #ifndef BUILDING_TESTS - return AnonymizeUserData ? Util::anonymize(username, AnonymizationSalt) : username; + return AnonymizeUserData ? Anonymizer::anonymize(username, AnonymizationSalt) : username; #else return username; #endif diff --git a/kit/KitWebSocket.cpp b/kit/KitWebSocket.cpp index 17989944aef2..c67cc33d1543 100644 --- a/kit/KitWebSocket.cpp +++ b/kit/KitWebSocket.cpp @@ -21,13 +21,13 @@ #include #include +#include #include #include #include #include #include "Kit.hpp" -#include "KitQueue.hpp" #include "ChildSession.hpp" #include "KitWebSocket.hpp" @@ -68,7 +68,8 @@ void KitWebSocketHandler::handleMessage(const std::vector& data) _docKey = tokens[2]; const std::string& docId = tokens[3]; const std::string fileId = Uri::getFilenameFromURL(_docKey); - Util::mapAnonymized(fileId, fileId); // Identity mapping, since fileId is already obfuscated + Anonymizer::mapAnonymized(fileId, + fileId); // Identity mapping, since fileId is already obfuscated const std::string url = Uri::decode(_docKey); #ifndef IOS diff --git a/test/WhiteBoxTests.cpp b/test/WhiteBoxTests.cpp index 7d8e5d87b94d..081a820312b4 100644 --- a/test/WhiteBoxTests.cpp +++ b/test/WhiteBoxTests.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -724,52 +725,54 @@ void WhiteBoxTests::testAnonymization() std::uint64_t nAnonymizationSalt = 1111111111182589933; LOK_ASSERT_EQUAL(std::string("#0#5e45aef91248a8aa#"), - Util::anonymizeUrl(name, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(name, nAnonymizationSalt)); LOK_ASSERT_EQUAL(std::string("#1#8f8d95bd2a202d00#.odt"), - Util::anonymizeUrl(filenameTestx, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(filenameTestx, nAnonymizationSalt)); LOK_ASSERT_EQUAL(std::string("/path/to/#2#5c872b2d82ecc8a0#.ext"), - Util::anonymizeUrl(path, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(path, nAnonymizationSalt)); LOK_ASSERT_EQUAL( std::string("http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/" "#3#22c6f0caad277666#?access_token=Hn0zttjbwkvGWb5BHbDa5ArgTykJAyBl&access_" "token_ttl=0&permission=edit"), - Util::anonymizeUrl(plainUrl, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(plainUrl, nAnonymizationSalt)); LOK_ASSERT_EQUAL( std::string("http://localhost/owncloud/index.php/apps/richdocuments/wopi/files/" "736_ocgdpzbkm39u/" "#4#294f0dfb18f6a80b#.odt?access_token=Hn0zttjbwkvGWb5BHbDa5ArgTykJAyBl&access_" "token_ttl=0&permission=edit"), - Util::anonymizeUrl(fileUrl, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(fileUrl, nAnonymizationSalt)); nAnonymizationSalt = 0; - LOK_ASSERT_EQUAL(std::string("#0#5e45aef91248a8aa#"), Util::anonymizeUrl(name, nAnonymizationSalt)); - Util::mapAnonymized(name, name); - LOK_ASSERT_EQUAL(name, Util::anonymizeUrl(name, nAnonymizationSalt)); + LOK_ASSERT_EQUAL(std::string("#0#5e45aef91248a8aa#"), + Anonymizer::anonymizeUrl(name, nAnonymizationSalt)); + Anonymizer::mapAnonymized(name, name); + LOK_ASSERT_EQUAL(name, Anonymizer::anonymizeUrl(name, nAnonymizationSalt)); LOK_ASSERT_EQUAL(std::string("#2#5c872b2d82ecc8a0#.ext"), - Util::anonymizeUrl(filename, nAnonymizationSalt)); - Util::mapAnonymized("filename", "filename"); // Identity map of the filename without extension. - LOK_ASSERT_EQUAL(filename, Util::anonymizeUrl(filename, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(filename, nAnonymizationSalt)); + Anonymizer::mapAnonymized("filename", + "filename"); // Identity map of the filename without extension. + LOK_ASSERT_EQUAL(filename, Anonymizer::anonymizeUrl(filename, nAnonymizationSalt)); LOK_ASSERT_EQUAL(std::string("#1#8f8d95bd2a202d00#.odt"), - Util::anonymizeUrl(filenameTestx, nAnonymizationSalt)); - Util::mapAnonymized("testx (6)", - "testx (6)"); // Identity map of the filename without extension. - LOK_ASSERT_EQUAL(filenameTestx, Util::anonymizeUrl(filenameTestx, nAnonymizationSalt)); + Anonymizer::anonymizeUrl(filenameTestx, nAnonymizationSalt)); + Anonymizer::mapAnonymized("testx (6)", + "testx (6)"); // Identity map of the filename without extension. + LOK_ASSERT_EQUAL(filenameTestx, Anonymizer::anonymizeUrl(filenameTestx, nAnonymizationSalt)); - LOK_ASSERT_EQUAL(path, Util::anonymizeUrl(path, nAnonymizationSalt)); + LOK_ASSERT_EQUAL(path, Anonymizer::anonymizeUrl(path, nAnonymizationSalt)); const std::string urlAnonymized = Util::replace(plainUrl, "736_ocgdpzbkm39u", "#3#22c6f0caad277666#"); - LOK_ASSERT_EQUAL(urlAnonymized, Util::anonymizeUrl(plainUrl, nAnonymizationSalt)); - Util::mapAnonymized("736_ocgdpzbkm39u", "736_ocgdpzbkm39u"); - LOK_ASSERT_EQUAL(plainUrl, Util::anonymizeUrl(plainUrl, nAnonymizationSalt)); + LOK_ASSERT_EQUAL(urlAnonymized, Anonymizer::anonymizeUrl(plainUrl, nAnonymizationSalt)); + Anonymizer::mapAnonymized("736_ocgdpzbkm39u", "736_ocgdpzbkm39u"); + LOK_ASSERT_EQUAL(plainUrl, Anonymizer::anonymizeUrl(plainUrl, nAnonymizationSalt)); const std::string urlAnonymized2 = Util::replace(fileUrl, "secret", "#4#294f0dfb18f6a80b#"); - LOK_ASSERT_EQUAL(urlAnonymized2, Util::anonymizeUrl(fileUrl, nAnonymizationSalt)); - Util::mapAnonymized("secret", "736_ocgdpzbkm39u"); + LOK_ASSERT_EQUAL(urlAnonymized2, Anonymizer::anonymizeUrl(fileUrl, nAnonymizationSalt)); + Anonymizer::mapAnonymized("secret", "736_ocgdpzbkm39u"); const std::string urlAnonymized3 = Util::replace(fileUrl, "secret", "736_ocgdpzbkm39u"); - LOK_ASSERT_EQUAL(urlAnonymized3, Util::anonymizeUrl(fileUrl, nAnonymizationSalt)); + LOK_ASSERT_EQUAL(urlAnonymized3, Anonymizer::anonymizeUrl(fileUrl, nAnonymizationSalt)); } void WhiteBoxTests::testIso8601Time() diff --git a/tools/Config.cpp b/tools/Config.cpp index c8e4d9c0096d..76da0031b065 100644 --- a/tools/Config.cpp +++ b/tools/Config.cpp @@ -11,6 +11,11 @@ #include +#include +#include +#include +#include + #include #include #include @@ -33,10 +38,6 @@ #include #include -#include -#include -#include - using Poco::Util::Application; using Poco::Util::HelpFormatter; using Poco::Util::Option; @@ -422,7 +423,8 @@ int Config::main(const std::vector& args) for (std::size_t i = 1; i < args.size(); ++i) { - std::cout << '[' << args[i] << "]: " << Util::anonymizeUrl(args[i], AnonymizationSalt) << std::endl; + std::cout << '[' << args[i] + << "]: " << Anonymizer::anonymizeUrl(args[i], AnonymizationSalt) << std::endl; } } else if (args[0] == "migrateconfig") diff --git a/wsd/COOLWSD.cpp b/wsd/COOLWSD.cpp index 8622c5b215bf..93dae733e0b5 100644 --- a/wsd/COOLWSD.cpp +++ b/wsd/COOLWSD.cpp @@ -93,6 +93,7 @@ #include #include +#include #include #include #include @@ -3693,7 +3694,7 @@ int COOLWSD::innerMain() #endif // URI with /contents are public and we don't need to anonymize them. - Util::mapAnonymized("contents", "contents"); + Anonymizer::mapAnonymized("contents", "contents"); // Start the server. Server->start(); diff --git a/wsd/ClientRequestDispatcher.cpp b/wsd/ClientRequestDispatcher.cpp index 2896076af147..ae572a624a1b 100644 --- a/wsd/ClientRequestDispatcher.cpp +++ b/wsd/ClientRequestDispatcher.cpp @@ -15,6 +15,7 @@ #include "CommandControl.hpp" #endif +#include #include #include #include @@ -1819,7 +1820,8 @@ bool ClientRequestDispatcher::handleClientProxyRequest(const Poco::Net::HTTPRequ auto uriPublic = RequestDetails::sanitizeURI(url); const auto docKey = RequestDetails::getDocKey(uriPublic); const std::string fileId = Uri::getFilenameFromURL(docKey); - Util::mapAnonymized(fileId, fileId); // Identity mapping, since fileId is already obfuscated + Anonymizer::mapAnonymized(fileId, + fileId); // Identity mapping, since fileId is already obfuscated LOG_INF("Starting Proxy request handler for session [" << _id << "] on url [" << COOLWSD::anonymizeUrl(url) << "]."); diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index f20d9f974f51..26cb2a4083af 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -13,6 +13,8 @@ #include "DocumentBroker.hpp" +#include + #include #include #include @@ -2133,7 +2135,7 @@ void DocumentBroker::uploadToStorageInternal(const std::shared_ptr +#include #include #include #include @@ -63,7 +64,8 @@ void RequestVettingStation::handleRequest(const std::string& id) const auto uriPublic = RequestDetails::sanitizeURI(url); const auto docKey = RequestDetails::getDocKey(uriPublic); const std::string fileId = Uri::getFilenameFromURL(docKey); - Util::mapAnonymized(fileId, fileId); // Identity mapping, since fileId is already obfuscated + Anonymizer::mapAnonymized(fileId, + fileId); // Identity mapping, since fileId is already obfuscated // Check if readonly session is required. const bool isReadOnly = Uri::hasReadonlyPermission(uriPublic.toString()); @@ -156,7 +158,8 @@ void RequestVettingStation::handleRequest(const std::string& id, const auto uriPublic = RequestDetails::sanitizeURI(url); const auto docKey = RequestDetails::getDocKey(uriPublic); const std::string fileId = Uri::getFilenameFromURL(docKey); - Util::mapAnonymized(fileId, fileId); // Identity mapping, since fileId is already obfuscated + Anonymizer::mapAnonymized(fileId, + fileId); // Identity mapping, since fileId is already obfuscated // Check if readonly session is required. const bool isReadOnly = Uri::hasReadonlyPermission(uriPublic.toString()); diff --git a/wsd/wopi/WopiProxy.cpp b/wsd/wopi/WopiProxy.cpp index 6e87d9a6277f..53b0fd306471 100644 --- a/wsd/wopi/WopiProxy.cpp +++ b/wsd/wopi/WopiProxy.cpp @@ -13,6 +13,7 @@ #include "WopiProxy.hpp" +#include #include "FileUtil.hpp" #include "HttpHelper.hpp" #include "HttpRequest.hpp" @@ -38,7 +39,8 @@ void WopiProxy::handleRequest([[maybe_unused]] const std::shared_ptr& poll, cons std::move(lastModifiedTime) }); // if (COOLWSD::AnonymizeUserData) - // Util::mapAnonymized(Uri::getFilenameFromURL(filename), + // Anonymizer::mapAnonymized(Uri::getFilenameFromURL(filename), // Uri::getFilenameFromURL(getUri().toString())); auto wopiInfo = std::make_unique(fileInfo, object, uri); diff --git a/wsd/wopi/WopiStorage.cpp b/wsd/wopi/WopiStorage.cpp index 61195383c60f..fd461d1c7bb6 100644 --- a/wsd/wopi/WopiStorage.cpp +++ b/wsd/wopi/WopiStorage.cpp @@ -12,7 +12,6 @@ #include #include "WopiStorage.hpp" -#include "wopi/StorageConnectionManager.hpp" #include #include @@ -25,10 +24,12 @@ #include #include #include +#include #include #include #include #include +#include #include #include @@ -169,8 +170,8 @@ void WopiStorage::handleWOPIFileInfo(const WOPIFileInfo& wopiFileInfo, LockConte setFileInfo(wopiFileInfo); if (COOLWSD::AnonymizeUserData) - Util::mapAnonymized(Uri::getFilenameFromURL(wopiFileInfo.getFilename()), - Uri::getFilenameFromURL(getUri().toString())); + Anonymizer::mapAnonymized(Uri::getFilenameFromURL(wopiFileInfo.getFilename()), + Uri::getFilenameFromURL(getUri().toString())); if (wopiFileInfo.getSupportsLocks()) lockCtx.initSupportsLocks(); @@ -211,9 +212,9 @@ WopiStorage::WOPIFileInfo::WOPIFileInfo(const FileInfo& fileInfo, Poco::JSON::Ob JsonUtil::findJSONValue(object, "ObfuscatedUserId", _obfuscatedUserId); if (!_obfuscatedUserId.empty()) { - Util::mapAnonymized(getOwnerId(), _obfuscatedUserId); - Util::mapAnonymized(_userId, _obfuscatedUserId); - Util::mapAnonymized(_username, _obfuscatedUserId); + Anonymizer::mapAnonymized(getOwnerId(), _obfuscatedUserId); + Anonymizer::mapAnonymized(_userId, _obfuscatedUserId); + Anonymizer::mapAnonymized(_username, _obfuscatedUserId); } // Set anonymized version of the above fields before logging. @@ -963,11 +964,12 @@ WopiStorage::handleUploadToStorageResponse(const WopiUploadDetails& details, // Get the FileId form the URL, which we use as the anonymized filename. const std::string decodedUrl = Uri::decode(url); const std::string obfuscatedFileId = Uri::getFilenameFromURL(decodedUrl); - Util::mapAnonymized(obfuscatedFileId, - obfuscatedFileId); // Identity, to avoid re-anonymizing. + Anonymizer::mapAnonymized( + obfuscatedFileId, + obfuscatedFileId); // Identity, to avoid re-anonymizing. const std::string filenameOnly = Uri::getFilenameFromURL(filename); - Util::mapAnonymized(filenameOnly, obfuscatedFileId); + Anonymizer::mapAnonymized(filenameOnly, obfuscatedFileId); object->set("Name", COOLWSD::anonymizeUrl(filename)); }