History

Updated whitelist debugs for clarity in dev log

Kasen IO committed 6 years ago

Commit 3e6660b1 parent 2de388a1 file · +4 −3Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 1 file). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+4−3
@@ -2364,6 +2364,7 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 2363 unmodified lines
2364 }2364 }
2365 else {2365 else {
2366 // ENTITY SCRIPT WHITELIST STARTS HERE2366 // ENTITY SCRIPT WHITELIST STARTS HERE
2367 QString whitelistPrefix = "[WHITELIST ENTITY SCRIPTS]";
2367 QList<QString> safeURLS = { "" };2368 QList<QString> safeURLS = { "" };
2368 safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);2369 safeURLS += qEnvironmentVariable("EXTRA_WHITELIST").trimmed().split(QRegExp("\\s*,\\s*"), QString::SkipEmptyParts);
2369 2370
@@ -2377,16 +2378,16 @@ void ScriptEngine::entityScriptContentAvailable(const EntityItemID& entityID, co · 7 unmodified lines
2377 2378
2378 bool isInWhitelist = false; // assume unsafe2379 bool isInWhitelist = false; // assume unsafe
2379 for (const auto& str : safeURLS) {2380 for (const auto& str : safeURLS) {
2380 qCDebug(scriptengine) << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"2381 qCDebug(scriptengine) << whitelistPrefix << "Script URL: " << scriptOrURL << "TESTING AGAINST" << str << "RESULTS IN"
2381 << scriptOrURL.startsWith(str);2382 << scriptOrURL.startsWith(str);
2382 if (!str.isEmpty() && scriptOrURL.startsWith(str)) {2383 if (!str.isEmpty() && scriptOrURL.startsWith(str)) {
2383 isInWhitelist = true;2384 isInWhitelist = true;
2384 qCDebug(scriptengine) << "Script approved.";2385 qCDebug(scriptengine) << whitelistPrefix << "Script approved.";
2385 break; // bail early since we found a match2386 break; // bail early since we found a match
2386 }2387 }
2387 }2388 }
2388 if (!isInWhitelist) {2389 if (!isInWhitelist) {
2389 qCDebug(scriptengine) << "(disabled entity script)" << entityID.toString() << scriptOrURL;2390 qCDebug(scriptengine) << whitelistPrefix << "(disabled entity script)" << entityID.toString() << scriptOrURL;
2390 exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");2391 exception = makeError("UNSAFE_ENTITY_SCRIPTS == 0");
2391 } else {2392 } else {
2392 QTimer timeout;2393 QTimer timeout;