Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/scripting/JSInterface_ConfigDB.cpp
Show All 20 Lines | |||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "scriptinterface/ScriptInterface.h" | #include "scriptinterface/ScriptInterface.h" | ||||
#include <string> | #include <string> | ||||
#include <unordered_set> | #include <unordered_set> | ||||
// These entries will not be readable nor writable for JS, so that malicious mods can't leak personal or sensitive data | // These entries will not be readable nor writable for JS, so that e.g. malicious mods can't leak personal or sensitive data | ||||
static const std::unordered_set<std::string> g_ProtectedConfigNames = { | static const std::unordered_set<std::string> g_ProtectedConfigNames = { | ||||
"userreport.id" // authentication token for GDPR personal data requests | "modio.public_key", // See ModIO.cpp | ||||
"modio.v1.baseurl", | |||||
"modio.v1.api_key", | |||||
"modio.v1.name_id", | |||||
"userreport.id" // Acts as authentication token for GDPR personal data requests. | |||||
}; | }; | ||||
bool JSI_ConfigDB::IsProtectedConfigName(const std::string& name) | bool JSI_ConfigDB::IsProtectedConfigName(const std::string& name) | ||||
{ | { | ||||
if (g_ProtectedConfigNames.find(name) != g_ProtectedConfigNames.end()) | if (g_ProtectedConfigNames.find(name) != g_ProtectedConfigNames.end()) | ||||
{ | { | ||||
LOGERROR("Access denied (%s)", name.c_str()); | LOGERROR("Access denied (%s)", name.c_str()); | ||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
bool JSI_ConfigDB::GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs) | bool JSI_ConfigDB::GetConfigNamespace(const std::wstring& cfgNsString, EConfigNamespace& cfgNs) | ||||
{ | { | ||||
if (cfgNsString == L"default") | if (cfgNsString == L"default") | ||||
cfgNs = CFG_DEFAULT; | cfgNs = CFG_DEFAULT; | ||||
else if (cfgNsString == L"mod") | |||||
cfgNs = CFG_MOD; | |||||
else if (cfgNsString == L"system") | else if (cfgNsString == L"system") | ||||
cfgNs = CFG_SYSTEM; | cfgNs = CFG_SYSTEM; | ||||
else if (cfgNsString == L"user") | else if (cfgNsString == L"user") | ||||
cfgNs = CFG_USER; | cfgNs = CFG_USER; | ||||
else if (cfgNsString == L"mod") | else if (cfgNsString == L"hwdetect") | ||||
cfgNs = CFG_MOD; | cfgNs = CFG_HWDETECT; | ||||
else | else | ||||
{ | { | ||||
LOGERROR("Invalid namespace name passed to the ConfigDB!"); | LOGERROR("Invalid namespace name passed to the ConfigDB!"); | ||||
cfgNs = CFG_DEFAULT; | cfgNs = CFG_DEFAULT; | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator