History

whitelist -> allowlist

HifiExperiments committed 2 years ago

Commit f2d8fa21 parent 2876a4d28 files · +199 −199Browse files

Showing the changes to libraries/script-engine/src/ScriptManager.cpp (1 of 28 files). Show all

Unified · Split

libraries/script-engine/src/ScriptManager.cpp+34−34
@@ -2192,17 +2192,17 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 2191 unmodified lines
21922192 exception = testConstructor;
21932193 }
21942194 } else {
2195− // ENTITY SCRIPT WHITELIST STARTS HERE
2195+ // ENTITY SCRIPT ALLOWLIST STARTS HERE
21962196 auto nodeList = DependencyManager::get<NodeList>();
21972197 bool passList = false; // assume unsafe
2198− QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]";
2198+ QString allowlistPrefix = "[ALLOWLIST ENTITY SCRIPTS]";
21992199 QList<QString> safeURLPrefixes = { "file:///", "atp:", "cache:" };
2200− safeURLPrefixes += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts);
2200+ safeURLPrefixes += qEnvironmentVariable("EXTRA_ALLOWLIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts);
22012201
2202− // Entity Script Whitelist toggle check.
2203− Setting::Handle<bool> whitelistEnabled {"private/whitelistEnabled", false };
2202+ // Entity Script Allowlist toggle check.
2203+ Setting::Handle<bool> allowlistEnabled {"private/allowlistEnabled", false };
22042204
2205− if (!whitelistEnabled.get()) {
2205+ if (!allowlistEnabled.get()) {
22062206 passList = true;
22072207 }
22082208
@@ -2212,39 +2212,39 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 3 unmodified lines
22122212 safeURLPrefixes += settingsSafeURLS;
22132213 // END Pull SAFEURLS from the Interface.JSON settings.
22142214
2215− // Get current domain whitelist bypass, in case an entire domain is whitelisted.
2215+ // Get current domain allowlist bypass, in case an entire domain is allowlisted.
22162216 QString currentDomain = DependencyManager::get<AddressManager>()->getDomainURL().host();
22172217
22182218 QString domainSafeIP = nodeList->getDomainHandler().getHostname();
22192219 QString domainSafeURL = URL_SCHEME_OVERTE + "://" + currentDomain;
22202220 for (const auto& str : safeURLPrefixes) {
22212221 if (domainSafeURL.startsWith(str) || domainSafeIP.startsWith(str)) {
2222− qCDebug(scriptengine) << whitelistPrefix << "Whitelist Bypassed, entire domain is whitelisted. Current Domain Host: "
2222+ qCDebug(scriptengine) << allowlistPrefix << "Allowlist Bypassed, entire domain is allowlisted. Current Domain Host: "
22232223 << nodeList->getDomainHandler().getHostname()
22242224 << "Current Domain: " << currentDomain;
22252225 passList = true;
22262226 }
22272227 }
2228− // END bypass whitelist based on current domain.
2228+ // END bypass allowlist based on current domain.
22292229
2230− // Start processing scripts through the whitelist.
2231− if (ScriptManager::getContext() == "entity_server") { // If running on the server, do not engage whitelist.
2230+ // Start processing scripts through the allowlist.
2231+ if (ScriptManager::getContext() == "entity_server") { // If running on the server, do not engage allowlist.
22322232 passList = true;
2233− } else if (!passList) { // If waved through, do not engage whitelist.
2233+ } else if (!passList) { // If waved through, do not engage allowlist.
22342234 for (const auto& str : safeURLPrefixes) {
2235− qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
2235+ qCDebug(scriptengine) << allowlistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
22362236 << scriptOrURL.startsWith(str);
22372237 if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
22382238 passList = true;
2239− qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
2239+ qCDebug(scriptengine) << allowlistPrefix << "Script approved.";
22402240 break; // Bail early since we found a match.
22412241 }
22422242 }
22432243 }
2244− // END processing of scripts through the whitelist.
2244+ // END processing of scripts through the allowlist.
22452245
22462246 if (!passList) { // If the entity failed to pass for any reason, it's blocked and an error is thrown.
2247− qCDebug(scriptengine) << whitelistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
2247+ qCDebug(scriptengine) << allowlistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
22482248 exception = _engine->makeError(_engine->newValue("UNSAFE_ENTITY_SCRIPTS == 0"));
22492249 } else {
22502250 QTimer timeout;
@@ -2267,7 +2267,7 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 16 unmodified lines
22672267 exception = testConstructor;
22682268 }
22692269 }
2270− // ENTITY SCRIPT WHITELIST ENDS HERE, uncomment below for original full disabling.
2270+ // ENTITY SCRIPT ALLOWLIST ENDS HERE, uncomment below for original full disabling.
22712271
22722272 // qCDebug(scriptengine) << "(disabled entity script)" << entityID.toString() << scriptOrURL;
22732273 // exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");
@@ -2303,17 +2303,17 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 29 unmodified lines
23032303 return; // done processing script
23042304 }*/
23052305
2306− // ENTITY SCRIPT WHITELIST STARTS HERE
2306+ // ENTITY SCRIPT ALLOWLIST STARTS HERE
23072307 auto nodeList = DependencyManager::get<NodeList>();
23082308 bool passList = false; // assume unsafe
2309− QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]";
2309+ QString allowlistPrefix = "[ALLOWLIST ENTITY SCRIPTS]";
23102310 QList<QString> safeURLPrefixes = { "file:///", "atp:", "cache:" };
2311− safeURLPrefixes += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts);
2311+ safeURLPrefixes += qEnvironmentVariable("EXTRA_ALLOWLIST").trimmed().split(QRegExp("\\s*,\\s*"), Qt::SkipEmptyParts);
23122312
2313− // Entity Script Whitelist toggle check.
2314− Setting::Handle<bool> whitelistEnabled {"private/whitelistEnabled", false };
2313+ // Entity Script Allowlist toggle check.
2314+ Setting::Handle<bool> allowlistEnabled {"private/allowlistEnabled", false };
23152315
2316− if (!whitelistEnabled.get()) {
2316+ if (!allowlistEnabled.get()) {
23172317 passList = true;
23182318 }
23192319
@@ -2323,40 +2323,40 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 3 unmodified lines
23232323 safeURLPrefixes += settingsSafeURLS;
23242324 // END Pull SAFEURLS from the Interface.JSON settings.
23252325
2326− // Get current domain whitelist bypass, in case an entire domain is whitelisted.
2326+ // Get current domain allowlist bypass, in case an entire domain is allowlisted.
23272327 QString currentDomain = DependencyManager::get<AddressManager>()->getDomainURL().host();
23282328
23292329 QString domainSafeIP = nodeList->getDomainHandler().getHostname();
23302330 QString domainSafeURL = URL_SCHEME_OVERTE + "://" + currentDomain;
23312331 for (const auto& str : safeURLPrefixes) {
23322332 if (domainSafeURL.startsWith(str) || domainSafeIP.startsWith(str)) {
2333− qCDebug(scriptengine) << whitelistPrefix << "Whitelist Bypassed, entire domain is whitelisted. Current Domain Host: "
2333+ qCDebug(scriptengine) << allowlistPrefix << "Allowlist Bypassed, entire domain is allowlisted. Current Domain Host: "
23342334 << nodeList->getDomainHandler().getHostname()
23352335 << "Current Domain: " << currentDomain;
23362336 passList = true;
23372337 }
23382338 }
2339− // END bypass whitelist based on current domain.
2339+ // END bypass allowlist based on current domain.
23402340
2341− // Start processing scripts through the whitelist.
2342− if (ScriptManager::getContext() == "entity_server") { // If running on the server, do not engage whitelist.
2341+ // Start processing scripts through the allowlist.
2342+ if (ScriptManager::getContext() == "entity_server") { // If running on the server, do not engage allowlist.
23432343 passList = true;
2344− } else if (!passList) { // If waved through, do not engage whitelist.
2344+ } else if (!passList) { // If waved through, do not engage allowlist.
23452345 for (const auto& str : safeURLPrefixes) {
2346− qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
2346+ qCDebug(scriptengine) << allowlistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
23472347 << scriptOrURL.startsWith(str);
23482348 if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
23492349 passList = true;
2350− qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
2350+ qCDebug(scriptengine) << allowlistPrefix << "Script approved.";
23512351 break; // Bail early since we found a match.
23522352 }
23532353 }
23542354 }
2355− // END processing of scripts through the whitelist.
2355+ // END processing of scripts through the allowlist.
23562356
23572357 ScriptValue exception;
23582358 if (!passList) { // If the entity failed to pass for any reason, it's blocked and an error is thrown.
2359− qCDebug(scriptengine) << whitelistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
2359+ qCDebug(scriptengine) << allowlistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
23602360 exception = _engine->makeError(_engine->newValue("UNSAFE_ENTITY_SCRIPTS == 0"));
23612361 }
23622362
@@ -2369,7 +2369,7 @@ void ScriptManager::entityScriptContentAvailable(const EntityItemID& entityID, c · 6 unmodified lines
23692369 emit unhandledException(scriptRuntimeException);
23702370 return;
23712371 }
2372− // ENTITY SCRIPT WHITELIST ENDS HERE, uncomment below for original full disabling.
2372+ // ENTITY SCRIPT ALLOWLIST ENDS HERE, uncomment below for original full disabling.
23732373
23742374 // qCDebug(scriptengine) << "(disabled entity script)" << entityID.toString() << scriptOrURL;
23752375 // exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");