mirror of
https://github.com/lubosz/overte.git
synced 2025-04-14 10:08:20 +02:00
Merge pull request #1082 from digisomni/feature/preloaded-whitelist
Add ability to preload entity script whitelist
This commit is contained in:
commit
1b8800f772
10 changed files with 90 additions and 9 deletions
5
BUILD.md
5
BUILD.md
|
@ -90,7 +90,10 @@ BUILD_NUMBER
|
|||
RELEASE_TYPE=PRODUCTION|PR|DEV
|
||||
|
||||
// The Interface will have a custom default home and startup location.
|
||||
INITIAL_STARTUP_LOCATION=Location/IP/URL
|
||||
PRELOADED_STARTUP_LOCATION=Location/IP/URL
|
||||
// The Interface will have a custom default script whitelist, comma separated, no spaces.
|
||||
// This will also activate the whitelist on Interface's first run.
|
||||
PRELOADED_SCRIPT_WHITELIST=ListOfEntries
|
||||
|
||||
// Code-signing environment variables must be set during runtime of CMake AND globally when the signing takes place.
|
||||
HF_PFX_FILE=Path to certificate
|
||||
|
|
|
@ -25,7 +25,10 @@ macro(SET_PACKAGING_PARAMETERS)
|
|||
set_from_env(RELEASE_NUMBER RELEASE_NUMBER "")
|
||||
set_from_env(RELEASE_NAME RELEASE_NAME "")
|
||||
set_from_env(STABLE_BUILD STABLE_BUILD 0)
|
||||
set_from_env(INITIAL_STARTUP_LOCATION INITIAL_STARTUP_LOCATION "")
|
||||
|
||||
set_from_env(PRELOADED_STARTUP_LOCATION PRELOADED_STARTUP_LOCATION "")
|
||||
set_from_env(PRELOADED_SCRIPT_WHITELIST PRELOADED_SCRIPT_WHITELIST "")
|
||||
|
||||
set_from_env(BYPASS_SIGNING BYPASS_SIGNING 0)
|
||||
|
||||
message(STATUS "The RELEASE_TYPE variable is: ${RELEASE_TYPE}")
|
||||
|
|
|
@ -29,7 +29,8 @@ namespace BuildInfo {
|
|||
const QString BUILD_NUMBER = "@BUILD_NUMBER@";
|
||||
const QString BUILD_GLOBAL_SERVICES = "@BUILD_GLOBAL_SERVICES@";
|
||||
const QString BUILD_TIME = "@BUILD_TIME@";
|
||||
const QString INITIAL_STARTUP_LOCATION = "@INITIAL_STARTUP_LOCATION@";
|
||||
const QString PRELOADED_STARTUP_LOCATION = "@PRELOADED_STARTUP_LOCATION@";
|
||||
const QString PRELOADED_SCRIPT_WHITELIST = "@PRELOADED_SCRIPT_WHITELIST@";
|
||||
|
||||
enum BuildType {
|
||||
Dev,
|
||||
|
|
|
@ -4015,7 +4015,7 @@ void Application::handleSandboxStatus(QNetworkReply* reply) {
|
|||
|
||||
// If this is a first run we short-circuit the address passed in
|
||||
if (_firstRun.get()) {
|
||||
if (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty()) {
|
||||
if (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty()) {
|
||||
DependencyManager::get<LocationBookmarks>()->setHomeLocationToAddress(NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS);
|
||||
Menu::getInstance()->triggerOption(MenuOption::HomeLocation);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Stephen Birarda on 2014-09-10.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
// Copyright 2020 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -35,11 +36,11 @@ const QString REDIRECT_HIFI_ADDRESS = NetworkingConstants::REDIRECT_HIFI_ADDRESS
|
|||
const QString ADDRESS_MANAGER_SETTINGS_GROUP = "AddressManager";
|
||||
const QString SETTINGS_CURRENT_ADDRESS_KEY = "address";
|
||||
|
||||
const QString DEFAULT_VIRCADIA_ADDRESS = (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty())
|
||||
? BuildInfo::INITIAL_STARTUP_LOCATION
|
||||
const QString DEFAULT_VIRCADIA_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty())
|
||||
? BuildInfo::PRELOADED_STARTUP_LOCATION
|
||||
: NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS;
|
||||
const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::INITIAL_STARTUP_LOCATION.isEmpty())
|
||||
? BuildInfo::INITIAL_STARTUP_LOCATION
|
||||
const QString DEFAULT_HOME_ADDRESS = (!BuildInfo::PRELOADED_STARTUP_LOCATION.isEmpty())
|
||||
? BuildInfo::PRELOADED_STARTUP_LOCATION
|
||||
: NetworkingConstants::DEFAULT_VIRCADIA_ADDRESS;
|
||||
|
||||
Setting::Handle<QUrl> currentAddressHandle(QStringList() << ADDRESS_MANAGER_SETTINGS_GROUP << "address", DEFAULT_VIRCADIA_ADDRESS);
|
||||
|
|
|
@ -174,7 +174,6 @@ public:
|
|||
|
||||
QString getFilename() const;
|
||||
|
||||
|
||||
QList<EntityItemID> getListOfEntityScriptIDs();
|
||||
|
||||
/**jsdoc
|
||||
|
|
|
@ -68,6 +68,8 @@ void ScriptEngines::onErrorLoadingScript(const QString& url) {
|
|||
ScriptEngines::ScriptEngines(ScriptEngine::Context context, const QUrl& defaultScriptsOverride)
|
||||
: _context(context), _defaultScriptsOverride(defaultScriptsOverride)
|
||||
{
|
||||
scriptGatekeeper.initialize();
|
||||
|
||||
_scriptsModelFilter.setSourceModel(&_scriptsModel);
|
||||
_scriptsModelFilter.sort(0, Qt::AscendingOrder);
|
||||
_scriptsModelFilter.setDynamicSortFilter(true);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "ScriptEngine.h"
|
||||
#include "ScriptsModel.h"
|
||||
#include "ScriptsModelFilter.h"
|
||||
#include "ScriptGatekeeper.h"
|
||||
|
||||
class ScriptEngine;
|
||||
|
||||
|
@ -176,6 +177,8 @@ public:
|
|||
bool isStopped() const { return _isStopped; }
|
||||
|
||||
void addScriptEngine(ScriptEnginePointer);
|
||||
|
||||
ScriptGatekeeper scriptGatekeeper;
|
||||
|
||||
signals:
|
||||
|
||||
|
|
40
libraries/script-engine/src/ScriptGatekeeper.cpp
Normal file
40
libraries/script-engine/src/ScriptGatekeeper.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
//
|
||||
// ScriptGatekeeper.cpp
|
||||
// libraries/script-engine/src
|
||||
//
|
||||
// Created by Kalila L. on Mar 7 2021
|
||||
// Copyright 2021 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "ScriptGatekeeper.h"
|
||||
|
||||
#include "BuildInfo.h"
|
||||
#include "SettingHandle.h"
|
||||
|
||||
void ScriptGatekeeper::initialize() {
|
||||
if (_initialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
QVariant rawCurrentWhitelistValues = Setting::Handle<QVariant>(SCRIPT_WHITELIST_ENTRIES_KEY).get();
|
||||
QString settingsSafeValues = rawCurrentWhitelistValues.toString();
|
||||
|
||||
Setting::Handle<bool> whitelistEnabled { SCRIPT_WHITELIST_ENABLED_KEY, false };
|
||||
Setting::Handle<bool> isFirstRun { Settings::firstRun, true };
|
||||
|
||||
QString preloadedVal = BuildInfo::PRELOADED_SCRIPT_WHITELIST;
|
||||
|
||||
if (settingsSafeValues.isEmpty() && !preloadedVal.isEmpty() && isFirstRun.get()) {
|
||||
// We assume that the whitelist should be enabled if a preloaded whitelist is attached, so we activate it if it's not already active.
|
||||
if (!whitelistEnabled.get()) {
|
||||
whitelistEnabled.set(true);
|
||||
}
|
||||
|
||||
Setting::Handle<QVariant>(SCRIPT_WHITELIST_ENTRIES_KEY).set(preloadedVal);
|
||||
}
|
||||
|
||||
_initialized = true;
|
||||
}
|
29
libraries/script-engine/src/ScriptGatekeeper.h
Normal file
29
libraries/script-engine/src/ScriptGatekeeper.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
//
|
||||
// ScriptGatekeeper.h
|
||||
// libraries/script-engine/src
|
||||
//
|
||||
// Created by Kalila L. on Mar 7 2021
|
||||
// Copyright 2021 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef vircadia_ScriptGatekeeper_h
|
||||
#define vircadia_ScriptGatekeeper_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
|
||||
class ScriptGatekeeper : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
void initialize();
|
||||
|
||||
QString SCRIPT_WHITELIST_ENABLED_KEY{ "private/whitelistEnabled" };
|
||||
QString SCRIPT_WHITELIST_ENTRIES_KEY{ "private/settingsSafeURLS" };
|
||||
|
||||
private:
|
||||
bool _initialized { false };
|
||||
};
|
||||
|
||||
#endif // vircadia_ScriptGatekeeper_h
|
Loading…
Reference in a new issue