Restore SEBPatch

This commit is contained in:
2025-06-01 11:44:20 +02:00
commit 8c656e3137
1297 changed files with 142172 additions and 0 deletions

View File

@@ -0,0 +1,239 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines all settings for the integrated browser application.
/// </summary>
[Serializable]
public class BrowserSettings
{
/// <summary>
/// The settings to be used for additional browser windows.
/// </summary>
public WindowSettings AdditionalWindow { get; set; }
/// <summary>
/// Determines whether the user will be allowed to download configuration files.
/// </summary>
public bool AllowConfigurationDownloads { get; set; }
/// <summary>
/// Determines whether the user will be allowed to select a custom location when down- or uploading a file (excluding configuration files).
/// </summary>
public bool AllowCustomDownAndUploadLocation { get; set; }
/// <summary>
/// Determines whether the user will be allowed to download files (excluding configuration files).
/// </summary>
public bool AllowDownloads { get; set; }
/// <summary>
/// Determines whether the user will be allowed to search page contents.
/// </summary>
public bool AllowFind { get; set; }
/// <summary>
/// Determines whether the user will be allowed to zoom webpages.
/// </summary>
public bool AllowPageZoom { get; set; }
/// <summary>
/// Determines whether the internal PDF reader of the browser application is enabled. If not, documents will be downloaded by default.
/// </summary>
public bool AllowPdfReader { get; set; }
/// <summary>
/// Determines whether the toolbar of the internal PDF reader (which allows to e.g. download or print a document) will be enabled.
/// </summary>
public bool AllowPdfReaderToolbar { get; set; }
/// <summary>
/// Determines whether the user will be allowed to print web content. To control printing in PDF documents, see <see cref="AllowPdfReaderToolbar"/>.
/// </summary>
public bool AllowPrint { get; set; }
/// <summary>
/// Determines whether spell checking is enabled for input fields.
/// </summary>
public bool AllowSpellChecking { get; set; }
/// <summary>
/// Determines whether the user will be allowed to upload files.
/// </summary>
public bool AllowUploads { get; set; }
/// <summary>
/// The salt value for the calculation of the browser exam key which is used for integrity checks with server applications (see also <see cref="SendBrowserExamKey"/>).
/// </summary>
public byte[] BrowserExamKeySalt { get; set; }
/// <summary>
/// The configuration key used for integrity checks with server applications (see also <see cref="SendConfigurationKey"/>).
/// </summary>
public string ConfigurationKey { get; set; }
/// <summary>
/// Determines whether the user needs to confirm the termination of SEB by <see cref="QuitUrl"/>.
/// </summary>
public bool ConfirmQuitUrl { get; set; }
/// <summary>
/// An optional, custom browser exam key used for integrity checks with server applications (see also <see cref="SendBrowserExamKey"/>).
/// </summary>
public string CustomBrowserExamKey { get; set; }
/// <summary>
/// The custom user agent to optionally be used for all requests.
/// </summary>
public string CustomUserAgent { get; set; }
/// <summary>
/// Determines whether the entire browser cache is deleted when terminating the application. IMPORTANT: If <see cref="DeleteCookiesOnShutdown"/>
/// is set to <c>false</c>, the cache will not be deleted in order to keep the cookies for the next session.
/// </summary>
public bool DeleteCacheOnShutdown { get; set; }
/// <summary>
/// Determines whether all cookies are deleted when terminating the browser application. IMPORTANT: The browser cache will not be deleted
/// if set to <c>false</c>, even if <see cref="DeleteCacheOnShutdown"/> is set to <c>true</c>!
/// </summary>
public bool DeleteCookiesOnShutdown { get; set; }
/// <summary>
/// Determines whether all cookies are deleted when starting the browser application.
/// </summary>
public bool DeleteCookiesOnStartup { get; set; }
/// <summary>
/// Defines a custom directory for down- and uploads. If not defined, all operations will be directed to the current user's download directory.
/// </summary>
public string DownAndUploadDirectory { get; set; }
/// <summary>
/// Determines whether the user is allowed to use the integrated browser application.
/// </summary>
public bool EnableBrowser { get; set; }
/// <summary>
/// The settings to be used for the browser request filter.
/// </summary>
public FilterSettings Filter { get; set; }
/// <summary>
/// An optional custom message shown before navigating home.
/// </summary>
public string HomeNavigationMessage { get; set; }
/// <summary>
/// Determines whether a password is required to navigate home.
/// </summary>
public bool HomeNavigationRequiresPassword { get; set; }
/// <summary>
/// The hash code of the password optionally required to navigate home.
/// </summary>
public string HomePasswordHash { get; set; }
/// <summary>
/// An optional custom URL to be used when navigating home.
/// </summary>
public string HomeUrl { get; set; }
/// <summary>
/// The settings to be used for the main browser window.
/// </summary>
public WindowSettings MainWindow { get; set; }
/// <summary>
/// Determines how attempts to open a popup are handled.
/// </summary>
public PopupPolicy PopupPolicy { get; set; }
/// <summary>
/// Determines the proxy settings to be used by the browser.
/// </summary>
public ProxySettings Proxy { get; set; }
/// <summary>
/// An URL which will initiate the termination of SEB (or reset the browser if <see cref="ResetOnQuitUrl"/> is <c>true</c>) when visited by the user.
/// </summary>
public string QuitUrl { get; set; }
/// <summary>
/// Determines whether the browser should be reset when a <see cref="QuitUrl"/> is detected.
/// </summary>
public bool ResetOnQuitUrl { get; set; }
/// <summary>
/// Determines whether the configuration key header is sent with every HTTP request (see also <see cref="ConfigurationKey"/>).
/// </summary>
public bool SendConfigurationKey { get; set; }
/// <summary>
/// Determines whether the browser exam key header is sent with every HTTP request (see also <see cref="BrowserExamKeySalt"/> and <see cref="CustomBrowserExamKey"/>).
/// </summary>
public bool SendBrowserExamKey { get; set; }
/// <summary>
/// Determines whether the user will be able to see the path of a file system element in the file system dialog (e.g. when down- or uploading a file).
/// </summary>
public bool ShowFileSystemElementPath { get; set; }
/// <summary>
/// The URL with which the main browser window will be loaded.
/// </summary>
public string StartUrl { get; set; }
/// <summary>
/// A query for the <see cref="StartUrl"/> which SEB automatically extracts from the configuration URL.
/// </summary>
public string StartUrlQuery { get; set; }
/// <summary>
/// Determines whether a custom user agent will be used for all requests, see <see cref="CustomUserAgent"/>.
/// </summary>
public bool UseCustomUserAgent { get; set; }
/// <summary>
/// Determines whether the browser application will use an isolated clipboard only working within the browser itself.
/// </summary>
public bool UseIsolatedClipboard { get; set; }
/// <summary>
/// Determines whether the <see cref="StartUrlQuery"/> will be appended to the <see cref="StartUrl"/>.
/// </summary>
public bool UseQueryParameter { get; set; }
/// <summary>
/// A custom suffix to be appended to the user agent.
/// </summary>
public string UserAgentSuffix { get; set; }
/// <summary>
/// Determines whether the start URL will be used when navigating home.
/// </summary>
public bool UseStartUrlAsHomeUrl { get; set; }
/// <summary>
/// Determines whether a temporary directory should be used for down- and uploads.
/// </summary>
public bool UseTemporaryDownAndUploadDirectory { get; set; }
public BrowserSettings()
{
AdditionalWindow = new WindowSettings();
Filter = new FilterSettings();
MainWindow = new WindowSettings();
Proxy = new ProxySettings();
}
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser.Filter
{
/// <summary>
/// Defines all possible results of a request filter operation.
/// </summary>
public enum FilterResult
{
/// <summary>
/// Indicates that a request should be allowed if a filter matches.
/// </summary>
Allow,
/// <summary>
/// Indicates that a request should be blocked if a filter matches.
/// </summary>
Block
}
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Settings.Browser.Filter
{
/// <summary>
/// Defines the settings for a request filter rule.
/// </summary>
[Serializable]
public class FilterRuleSettings
{
/// <summary>
/// The expression according to which requests should be filtered.
/// </summary>
public string Expression { get; set; }
/// <summary>
/// The filter result to be used when the <see cref="Expression"/> matches.
/// </summary>
public FilterResult Result { get; set; }
/// <summary>
/// The filter type which defines how the <see cref="Expression"/> is processed.
/// </summary>
public FilterRuleType Type { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser.Filter
{
/// <summary>
/// Defines all possible filter rule types.
/// </summary>
public enum FilterRuleType
{
/// <summary>
/// The filter rule is based on a regular expression.
/// </summary>
Regex,
/// <summary>
/// The filter rule is based on a simplified expression with wildcards.
/// </summary>
Simplified
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Collections.Generic;
using SafeExamBrowser.Settings.Browser.Filter;
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines all settings for the request filter of the browser.
/// </summary>
[Serializable]
public class FilterSettings
{
/// <summary>
/// Defines whether content requests for a web page should be filtered according to the defined <see cref="Rules"/>.
/// </summary>
public bool ProcessContentRequests { get; set; }
/// <summary>
/// Defines whether the main request for a web page should be filtered according to the defined <see cref="Rules"/>.
/// </summary>
public bool ProcessMainRequests { get; set; }
/// <summary>
/// Defines all rules to be used to filter web requests.
/// </summary>
public IList<FilterRuleSettings> Rules { get; set; }
public FilterSettings()
{
Rules = new List<FilterRuleSettings>();
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines all policies for browser window popups.
/// </summary>
public enum PopupPolicy
{
/// <summary>
/// Allows all popups.
/// </summary>
Allow,
/// <summary>
/// Allows only popups which target the same host as the window from which they originate.
/// </summary>
AllowSameHost,
/// <summary>
/// Allows only popups which target the same host as the window from which they originate and opens every request directly in the respective window.
/// </summary>
AllowSameHostAndWindow,
/// <summary>
/// Allows all popups but opens every request directly in the window from which it originates.
/// </summary>
AllowSameWindow,
/// <summary>
/// Blocks all popups.
/// </summary>
Block
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Settings.Browser.Proxy
{
/// <summary>
/// Defines the configuration of a proxy server.
/// </summary>
[Serializable]
public class ProxyConfiguration
{
/// <summary>
/// The host name or IP address of the proxy server.
/// </summary>
public string Host { get; set; }
/// <summary>
/// The password to be used for authentication.
/// </summary>
public string Password { get; set; }
/// <summary>
/// The port of the proxy server.
/// </summary>
public int Port { get; set; }
/// <summary>
/// The protocol of the proxy server.
/// </summary>
public ProxyProtocol Protocol { get; set; }
/// <summary>
/// Determines whether the proxy server requires authentication.
/// </summary>
public bool RequiresAuthentication { get; set; }
/// <summary>
/// The username to be used for authentication.
/// </summary>
public string Username { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser.Proxy
{
/// <summary>
/// Defines all currently supported proxy policies for the browser.
/// </summary>
public enum ProxyPolicy
{
/// <summary>
/// Use custom proxy settings as defined in <see cref="ProxySettings"/>.
/// </summary>
Custom,
/// <summary>
/// Use the proxy settings of the operating system (i.e. ignore all custom settings defined in <see cref="ProxySettings"/>).
/// </summary>
System
}
}

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser.Proxy
{
/// <summary>
/// Defines all protocols currently supported for proxies.
/// </summary>
public enum ProxyProtocol
{
Ftp,
Http,
Https,
Socks
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
using System.Collections.Generic;
using SafeExamBrowser.Settings.Browser.Proxy;
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines the proxy settings for the browser engine.
/// </summary>
[Serializable]
public class ProxySettings
{
/// <summary>
/// Determines whether proxy auto-configuration should be used. Requires a valid URL defined in <see cref="AutoConfigureUrl"/>.
/// </summary>
public bool AutoConfigure { get; set; }
/// <summary>
/// A valid URL to a proxy auto-configuration file (.pac). Is only evaluated if <see cref="AutoConfigure"/> is enabled.
/// </summary>
public string AutoConfigureUrl { get; set; }
/// <summary>
/// Forces proxy auto-detection by the browser engine.
/// </summary>
public bool AutoDetect { get; set; }
/// <summary>
/// A list of hosts for which all proxy settings should be bypassed.
/// </summary>
public IList<string> BypassList { get; set; }
/// <summary>
/// The proxy policy to be used.
/// </summary>
public ProxyPolicy Policy { get; set; }
/// <summary>
/// Defines all proxies to be used.
/// </summary>
public IList<ProxyConfiguration> Proxies { get; set; }
public ProxySettings()
{
BypassList = new List<string>();
Proxies = new List<ProxyConfiguration>();
}
}
}

View File

@@ -0,0 +1,55 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines all policies for handling of URLs in the user interface and log.
/// </summary>
public enum UrlPolicy
{
/// <summary>
/// Always show the URL of a resource instead of the title. Log URLs normally.
/// </summary>
Always,
/// <summary>
/// Show the URL until the title of a resource is available. Log URLs normally.
/// </summary>
BeforeTitle,
/// <summary>
/// Only show the URL on load errors, otherwise show the title of a resource. Only log URLs in error messages.
/// </summary>
LoadError,
/// <summary>
/// Never show the URL of a resource and do not log any URLs.
/// </summary>
Never
}
public static class UrlPolicyExtensions
{
/// <summary>
/// Indicates whether URLs may be logged normally.
/// </summary>
public static bool CanLog(this UrlPolicy policy)
{
return policy == UrlPolicy.Always || policy == UrlPolicy.BeforeTitle;
}
/// <summary>
/// Indicates whether URLs may be logged in case of an error.
/// </summary>
public static bool CanLogError(this UrlPolicy policy)
{
return policy.CanLog() || policy == UrlPolicy.LoadError;
}
}
}

View File

@@ -0,0 +1,20 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines the initial position of a browser window.
/// </summary>
public enum WindowPosition
{
Left,
Center,
Right
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (c) 2024 ETH Zürich, IT Services
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
using System;
namespace SafeExamBrowser.Settings.Browser
{
/// <summary>
/// Defines all settings for a window of the browser engine.
/// </summary>
[Serializable]
public class WindowSettings
{
/// <summary>
/// Optionally defines the height of the browser window in physical pixels.
/// </summary>
public int? AbsoluteHeight { get; set; }
/// <summary>
/// Optionally defines the width of the browser window in physical pixels.
/// </summary>
public int? AbsoluteWidth { get; set; }
/// <summary>
/// Determines whether the user will be allowed to change the URL in the address bar.
/// </summary>
public bool AllowAddressBar { get; set; }
/// <summary>
/// Determines whether the user will be allowed to navigate backwards.
/// </summary>
public bool AllowBackwardNavigation { get; set; }
/// <summary>
/// Determines whether the user will be allowed to open the developer console.
/// </summary>
public bool AllowDeveloperConsole { get; set; }
/// <summary>
/// Determines whether the user will be allowed to navigate forwards.
/// </summary>
public bool AllowForwardNavigation { get; set; }
/// <summary>
/// Determines whether the user will be allowed to reload webpages.
/// </summary>
public bool AllowReloading { get; set; }
/// <summary>
/// Determines whether the browser window will be rendered in fullscreen mode, i.e. without window frame.
/// </summary>
public bool FullScreenMode { get; set; }
/// <summary>
/// Determines the initial position of the browser window (if it is not maximized).
/// </summary>
public WindowPosition Position { get; set; }
/// <summary>
/// Optionally defines the height of the browser window as percentage of the working area height.
/// </summary>
public int? RelativeHeight { get; set; }
/// <summary>
/// Optionally defines the width of the browser window as percentage of the working area width.
/// </summary>
public int? RelativeWidth { get; set; }
/// <summary>
/// Determines whether the home button is visible.
/// </summary>
public bool ShowHomeButton { get; set; }
/// <summary>
/// Determines whether the reload button is visible.
/// </summary>
public bool ShowReloadButton { get; set; }
/// <summary>
/// Determines whether the user will need to confirm every reload attempt.
/// </summary>
public bool ShowReloadWarning { get; set; }
/// <summary>
/// Determines whether the window toolbar is visible.
/// </summary>
public bool ShowToolbar { get; set; }
/// <summary>
/// Determines how URLs are handled in the user interface and log.
/// </summary>
public UrlPolicy UrlPolicy { get; set; }
}
}