Hide userreporter ID from mods and logfiles, since it shall be used as an authentication token for GDPR personal data requests, refs #5257, f51f78c999
/ D1563.
Comments by: Vladislav in irc on 2018-08-13 This was SVN commit r21867.
This commit is contained in:
parent
9e712fa0c5
commit
b3438cabd2
@ -22,10 +22,14 @@
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/ThreadUtil.h"
|
||||
|
||||
#include <unordered_set>
|
||||
|
||||
typedef std::map<CStr, CConfigValueSet> TConfigMap;
|
||||
TConfigMap CConfigDB::m_Map[CFG_LAST];
|
||||
VfsPath CConfigDB::m_ConfigFile[CFG_LAST];
|
||||
@ -33,10 +37,11 @@ bool CConfigDB::m_HasChanges[CFG_LAST];
|
||||
|
||||
static pthread_mutex_t cfgdb_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
// These entries will not be printed to logfiles
|
||||
static const std::set<CStr> g_UnloggedEntries = {
|
||||
// These entries will not be printed to logfiles, so that logfiles can be shared without leaking personal or sensitive data
|
||||
static const std::unordered_set<std::string> g_UnloggedEntries = {
|
||||
"lobby.password",
|
||||
"lobby.buddies"
|
||||
"lobby.buddies",
|
||||
"userreport.id" // authentication token for GDPR personal data requests
|
||||
};
|
||||
|
||||
CConfigDB::CConfigDB()
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2017 Wildfire Games.
|
||||
/* Copyright (C) 2018 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -21,9 +21,26 @@
|
||||
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "ps/CLogger.h"
|
||||
#include "ps/Profile.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
#include <string>
|
||||
#include <unordered_set>
|
||||
|
||||
// These entries will not be readable nor writable for JS, so that malicious mods can't leak personal or sensitive data
|
||||
static const std::unordered_set<std::string> g_ProtectedConfigNames = {
|
||||
"userreport.id" // authentication token for GDPR personal data requests
|
||||
};
|
||||
|
||||
bool JSI_ConfigDB::IsProtectedConfigName(const std::string& name)
|
||||
{
|
||||
if (g_ProtectedConfigNames.find(name) != g_ProtectedConfigNames.end())
|
||||
{
|
||||
LOGERROR("Access denied (%s)", name.c_str());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool JSI_ConfigDB::GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs)
|
||||
{
|
||||
if (cfgNsString == L"default")
|
||||
@ -64,6 +81,9 @@ bool JSI_ConfigDB::SetChanges(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), co
|
||||
|
||||
std::string JSI_ConfigDB::GetValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name)
|
||||
{
|
||||
if (IsProtectedConfigName(name))
|
||||
return "";
|
||||
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return std::string();
|
||||
@ -75,6 +95,9 @@ std::string JSI_ConfigDB::GetValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate
|
||||
|
||||
bool JSI_ConfigDB::CreateValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value)
|
||||
{
|
||||
if (IsProtectedConfigName(name))
|
||||
return false;
|
||||
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
@ -85,6 +108,9 @@ bool JSI_ConfigDB::CreateValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), c
|
||||
|
||||
bool JSI_ConfigDB::RemoveValue(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name)
|
||||
{
|
||||
if (IsProtectedConfigName(name))
|
||||
return false;
|
||||
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
@ -99,18 +125,19 @@ bool JSI_ConfigDB::WriteFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), con
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
bool ret = g_ConfigDB.WriteFile(cfgNs, path);
|
||||
return ret;
|
||||
return g_ConfigDB.WriteFile(cfgNs, path);
|
||||
}
|
||||
|
||||
bool JSI_ConfigDB::WriteValueToFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const std::string& name, const std::string& value, const Path& path)
|
||||
{
|
||||
if (IsProtectedConfigName(name))
|
||||
return false;
|
||||
|
||||
EConfigNamespace cfgNs;
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
bool ret = g_ConfigDB.WriteValueToFile(cfgNs, name, value, path);
|
||||
return ret;
|
||||
return g_ConfigDB.WriteValueToFile(cfgNs, name, value, path);
|
||||
}
|
||||
|
||||
bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString)
|
||||
@ -119,8 +146,7 @@ bool JSI_ConfigDB::Reload(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const
|
||||
if (!GetConfigNamespace(cfgNsString, cfgNs))
|
||||
return false;
|
||||
|
||||
bool ret = g_ConfigDB.Reload(cfgNs);
|
||||
return ret;
|
||||
return g_ConfigDB.Reload(cfgNs);
|
||||
}
|
||||
|
||||
bool JSI_ConfigDB::SetFile(ScriptInterface::CxPrivate* UNUSED(pCxPrivate), const std::wstring& cfgNsString, const Path& path)
|
||||
|
@ -21,8 +21,11 @@
|
||||
#include "ps/ConfigDB.h"
|
||||
#include "scriptinterface/ScriptInterface.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace JSI_ConfigDB
|
||||
{
|
||||
bool IsProtectedConfigName(const std::string& name);
|
||||
bool GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs);
|
||||
bool HasChanges(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString);
|
||||
bool SetChanges(ScriptInterface::CxPrivate* pCxPrivate, const std::wstring& cfgNsString, bool value);
|
||||
|
Loading…
Reference in New Issue
Block a user