From dd82d45ed85f851a6e0bfb15e35edd43bf2f7983 Mon Sep 17 00:00:00 2001 From: Vichingo455 Date: Tue, 16 Sep 2025 16:32:31 +0200 Subject: [PATCH] Update Safe Exam Browser Patch to 3.10.0.826 --- .github/FUNDING.yml | 1 - .github/ISSUE_TEMPLATE/bug-report.md | 24 +- .github/ISSUE_TEMPLATE/config.yml | 11 - .github/ISSUE_TEMPLATE/feature-request.md | 20 + .github/workflows/codeql.yml | 54 ++ .../FactoryResult.cs | 5 + .../ILLink.Descriptors.LibraryBuild.xml | 8 - ...eExamBrowser.Applications.UnitTests.csproj | 111 +-- .../app.config | 16 +- .../packages.config | 41 +- .../ApplicationFactory.cs | 142 +++- .../Filters/RequestFilterTests.cs | 4 +- .../Filters/RuleFactoryTests.cs | 3 +- .../Filters/Rules/RegexRuleTests.cs | 6 +- .../Filters/Rules/SimplifiedRuleTests.cs | 5 +- .../Handlers/RequestHandlerTests.cs | 18 +- .../Handlers/ResourceHandlerTests.cs | 14 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../SafeExamBrowser.Browser.UnitTests.csproj | 135 ++-- SafeExamBrowser.Browser.UnitTests/app.config | 20 +- .../packages.config | 47 +- SafeExamBrowser.Browser/BrowserApplication.cs | 29 +- SafeExamBrowser.Browser/BrowserControl.cs | 50 +- SafeExamBrowser.Browser/BrowserWindow.cs | 38 +- SafeExamBrowser.Browser/Clipboard.cs | 4 +- SafeExamBrowser.Browser/Content/Clipboard.js | 320 +++++---- .../Events/ClipboardChangedEventHandler.cs | 2 +- .../Handlers/ContextMenuHandler.cs | 8 +- .../Handlers/CookieVisitor.cs | 49 ++ .../Handlers/DragHandler.cs | 2 +- .../Handlers/ResourceHandler.cs | 220 +----- .../Integrations/EdxIntegration.cs | 75 ++ .../Integrations/GenericIntegration.cs | 47 ++ .../Integrations/Integration.cs | 32 + .../Integrations/MoodleIntegration.cs | 226 ++++++ .../SafeExamBrowser.Browser.csproj | 38 +- .../Wrapper/CefSharpBrowserControl.cs | 27 +- .../Wrapper/CefSharpPopupControl.cs | 24 + .../Events/BeforeContextMenuEventHandler.cs | 9 +- .../Events/ContextMenuCommandEventHandler.cs | 14 + .../ContextMenuDismissedEventHandler.cs | 14 + .../Events/RunContextMenuEventHandler.cs | 14 + .../Handlers/ContextMenuHandlerSwitch.cs | 88 +++ .../Wrapper/ICefSharpControl.cs | 8 + SafeExamBrowser.Browser/packages.config | 8 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../Operations/ServerOperationTests.cs | 13 +- .../MonitoringResponsibilityTests.cs | 40 +- .../ProctoringResponsibilityTests.cs | 8 +- .../ShellResponsibilityTests.cs | 1 + .../SafeExamBrowser.Client.UnitTests.csproj | 120 ++-- SafeExamBrowser.Client.UnitTests/app.config | 18 +- .../packages.config | 45 +- SafeExamBrowser.Client/App.config | 2 +- SafeExamBrowser.Client/ClientContext.cs | 5 + SafeExamBrowser.Client/CompositionRoot.cs | 18 +- .../Operations/ClientOperation.cs | 7 +- .../Operations/PermissionOperation.cs | 60 ++ .../Operations/ProctoringOperation.cs | 7 - .../Operations/ServerOperation.cs | 27 +- .../Operations/ShellOperation.cs | 12 +- .../Operations/WindowGuardOperation.cs | 54 ++ .../Properties/AssemblyInfo.cs | 4 +- .../Responsibilities/ClientResponsibility.cs | 130 ++-- .../MonitoringResponsibility.cs | 21 +- .../ProctoringResponsibility.cs | 43 +- .../Responsibilities/ShellResponsibility.cs | 33 +- .../SafeExamBrowser.Client.csproj | 2 + .../Hosts/BaseHostTests.cs | 8 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../Proxies/BaseProxyTests.cs | 10 +- ...ExamBrowser.Communication.UnitTests.csproj | 116 +-- .../app.config | 16 +- .../packages.config | 43 +- .../Cryptography/KeyGeneratorTests.cs | 6 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - ...ExamBrowser.Configuration.UnitTests.csproj | 116 +-- .../SubStreamTests.cs | 21 +- .../app.config | 16 +- .../packages.config | 43 +- .../DataMapping/ProctoringDataMapper.cs | 23 +- .../DataMapping/SecurityDataMapper.cs | 12 + .../DataMapping/ServerDataMapper.cs | 20 + .../ConfigurationData/DataProcessor.cs | 10 +- .../ConfigurationData/DataValues.cs | 8 +- .../ConfigurationData/Keys.cs | 5 +- .../OperationModel/IOperation.cs | 5 - .../OperationModel/IOperationSequence.cs | 5 - .../SafeExamBrowser.Core.Contracts.csproj | 2 - .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../OperationModel/OperationSequenceTests.cs | 31 +- .../CommunicationHostOperationTests.cs | 14 +- .../Operations/DelegateOperationTests.cs | 2 - .../Operations/I18nOperationTests.cs | 1 - .../LazyInitializationOperationTests.cs | 17 +- .../SafeExamBrowser.Core.UnitTests.csproj | 116 +-- SafeExamBrowser.Core.UnitTests/app.config | 16 +- .../packages.config | 43 +- .../OperationModel/OperationSequence.cs | 6 - .../Operations/CommunicationHostOperation.cs | 5 +- .../Operations/DelegateOperation.cs | 7 +- .../Operations/I18nOperation.cs | 5 +- .../Operations/LazyInitializationOperation.cs | 26 +- SafeExamBrowser.I18n.Contracts/TextKey.cs | 6 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../SafeExamBrowser.I18n.UnitTests.csproj | 114 +-- .../XmlTextResourceTests.cs | 6 +- SafeExamBrowser.I18n.UnitTests/app.config | 16 +- .../packages.config | 43 +- SafeExamBrowser.I18n/Data/de.xml | 22 +- SafeExamBrowser.I18n/Data/en.xml | 20 +- SafeExamBrowser.I18n/Data/es.xml | 18 +- SafeExamBrowser.I18n/Data/et.xml | 18 +- SafeExamBrowser.I18n/Data/fr.xml | 18 +- SafeExamBrowser.I18n/Data/id.xml | 18 +- SafeExamBrowser.I18n/Data/it.xml | 18 +- SafeExamBrowser.I18n/Data/nl.xml | 34 +- SafeExamBrowser.I18n/Data/ro.xml | 18 +- SafeExamBrowser.I18n/Data/ru.xml | 18 +- SafeExamBrowser.I18n/Data/zh.xml | 18 +- .../AutoRestoreMechanismTests.cs | 3 +- .../FeatureConfigurationMonitorTests.cs | 3 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../SafeExamBrowser.Lockdown.UnitTests.csproj | 111 +-- SafeExamBrowser.Lockdown.UnitTests/app.config | 16 +- .../packages.config | 41 +- .../DefaultLogFormatterTests.cs | 3 +- .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../LoggerTests.cs | 59 +- .../SafeExamBrowser.Logging.UnitTests.csproj | 116 +-- SafeExamBrowser.Logging.UnitTests/app.config | 16 +- .../packages.config | 43 +- .../Events/SessionChangedEventHandler.cs | 4 +- .../Applications/ApplicationMonitor.cs | 2 +- .../Keyboard/KeyboardInterceptor.cs | 4 +- .../RemoteSessionDetector.cs | 1 + .../System/Components/SystemEvents.cs | 2 +- .../System/SystemSentinel.cs | 2 +- .../VirtualMachineDetector.cs | 17 +- .../IProctoringController.cs | 25 - .../ProctoringController.cs | 46 -- .../SafeExamBrowser.Proctoring.csproj | 14 +- .../ScreenProctoring/TransmissionSpooler.cs | 2 +- SafeExamBrowser.Proctoring/app.config | 2 +- SafeExamBrowser.Proctoring/packages.config | 8 +- .../Communication/ClientBridgeTests.cs | 149 ++++ .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../Operations/ClientOperationTests.cs | 62 +- .../ClientTerminationOperationTests.cs | 50 +- .../Operations/ConfigurationOperationTests.cs | 265 ++++--- .../Operations/DisclaimerOperationTests.cs | 114 ++- .../DisplayMonitorOperationTests.cs | 48 +- .../Operations/KioskModeOperationTests.cs | 33 +- .../Operations/RemoteSessionOperationTests.cs | 104 ++- .../Operations/ServerOperationTests.cs | 353 ++++----- .../Operations/ServiceOperationTests.cs | 52 +- .../SessionActivationOperationTests.cs | 36 +- .../SessionInitializationOperationTests.cs | 43 +- .../VirtualMachineOperationTests.cs | 22 +- .../ClientResponsibilityTests.cs | 83 +++ .../CommunicationResponsibilityTests.cs | 105 +++ .../ServiceResponsibilityTests.cs | 96 +++ .../SessionResponsibilityTests.cs | 144 ++++ .../RuntimeControllerTests.cs | 678 +----------------- .../SafeExamBrowser.Runtime.UnitTests.csproj | 121 ++-- SafeExamBrowser.Runtime.UnitTests/app.config | 16 +- .../packages.config | 43 +- SafeExamBrowser.Runtime/App.cs | 34 + .../Communication/ClientBridge.cs | 175 +++++ SafeExamBrowser.Runtime/CompositionRoot.cs | 172 +++-- .../ApplicationIntegrityOperation.cs | 3 +- .../Bootstrap/BootstrapOperationSequence.cs | 64 ++ .../Operations/ConfigurationBaseOperation.cs | 91 --- .../Operations/DisplayMonitorOperation.cs | 87 --- .../ClientConfigurationErrorMessageArgs.cs | 23 - .../Events/ExamSelectionEventArgs.cs | 26 - .../Events/InvalidDataMessageArgs.cs | 24 - .../Events/InvalidPasswordMessageArgs.cs | 23 - .../Operations/Events/MessageEventArgs.cs | 33 - .../Events/NotSupportedMessageArgs.cs | 24 - .../Events/PasswordRequiredEventArgs.cs | 20 - .../Events/ServerFailureEventArgs.cs | 27 - .../Events/UnexpectedErrorMessageArgs.cs | 24 - .../Events/VersionRestrictionMessageArgs.cs | 25 - .../Operations/RemoteSessionOperation.cs | 71 -- .../{ => Session}/ClientOperation.cs | 57 +- .../ClientTerminationOperation.cs | 8 +- .../Session/ConfigurationBaseOperation.cs | 128 ++++ .../{ => Session}/ConfigurationOperation.cs | 164 +++-- .../Operations/Session/Dependencies.cs | 43 ++ .../{ => Session}/DisclaimerOperation.cs | 36 +- .../Session/DisplayMonitorOperation.cs | 83 +++ .../{ => Session}/KioskModeOperation.cs | 33 +- .../Session/RemoteSessionOperation.cs | 60 ++ .../{ => Session}/ServerOperation.cs | 120 ++-- .../{ => Session}/ServiceOperation.cs | 97 ++- .../SessionActivationOperation.cs | 25 +- .../SessionInitializationOperation.cs | 31 +- .../SessionIntegrityOperation.cs | 18 +- .../Operations/Session/SessionOperation.cs | 88 +++ .../Session/SessionOperationSequence.cs | 63 ++ .../VersionRestrictionOperation.cs | 63 +- .../{ => Session}/VirtualMachineOperation.cs | 29 +- .../Operations/SessionOperation.cs | 33 - .../Properties/AssemblyInfo.cs | 9 +- .../Responsibilities/ClientResponsibility.cs | 93 +++ .../CommunicationResponsibility.cs | 84 +++ .../ErrorMessageResponsibility.cs | 67 ++ .../Responsibilities/RuntimeResponsibility.cs | 58 ++ .../Responsibilities/RuntimeTask.cs | 56 ++ .../Responsibilities/ServiceResponsibility.cs | 80 +++ .../Responsibilities/SessionResponsibility.cs | 181 +++++ .../{SessionContext.cs => RuntimeContext.cs} | 11 +- SafeExamBrowser.Runtime/RuntimeController.cs | 664 +---------------- .../SafeExamBrowser.Runtime.csproj | 58 +- .../Events/InvigilationEventHandler.cs | 8 +- .../IInvigilator.cs | 49 ++ .../SafeExamBrowser.Server.Contracts.csproj | 2 + SafeExamBrowser.Server/Invigilator.cs | 87 +++ SafeExamBrowser.Server/Parser.cs | 2 +- .../SafeExamBrowser.Server.csproj | 1 + .../ILLink.Descriptors.LibraryBuild.xml | 8 - .../SafeExamBrowser.Service.UnitTests.csproj | 111 +-- SafeExamBrowser.Service.UnitTests/app.config | 16 +- .../packages.config | 41 +- .../Operations/RestoreOperation.cs | 3 +- .../ServiceEventCleanupOperation.cs | 5 +- .../Operations/SessionActivationOperation.cs | 2 +- .../SessionInitializationOperation.cs | 4 +- .../Operations/SessionOperation.cs | 1 - .../Proctoring/ProctoringSettings.cs | 10 - .../SafeExamBrowser.Settings.csproj | 1 + .../Security/SecuritySettings.cs | 15 +- .../Server/InvigilationSettings.cs | 29 + .../Server/ServerSettings.cs | 10 + .../Network/INetworkAdapter.cs | 5 + .../Audio/Audio.cs | 13 +- .../Network/NetworkAdapter.cs | 26 +- .../SafeExamBrowser.SystemComponents.csproj | 2 +- .../Browser/IBrowserControl.cs | 4 +- .../IUserInterfaceFactory.cs | 10 +- .../IWindowGuard.cs | 32 + .../CancellationRequestedEventHandler.cs | 6 +- .../IProctoringFinalizationDialog.cs | 13 +- ...ExamBrowser.UserInterface.Contracts.csproj | 2 + .../ControlFactory.cs | 115 +++ .../ActionCenter/RaiseHandControl.xaml.cs | 28 +- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 28 +- .../FileSystemDialogFactory.cs | 19 +- .../MessageBoxFactory.cs | 2 +- ...feExamBrowser.UserInterface.Desktop.csproj | 2 + .../UserInterfaceFactory.cs | 154 +--- .../WindowFactory.cs | 157 ++++ .../Windows/ActionCenter.xaml.cs | 12 +- .../Windows/ProctoringFinalizationDialog.xaml | 8 +- .../ProctoringFinalizationDialog.xaml.cs | 79 +- .../ControlFactory.cs | 115 +++ .../ActionCenter/RaiseHandControl.xaml.cs | 28 +- .../Controls/Taskbar/RaiseHandControl.xaml.cs | 29 +- .../FileSystemDialogFactory.cs | 19 +- ...afeExamBrowser.UserInterface.Mobile.csproj | 2 + .../UserInterfaceFactory.cs | 154 +--- .../WindowFactory.cs | 157 ++++ .../Windows/ProctoringFinalizationDialog.xaml | 8 +- .../ProctoringFinalizationDialog.xaml.cs | 80 ++- .../Guardable.cs | 29 + ...afeExamBrowser.UserInterface.Shared.csproj | 2 + .../Utilities/WindowExtensions.cs | 31 +- .../WindowGuard.cs | 101 +++ .../Events/KeyModifier.cs | 3 +- .../Hooks/KeyboardHook.cs | 5 + .../Types/KBDLLHOOKSTRUCTFlags.cs | 11 +- SafeExamBrowser.sln | 1 + SebWindowsConfig/SEBSettings.cs | 2 +- SebWindowsConfig/SebWindowsConfig.csproj | 37 +- .../SebWindowsConfigForm.Designer.cs | 25 +- SebWindowsConfig/SebWindowsConfigForm.cs | 9 +- SebWindowsConfig/SebWindowsConfigForm.resx | 134 ++-- SebWindowsConfig/app.config | 25 +- SebWindowsConfig/packages.config | 10 +- Setup/Components/Application.wxs | 6 + Setup/Components/Application.xslt | 36 + Setup/Components/Configuration.wxs | 6 + Setup/Components/Configuration.xslt | 17 + Setup/Components/Reset.wxs | 6 + Setup/Components/Reset.xslt | 17 + Setup/Components/Service.wxs | 6 + Setup/Components/Service.xslt | 17 + Setup/Directories.wxs | 23 + Setup/LegacyCleanup.wxs | 7 + Setup/Product.wxs | 28 + Setup/Resources/Application.ico | Bin 0 -> 370070 bytes Setup/Resources/Banner.bmp | Bin 0 -> 85896 bytes Setup/Resources/ConfigurationFile.ico | Bin 0 -> 370070 bytes Setup/Resources/ConfigurationTool.ico | Bin 0 -> 53120 bytes Setup/Resources/Dialog.bmp | Bin 0 -> 461816 bytes Setup/Resources/License.rtf | 318 ++++++++ Setup/Resources/ResetUtility.ico | Bin 0 -> 58686 bytes Setup/Setup.wixproj | 165 +++++ Setup/Shortcuts.wxs | 18 + SetupBundle/Bundle.wxs | 33 + SetupBundle/DotNetFramework.wxs | 22 + SetupBundle/Resources/Logo.png | Bin 0 -> 8853 bytes SetupBundle/Resources/Theme.wxl | 63 ++ SetupBundle/Resources/Theme.xml | 84 +++ SetupBundle/SetupBundle.wixproj | 103 +++ SetupBundle/VisualCppRuntime.wxs | 29 + .../Resources/x64/SafeExamBrowser.Client.exe | Bin 836264 -> 832000 bytes .../x64/SafeExamBrowser.Configuration.dll | Bin 117928 -> 110592 bytes .../x64/SafeExamBrowser.Monitoring.dll | Bin 56488 -> 49152 bytes .../SafeExamBrowser.UserInterface.Desktop.dll | Bin 823976 -> 819712 bytes .../SafeExamBrowser.UserInterface.Mobile.dll | Bin 827048 -> 822272 bytes patch-seb/Resources/x64/SafeExamBrowser.exe | Bin 831144 -> 824320 bytes .../Resources/x86/SafeExamBrowser.Client.exe | Bin 836776 -> 832512 bytes .../x86/SafeExamBrowser.Configuration.dll | Bin 118952 -> 111104 bytes .../x86/SafeExamBrowser.Monitoring.dll | Bin 57512 -> 49664 bytes .../SafeExamBrowser.UserInterface.Desktop.dll | Bin 824488 -> 820224 bytes .../SafeExamBrowser.UserInterface.Mobile.dll | Bin 828072 -> 822784 bytes patch-seb/Resources/x86/SafeExamBrowser.exe | Bin 832168 -> 824320 bytes patch-seb/Variables.cs | 2 +- 320 files changed, 8445 insertions(+), 5295 deletions(-) delete mode 100644 .github/FUNDING.yml delete mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/workflows/codeql.yml delete mode 100644 SafeExamBrowser.Applications.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.Browser.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml create mode 100644 SafeExamBrowser.Browser/Handlers/CookieVisitor.cs create mode 100644 SafeExamBrowser.Browser/Integrations/EdxIntegration.cs create mode 100644 SafeExamBrowser.Browser/Integrations/GenericIntegration.cs create mode 100644 SafeExamBrowser.Browser/Integrations/Integration.cs create mode 100644 SafeExamBrowser.Browser/Integrations/MoodleIntegration.cs rename SafeExamBrowser.Runtime/Operations/Events/ConfigurationCompletedEventArgs.cs => SafeExamBrowser.Browser/Wrapper/Events/BeforeContextMenuEventHandler.cs (53%) create mode 100644 SafeExamBrowser.Browser/Wrapper/Events/ContextMenuCommandEventHandler.cs create mode 100644 SafeExamBrowser.Browser/Wrapper/Events/ContextMenuDismissedEventHandler.cs create mode 100644 SafeExamBrowser.Browser/Wrapper/Events/RunContextMenuEventHandler.cs create mode 100644 SafeExamBrowser.Browser/Wrapper/Handlers/ContextMenuHandlerSwitch.cs delete mode 100644 SafeExamBrowser.Client.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml create mode 100644 SafeExamBrowser.Client/Operations/PermissionOperation.cs create mode 100644 SafeExamBrowser.Client/Operations/WindowGuardOperation.cs delete mode 100644 SafeExamBrowser.Communication.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.Configuration.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.Core.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.I18n.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.Lockdown.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml delete mode 100644 SafeExamBrowser.Logging.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml create mode 100644 SafeExamBrowser.Runtime.UnitTests/Communication/ClientBridgeTests.cs delete mode 100644 SafeExamBrowser.Runtime.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml create mode 100644 SafeExamBrowser.Runtime.UnitTests/Responsibilities/ClientResponsibilityTests.cs create mode 100644 SafeExamBrowser.Runtime.UnitTests/Responsibilities/CommunicationResponsibilityTests.cs create mode 100644 SafeExamBrowser.Runtime.UnitTests/Responsibilities/ServiceResponsibilityTests.cs create mode 100644 SafeExamBrowser.Runtime.UnitTests/Responsibilities/SessionResponsibilityTests.cs create mode 100644 SafeExamBrowser.Runtime/Communication/ClientBridge.cs rename SafeExamBrowser.Runtime/Operations/{ => Bootstrap}/ApplicationIntegrityOperation.cs (92%) create mode 100644 SafeExamBrowser.Runtime/Operations/Bootstrap/BootstrapOperationSequence.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/ConfigurationBaseOperation.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/DisplayMonitorOperation.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/ClientConfigurationErrorMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/ExamSelectionEventArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/InvalidDataMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/InvalidPasswordMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/MessageEventArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/NotSupportedMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/PasswordRequiredEventArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/ServerFailureEventArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/UnexpectedErrorMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/Events/VersionRestrictionMessageArgs.cs delete mode 100644 SafeExamBrowser.Runtime/Operations/RemoteSessionOperation.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/ClientOperation.cs (78%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/ClientTerminationOperation.cs (79%) create mode 100644 SafeExamBrowser.Runtime/Operations/Session/ConfigurationBaseOperation.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/ConfigurationOperation.cs (72%) create mode 100644 SafeExamBrowser.Runtime/Operations/Session/Dependencies.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/DisclaimerOperation.cs (61%) create mode 100644 SafeExamBrowser.Runtime/Operations/Session/DisplayMonitorOperation.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/KioskModeOperation.cs (78%) create mode 100644 SafeExamBrowser.Runtime/Operations/Session/RemoteSessionOperation.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/ServerOperation.cs (70%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/ServiceOperation.cs (65%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/SessionActivationOperation.cs (62%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/SessionInitializationOperation.cs (60%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/SessionIntegrityOperation.cs (79%) create mode 100644 SafeExamBrowser.Runtime/Operations/Session/SessionOperation.cs create mode 100644 SafeExamBrowser.Runtime/Operations/Session/SessionOperationSequence.cs rename SafeExamBrowser.Runtime/Operations/{ => Session}/VersionRestrictionOperation.cs (66%) rename SafeExamBrowser.Runtime/Operations/{ => Session}/VirtualMachineOperation.cs (62%) delete mode 100644 SafeExamBrowser.Runtime/Operations/SessionOperation.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/ClientResponsibility.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/CommunicationResponsibility.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/ErrorMessageResponsibility.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/RuntimeResponsibility.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/RuntimeTask.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/ServiceResponsibility.cs create mode 100644 SafeExamBrowser.Runtime/Responsibilities/SessionResponsibility.cs rename SafeExamBrowser.Runtime/{SessionContext.cs => RuntimeContext.cs} (79%) rename SafeExamBrowser.Core.Contracts/OperationModel/Events/ActionRequiredEventArgs.cs => SafeExamBrowser.Server.Contracts/Events/InvigilationEventHandler.cs (58%) create mode 100644 SafeExamBrowser.Server.Contracts/IInvigilator.cs create mode 100644 SafeExamBrowser.Server/Invigilator.cs delete mode 100644 SafeExamBrowser.Service.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml create mode 100644 SafeExamBrowser.Settings/Server/InvigilationSettings.cs create mode 100644 SafeExamBrowser.UserInterface.Contracts/IWindowGuard.cs rename SafeExamBrowser.Core.Contracts/OperationModel/Events/ActionRequiredEventHandler.cs => SafeExamBrowser.UserInterface.Contracts/Proctoring/Events/CancellationRequestedEventHandler.cs (55%) create mode 100644 SafeExamBrowser.UserInterface.Desktop/ControlFactory.cs create mode 100644 SafeExamBrowser.UserInterface.Desktop/WindowFactory.cs create mode 100644 SafeExamBrowser.UserInterface.Mobile/ControlFactory.cs create mode 100644 SafeExamBrowser.UserInterface.Mobile/WindowFactory.cs create mode 100644 SafeExamBrowser.UserInterface.Shared/Guardable.cs create mode 100644 SafeExamBrowser.UserInterface.Shared/WindowGuard.cs create mode 100644 Setup/Components/Application.wxs create mode 100644 Setup/Components/Application.xslt create mode 100644 Setup/Components/Configuration.wxs create mode 100644 Setup/Components/Configuration.xslt create mode 100644 Setup/Components/Reset.wxs create mode 100644 Setup/Components/Reset.xslt create mode 100644 Setup/Components/Service.wxs create mode 100644 Setup/Components/Service.xslt create mode 100644 Setup/Directories.wxs create mode 100644 Setup/LegacyCleanup.wxs create mode 100644 Setup/Product.wxs create mode 100644 Setup/Resources/Application.ico create mode 100644 Setup/Resources/Banner.bmp create mode 100644 Setup/Resources/ConfigurationFile.ico create mode 100644 Setup/Resources/ConfigurationTool.ico create mode 100644 Setup/Resources/Dialog.bmp create mode 100644 Setup/Resources/License.rtf create mode 100644 Setup/Resources/ResetUtility.ico create mode 100644 Setup/Setup.wixproj create mode 100644 Setup/Shortcuts.wxs create mode 100644 SetupBundle/Bundle.wxs create mode 100644 SetupBundle/DotNetFramework.wxs create mode 100644 SetupBundle/Resources/Logo.png create mode 100644 SetupBundle/Resources/Theme.wxl create mode 100644 SetupBundle/Resources/Theme.xml create mode 100644 SetupBundle/SetupBundle.wixproj create mode 100644 SetupBundle/VisualCppRuntime.wxs diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index a85367c..0000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1 +0,0 @@ -custom: ["https://web.satispay.com/app/match/link/user/S6Y-CON--88923C30-BEC8-487E-9814-68A5449F7D83?amount=500¤cy=EUR"] diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 1379a16..78d4791 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -1,18 +1,17 @@ --- name: Bug Report -about: Create a bug report to help us improve the Safe Exam Browser Patch +about: Create a bug report to help us improve Safe Exam Browser. title: '' -labels: bug -assignees: theitaliandeveloper +labels: '' +assignees: dbuechel --- > [!IMPORTANT] -> - Please _always_ consult the FAQs before creating an issue: https://git.vichingo455.freeddns.org/school-cheating/SEBPatch/wiki/FAQs. +> - Please _always_ consult the documentation first before creating a bug report: https://safeexambrowser.org/windows/win_usermanual_en.html. > - Please _always_ attach the log file(s) of the affected session(s)! They can be found under `%LocalAppData%\SafeExamBrowser\Logs`. -> - Please follow this issue template. Saves me some work while reading all issues. -**Bug Description** +**Describe the Bug** A clear and concise description of what the bug is. **Steps to Reproduce** @@ -30,18 +29,7 @@ If applicable, add screenshots to help explain your problem. **Version Information** - OS: [e.g. Windows 10 Professional, Version 1803] - - SEB version: [e.g. SEB 3.0.1] - - SEB patch version: [e.g. 1.5.1] + - SEB-Version [e.g. SEB 3.0.1] **Additional Context** Add any other context about the problem here. - -**SEB Logs** -``` -Paste here the SEB logs -``` - -**SEB Patcher logs (optional, read below)** -``` -Paste here the SEB patcher logs (if issue is SEB patcher related, else just ignore this section) -``` diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index e6c5858..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,11 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: FAQs - url: https://git.vichingo455.freeddns.org/school-cheating/SEBPatch/wiki/FAQs - about: Before opening an issue, check out the FAQs. Any issue corresponding to the FAQs will be ignored and closed. - - name: Questions - url: https://github.com/theitaliandeveloper/SEBPatch/discussions/categories/q-a - about: Ask questions here about the Safe Exam Browser Patch - - name: Feature Requests - url: https://github.com/theitaliandeveloper/SEBPatch/discussions/categories/ideas - about: Propose a feature or a change for the Safe Exam Browser Patch. diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md new file mode 100644 index 0000000..325de6b --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.md @@ -0,0 +1,20 @@ +--- +name: Feature Request +about: Suggest an idea or new feature for Safe Exam Browser. +title: '' +labels: '' +assignees: dbuechel + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..57f0fc6 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,54 @@ +name: "CodeQL" + +on: + push: + branches: [ "master", "*" ] + pull_request: + branches: [ "master", "*" ] + schedule: + - cron: '0 0 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: "windows-latest" + timeout-minutes: 360 + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'csharp', 'javascript-typescript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + queries: security-extended,security-and-quality + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" diff --git a/SafeExamBrowser.Applications.Contracts/FactoryResult.cs b/SafeExamBrowser.Applications.Contracts/FactoryResult.cs index 0286fe7..3624615 100644 --- a/SafeExamBrowser.Applications.Contracts/FactoryResult.cs +++ b/SafeExamBrowser.Applications.Contracts/FactoryResult.cs @@ -18,6 +18,11 @@ namespace SafeExamBrowser.Applications.Contracts /// Error, + /// + /// The application has been found but is invalid (e.g. because it is not the correct version or has been manipulated). + /// + Invalid, + /// /// The application could not be found on the system. /// diff --git a/SafeExamBrowser.Applications.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml b/SafeExamBrowser.Applications.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index a42d7f0..0000000 --- a/SafeExamBrowser.Applications.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/SafeExamBrowser.Applications.UnitTests/SafeExamBrowser.Applications.UnitTests.csproj b/SafeExamBrowser.Applications.UnitTests/SafeExamBrowser.Applications.UnitTests.csproj index 466b469..9edb9a2 100644 --- a/SafeExamBrowser.Applications.UnitTests/SafeExamBrowser.Applications.UnitTests.csproj +++ b/SafeExamBrowser.Applications.UnitTests/SafeExamBrowser.Applications.UnitTests.csproj @@ -1,9 +1,9 @@  - - - - + + + + Debug @@ -63,78 +63,82 @@ - ..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll + ..\packages\Castle.Core.5.2.1\lib\net462\Castle.Core.dll - - ..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll - - ..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - ..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - ..\packages\Microsoft.Testing.Platform.1.5.2\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + ..\packages\Microsoft.Testing.Platform.1.8.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.14.1\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + True - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - ..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + ..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - ..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + ..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll ..\packages\Moq.4.20.72\lib\net462\Moq.dll - - ..\packages\NuGet.Frameworks.6.12.1\lib\net472\NuGet.Frameworks.dll + + ..\packages\NuGet.Frameworks.6.14.0\lib\net472\NuGet.Frameworks.dll - - ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll - - ..\packages\System.Collections.Immutable.9.0.1\lib\net462\System.Collections.Immutable.dll + + ..\packages\System.Collections.Immutable.9.0.8\lib\net462\System.Collections.Immutable.dll - - ..\packages\System.Diagnostics.DiagnosticSource.9.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + ..\packages\System.Diagnostics.DiagnosticSource.9.0.8\lib\net462\System.Diagnostics.DiagnosticSource.dll - - ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Reflection.Metadata.9.0.1\lib\net462\System.Reflection.Metadata.dll + + ..\packages\System.Reflection.Metadata.9.0.8\lib\net462\System.Reflection.Metadata.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll @@ -184,11 +188,8 @@ - - - - - + + @@ -196,13 +197,17 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - + + + + + + + + - - + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Applications.UnitTests/app.config b/SafeExamBrowser.Applications.UnitTests/app.config index 4a41c0d..259d7bd 100644 --- a/SafeExamBrowser.Applications.UnitTests/app.config +++ b/SafeExamBrowser.Applications.UnitTests/app.config @@ -4,7 +4,7 @@ - + @@ -12,31 +12,31 @@ - + - + - + - + - + - + - + diff --git a/SafeExamBrowser.Applications.UnitTests/packages.config b/SafeExamBrowser.Applications.UnitTests/packages.config index da1800f..32e6e53 100644 --- a/SafeExamBrowser.Applications.UnitTests/packages.config +++ b/SafeExamBrowser.Applications.UnitTests/packages.config @@ -1,24 +1,25 @@  - - - - - - - - + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Applications/ApplicationFactory.cs b/SafeExamBrowser.Applications/ApplicationFactory.cs index 497600d..cb940b2 100644 --- a/SafeExamBrowser.Applications/ApplicationFactory.cs +++ b/SafeExamBrowser.Applications/ApplicationFactory.cs @@ -8,7 +8,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.Security.Cryptography.X509Certificates; using SafeExamBrowser.Applications.Contracts; using SafeExamBrowser.Logging.Contracts; using SafeExamBrowser.Monitoring.Contracts.Applications; @@ -43,42 +45,62 @@ namespace SafeExamBrowser.Applications public FactoryResult TryCreate(WhitelistApplication settings, out IApplication application) { var name = $"'{settings.DisplayName}' ({settings.ExecutableName})"; + var result = FactoryResult.Error; application = default; try { - var success = TryFindApplication(settings, out var executablePath); + var found = TryFindApplication(settings, out var executablePath); + var valid = found && VerifyApplication(executablePath, name, settings); - if (success) + if (found && valid) { - application = BuildApplication(executablePath, settings); - application.Initialize(); - - logger.Debug($"Successfully initialized application {name}."); - - return FactoryResult.Success; + application = InitializeApplication(executablePath, settings); } - logger.Error($"Could not find application {name}!"); - - return FactoryResult.NotFound; + result = DetermineResult(name, found, valid); } catch (Exception e) { logger.Error($"Unexpected error while trying to initialize application {name}!", e); } - return FactoryResult.Error; + return result; } - private IApplication BuildApplication(string executablePath, WhitelistApplication settings) + private FactoryResult DetermineResult(string name, bool found, bool valid) + { + var result = default(FactoryResult); + + if (!found) + { + result = FactoryResult.NotFound; + logger.Error($"Could not find application {name}!"); + } + else if (!valid) + { + result = FactoryResult.Invalid; + logger.Error($"The application {name} is not valid or has been manipulated!"); + } + else + { + result = FactoryResult.Success; + logger.Debug($"Successfully initialized application {name}."); + } + + return result; + } + + private IApplication InitializeApplication(string executablePath, WhitelistApplication settings) { const int ONE_SECOND = 1000; var applicationLogger = logger.CloneFor(settings.DisplayName); var application = new ExternalApplication(applicationMonitor, executablePath, applicationLogger, nativeMethods, processFactory, settings, ONE_SECOND); + application.Initialize(); + return application; } @@ -143,5 +165,99 @@ namespace SafeExamBrowser.Applications return default; } + + private bool VerifyApplication(string executablePath, string name, WhitelistApplication settings) + { + var valid = true; + + valid &= VerifyName(executablePath, name, settings); + valid &= VerifyOriginalName(executablePath, name, settings); + valid &= VerifySignature(executablePath, name, settings); + + return valid; + } + + private bool VerifyName(string executablePath, string name, WhitelistApplication settings) + { + var valid = Path.GetFileName(executablePath).Equals(settings.ExecutableName, StringComparison.OrdinalIgnoreCase); + + if (!valid) + { + logger.Warn($"The executable name of application {name} at '{executablePath}' does not match the configured value!"); + } + + return valid; + } + + private bool VerifyOriginalName(string executablePath, string name, WhitelistApplication settings) + { + var ignoreOriginalName = string.IsNullOrWhiteSpace(settings.OriginalName); + var valid = ignoreOriginalName; + + if (!ignoreOriginalName && TryLoadOriginalName(executablePath, out var originalName)) + { + valid = originalName.Equals(settings.OriginalName, StringComparison.OrdinalIgnoreCase); + } + + if (!valid) + { + logger.Warn($"The original name of application {name} at '{executablePath}' does not match the configured value!"); + } + + return valid; + } + + private bool VerifySignature(string executablePath, string name, WhitelistApplication settings) + { + var ignoreSignature = string.IsNullOrWhiteSpace(settings.Signature); + var valid = ignoreSignature; + + if (!ignoreSignature && TryLoadSignature(executablePath, out var signature)) + { + valid = signature.Equals(settings.Signature, StringComparison.OrdinalIgnoreCase); + } + + if (!valid) + { + logger.Warn($"The signature of application {name} at '{executablePath}' does not match the configured value!"); + } + + return valid; + } + + private bool TryLoadOriginalName(string path, out string originalName) + { + originalName = default; + + try + { + originalName = FileVersionInfo.GetVersionInfo(path).OriginalFilename; + } + catch (Exception e) + { + logger.Error($"Failed to load original name for '{path}'!", e); + } + + return originalName != default; + } + + private bool TryLoadSignature(string path, out string signature) + { + signature = default; + + try + { + using (var certificate = X509Certificate.CreateFromSignedFile(path)) + { + signature = certificate.GetCertHashString(); + } + } + catch (Exception e) + { + logger.Error($"Failed to load signature for '{path}'!", e); + } + + return signature != default; + } } } diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs index 941c5b5..c674dcf 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/RequestFilterTests.cs @@ -102,13 +102,13 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters } [TestMethod] - [ExpectedException(typeof(NotImplementedException))] public void MustNotAllowUnsupportedResult() { var rule = new Mock(); rule.SetupGet(r => r.Result).Returns((FilterResult) (-1)); - sut.Load(rule.Object); + + Assert.ThrowsExactly(() => sut.Load(rule.Object)); } } } diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs index 85c3b33..86f731e 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/RuleFactoryTests.cs @@ -33,10 +33,9 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters } [TestMethod] - [ExpectedException(typeof(NotImplementedException))] public void MustNotAllowUnsupportedFilterType() { - sut.CreateRule((FilterRuleType) (-1)); + Assert.ThrowsExactly(() => sut.CreateRule((FilterRuleType) (-1))); } } } diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs index d4af886..0c3d612 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/RegexRuleTests.cs @@ -51,17 +51,15 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules } [TestMethod] - [ExpectedException(typeof(ArgumentNullException))] public void MustNotAllowUndefinedExpression() { - sut.Initialize(new FilterRuleSettings()); + Assert.ThrowsExactly(() => sut.Initialize(new FilterRuleSettings())); } [TestMethod] - [ExpectedException(typeof(ArgumentException))] public void MustValidateExpression() { - sut.Initialize(new FilterRuleSettings { Expression = "ç+\"}%&*/(+)=?{=*+¦]@#°§]`?´^¨'°[¬|¢" }); + Assert.ThrowsExactly(() => sut.Initialize(new FilterRuleSettings { Expression = "ç+\"}%&*/(+)=?{=*+¦]@#°§]`?´^¨'°[¬|¢" })); } } } diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs index 4d49b26..d28a48c 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs @@ -51,10 +51,9 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules } [TestMethod] - [ExpectedException(typeof(ArgumentNullException))] public void MustNotAllowUndefinedExpression() { - sut.Initialize(new FilterRuleSettings()); + Assert.ThrowsExactly(() => sut.Initialize(new FilterRuleSettings())); } [TestMethod] @@ -73,7 +72,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules foreach (var expression in invalid) { - Assert.ThrowsException(() => sut.Initialize(new FilterRuleSettings { Expression = expression })); + Assert.ThrowsExactly(() => sut.Initialize(new FilterRuleSettings { Expression = expression })); } } diff --git a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs index 64c554f..440451c 100644 --- a/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Handlers/RequestHandlerTests.cs @@ -12,6 +12,7 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Handlers; +using SafeExamBrowser.Browser.Integrations; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Configuration.Contracts.Cryptography; using SafeExamBrowser.I18n.Contracts; @@ -41,6 +42,13 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers [TestInitialize] public void Initialize() { + var integrations = new Integration[] + { + new GenericIntegration(new Mock().Object), + new EdxIntegration(new Mock().Object), + new MoodleIntegration(new Mock().Object) + }; + appConfig = new AppConfig(); filter = new Mock(); keyGenerator = new Mock(); @@ -48,7 +56,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers settings = new BrowserSettings(); windowSettings = new WindowSettings(); text = new Mock(); - resourceHandler = new ResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, default, settings, windowSettings, text.Object); + resourceHandler = new ResourceHandler(appConfig, filter.Object, integrations, keyGenerator.Object, logger.Object, default, settings, windowSettings, text.Object); sut = new TestableRequestHandler(appConfig, filter.Object, logger.Object, resourceHandler, settings, windowSettings); } @@ -285,7 +293,13 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers private class TestableRequestHandler : RequestHandler { - internal TestableRequestHandler(AppConfig appConfig, IRequestFilter filter, ILogger logger, ResourceHandler resourceHandler, BrowserSettings settings, WindowSettings windowSettings) : base(appConfig, filter, logger, resourceHandler, settings, windowSettings) + internal TestableRequestHandler( + AppConfig appConfig, + IRequestFilter filter, + ILogger logger, + ResourceHandler resourceHandler, + BrowserSettings settings, + WindowSettings windowSettings) : base(appConfig, filter, logger, resourceHandler, settings, windowSettings) { } diff --git a/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs b/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs index 92b3111..c8ec7b7 100644 --- a/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Handlers/ResourceHandlerTests.cs @@ -7,6 +7,7 @@ */ using System; +using System.Collections.Generic; using System.Collections.Specialized; using System.Net.Mime; using System.Threading; @@ -14,6 +15,7 @@ using CefSharp; using Microsoft.VisualStudio.TestTools.UnitTesting; using Moq; using SafeExamBrowser.Browser.Contracts.Filters; +using SafeExamBrowser.Browser.Integrations; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Configuration.Contracts.Cryptography; using SafeExamBrowser.I18n.Contracts; @@ -42,6 +44,13 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers [TestInitialize] public void Initialize() { + var integrations = new Integration[] + { + new GenericIntegration(new Mock().Object), + new EdxIntegration(new Mock().Object), + new MoodleIntegration(new Mock().Object) + }; + appConfig = new AppConfig(); filter = new Mock(); keyGenerator = new Mock(); @@ -50,7 +59,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers windowSettings = new WindowSettings(); text = new Mock(); - sut = new TestableResourceHandler(appConfig, filter.Object, keyGenerator.Object, logger.Object, SessionMode.Server, settings, windowSettings, text.Object); + sut = new TestableResourceHandler(appConfig, filter.Object, integrations, keyGenerator.Object, logger.Object, SessionMode.Server, settings, windowSettings, text.Object); } [TestMethod] @@ -325,12 +334,13 @@ namespace SafeExamBrowser.Browser.UnitTests.Handlers internal TestableResourceHandler( AppConfig appConfig, IRequestFilter filter, + IEnumerable integrations, IKeyGenerator keyGenerator, ILogger logger, SessionMode sessionMode, BrowserSettings settings, WindowSettings windowSettings, - IText text) : base(appConfig, filter, keyGenerator, logger, sessionMode, settings, windowSettings, text) + IText text) : base(appConfig, filter, integrations, keyGenerator, logger, sessionMode, settings, windowSettings, text) { } diff --git a/SafeExamBrowser.Browser.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml b/SafeExamBrowser.Browser.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml deleted file mode 100644 index a42d7f0..0000000 --- a/SafeExamBrowser.Browser.UnitTests/ILLink/ILLink.Descriptors.LibraryBuild.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/SafeExamBrowser.Browser.UnitTests/SafeExamBrowser.Browser.UnitTests.csproj b/SafeExamBrowser.Browser.UnitTests/SafeExamBrowser.Browser.UnitTests.csproj index df98d1c..41b0683 100644 --- a/SafeExamBrowser.Browser.UnitTests/SafeExamBrowser.Browser.UnitTests.csproj +++ b/SafeExamBrowser.Browser.UnitTests/SafeExamBrowser.Browser.UnitTests.csproj @@ -1,12 +1,12 @@  - - - - - - - + + + + + + + Debug @@ -66,84 +66,88 @@ - ..\packages\Castle.Core.5.1.1\lib\net462\Castle.Core.dll + ..\packages\Castle.Core.5.2.1\lib\net462\Castle.Core.dll - - ..\packages\CefSharp.Common.131.3.50\lib\net462\CefSharp.dll + + ..\packages\CefSharp.Common.139.0.280\lib\net462\CefSharp.dll - - ..\packages\CefSharp.Common.131.3.50\lib\net462\CefSharp.Core.dll + + ..\packages\CefSharp.Common.139.0.280\lib\net462\CefSharp.Core.dll - - ..\packages\Microsoft.ApplicationInsights.2.22.0\lib\net46\Microsoft.ApplicationInsights.dll + + ..\packages\Microsoft.ApplicationInsights.2.23.0\lib\net46\Microsoft.ApplicationInsights.dll - - ..\packages\Microsoft.Testing.Platform.MSBuild.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll + + ..\packages\Microsoft.Testing.Platform.MSBuild.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.MSBuild.dll - - ..\packages\Microsoft.Testing.Extensions.Telemetry.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll + + ..\packages\Microsoft.Testing.Extensions.Telemetry.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.Telemetry.dll - - ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll + + ..\packages\Microsoft.Testing.Extensions.TrxReport.Abstractions.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.TrxReport.Abstractions.dll - - ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.5.2\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll + + ..\packages\Microsoft.Testing.Extensions.VSTestBridge.1.8.3\lib\netstandard2.0\Microsoft.Testing.Extensions.VSTestBridge.dll - - ..\packages\Microsoft.Testing.Platform.1.5.2\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + ..\packages\Microsoft.Testing.Platform.1.8.3\lib\netstandard2.0\Microsoft.Testing.Platform.dll + + + ..\packages\Microsoft.TestPlatform.AdapterUtilities.17.14.1\lib\net462\Microsoft.TestPlatform.AdapterUtilities.dll + True - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.CoreUtilities.dll - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.TestPlatform.PlatformAbstractions.dll - ..\packages\Microsoft.TestPlatform.ObjectModel.17.12.0\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll + ..\packages\Microsoft.TestPlatform.ObjectModel.17.14.1\lib\net462\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll - ..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll + ..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.dll - ..\packages\MSTest.TestFramework.3.7.2\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll + ..\packages\MSTest.TestFramework.3.10.3\lib\net462\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll ..\packages\Moq.4.20.72\lib\net462\Moq.dll - - ..\packages\NuGet.Frameworks.6.12.1\lib\net472\NuGet.Frameworks.dll + + ..\packages\NuGet.Frameworks.6.14.0\lib\net472\NuGet.Frameworks.dll - - ..\packages\System.Buffers.4.6.0\lib\net462\System.Buffers.dll + + ..\packages\System.Buffers.4.6.1\lib\net462\System.Buffers.dll - - ..\packages\System.Collections.Immutable.9.0.1\lib\net462\System.Collections.Immutable.dll + + ..\packages\System.Collections.Immutable.9.0.8\lib\net462\System.Collections.Immutable.dll - - ..\packages\System.Diagnostics.DiagnosticSource.9.0.1\lib\net462\System.Diagnostics.DiagnosticSource.dll + + ..\packages\System.Diagnostics.DiagnosticSource.9.0.8\lib\net462\System.Diagnostics.DiagnosticSource.dll - - ..\packages\System.Memory.4.6.0\lib\net462\System.Memory.dll + + ..\packages\System.Memory.4.6.3\lib\net462\System.Memory.dll - - ..\packages\System.Numerics.Vectors.4.6.0\lib\net462\System.Numerics.Vectors.dll + + ..\packages\System.Numerics.Vectors.4.6.1\lib\net462\System.Numerics.Vectors.dll - - ..\packages\System.Reflection.Metadata.9.0.1\lib\net462\System.Reflection.Metadata.dll + + ..\packages\System.Reflection.Metadata.9.0.8\lib\net462\System.Reflection.Metadata.dll - - ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.0\lib\net462\System.Runtime.CompilerServices.Unsafe.dll + + ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll - - ..\packages\System.Threading.Tasks.Extensions.4.6.0\lib\net462\System.Threading.Tasks.Extensions.dll + + ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll @@ -200,11 +204,8 @@ - - - - - + + @@ -212,18 +213,22 @@ This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - - - - - - - - - - + + + + + + + + + + + + - - - + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Browser.UnitTests/app.config b/SafeExamBrowser.Browser.UnitTests/app.config index ee510e7..4e06ece 100644 --- a/SafeExamBrowser.Browser.UnitTests/app.config +++ b/SafeExamBrowser.Browser.UnitTests/app.config @@ -4,11 +4,11 @@ - + - + @@ -16,11 +16,11 @@ - + - + @@ -28,27 +28,27 @@ - + - + - + - + - + - + diff --git a/SafeExamBrowser.Browser.UnitTests/packages.config b/SafeExamBrowser.Browser.UnitTests/packages.config index da5a1d8..71db1cb 100644 --- a/SafeExamBrowser.Browser.UnitTests/packages.config +++ b/SafeExamBrowser.Browser.UnitTests/packages.config @@ -1,27 +1,28 @@  - - - - - - - - - - - + + + + + + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + \ No newline at end of file diff --git a/SafeExamBrowser.Browser/BrowserApplication.cs b/SafeExamBrowser.Browser/BrowserApplication.cs index b27ed63..17c8962 100644 --- a/SafeExamBrowser.Browser/BrowserApplication.cs +++ b/SafeExamBrowser.Browser/BrowserApplication.cs @@ -18,6 +18,7 @@ using SafeExamBrowser.Applications.Contracts.Events; using SafeExamBrowser.Browser.Contracts; using SafeExamBrowser.Browser.Contracts.Events; using SafeExamBrowser.Browser.Events; +using SafeExamBrowser.Browser.Integrations; using SafeExamBrowser.Configuration.Contracts; using SafeExamBrowser.Configuration.Contracts.Cryptography; using SafeExamBrowser.Core.Contracts.Resources.Icons; @@ -119,6 +120,7 @@ namespace SafeExamBrowser.Browser InitializeCookies(); InitializeDownAndUploadDirectory(); InitializeIntegrityKeys(); + InitializePreferences(); logger.Info("Initialized browser."); } @@ -167,6 +169,12 @@ namespace SafeExamBrowser.Browser private void CreateNewWindow(PopupRequestedEventArgs args = default) { var id = ++windowIdCounter; + var integrations = new Integration[] + { + new GenericIntegration(logger.CloneFor($"{nameof(GenericIntegration)} #{id}")), + new EdxIntegration(logger.CloneFor($"{nameof(EdxIntegration)} #{id}")), + new MoodleIntegration(logger.CloneFor($"{nameof(MoodleIntegration)} #{id}")) + }; var isMainWindow = windows.Count == 0; var startUrl = GenerateStartUrl(); var windowLogger = logger.CloneFor($"Browser Window #{id}"); @@ -176,6 +184,7 @@ namespace SafeExamBrowser.Browser fileSystemDialog, hashAlgorithm, id, + integrations, isMainWindow, keyGenerator, windowLogger, @@ -197,7 +206,7 @@ namespace SafeExamBrowser.Browser window.InitializeControl(); windows.Add(window); - if (args != default(PopupRequestedEventArgs)) + if (args != default) { args.Window = window; } @@ -213,6 +222,7 @@ namespace SafeExamBrowser.Browser private void DeleteCookies() { var callback = new TaskDeleteCookiesCallback(); + var cookieManager = Cef.GetGlobalCookieManager(); callback.Task.ContinueWith(task => { @@ -226,7 +236,7 @@ namespace SafeExamBrowser.Browser } }); - if (Cef.GetGlobalCookieManager().DeleteCookies(callback: callback)) + if (cookieManager != default && cookieManager.DeleteCookies(callback: callback)) { logger.Debug("Successfully initiated cookie deletion."); } @@ -316,7 +326,6 @@ namespace SafeExamBrowser.Browser cefSettings.AcceptLanguageList = CultureInfo.CurrentUICulture.Name; cefSettings.CachePath = appConfig.BrowserCachePath; - cefSettings.CefCommandLineArgs.Add("touch-events", "enabled"); cefSettings.LogFile = appConfig.BrowserLogFilePath; cefSettings.LogSeverity = error ? LogSeverity.Error : (warning ? LogSeverity.Warning : LogSeverity.Info); cefSettings.PersistSessionCookies = !settings.DeleteCookiesOnStartup || !settings.DeleteCookiesOnShutdown; @@ -339,6 +348,7 @@ namespace SafeExamBrowser.Browser cefSettings.CefCommandLineArgs.Add("enable-media-stream"); cefSettings.CefCommandLineArgs.Add("enable-usermedia-screen-capturing"); + cefSettings.CefCommandLineArgs.Add("touch-events", "enabled"); cefSettings.CefCommandLineArgs.Add("use-fake-ui-for-media-stream"); InitializeProxySettings(cefSettings); @@ -417,6 +427,18 @@ namespace SafeExamBrowser.Browser } } + private void InitializePreferences() + { + Cef.UIThreadTaskFactory.StartNew(() => + { + using (var requestContext = Cef.GetGlobalRequestContext()) + { + requestContext.SetPreference("autofill.credit_card_enabled", false, out _); + requestContext.SetPreference("autofill.profile_enabled", false, out _); + } + }); + } + private void InitializeProxySettings(CefSettings cefSettings) { if (settings.Proxy.Policy == ProxyPolicy.Custom) @@ -506,6 +528,7 @@ namespace SafeExamBrowser.Browser private void Window_ResetRequested() { logger.Info("Attempting to reset browser..."); + AwaitReady(); foreach (var window in windows) diff --git a/SafeExamBrowser.Browser/BrowserControl.cs b/SafeExamBrowser.Browser/BrowserControl.cs index 445d4b0..823dc66 100644 --- a/SafeExamBrowser.Browser/BrowserControl.cs +++ b/SafeExamBrowser.Browser/BrowserControl.cs @@ -23,6 +23,7 @@ namespace SafeExamBrowser.Browser { private readonly Clipboard clipboard; private readonly ICefSharpControl control; + private readonly IContextMenuHandler contextMenuHandler; private readonly IDialogHandler dialogHandler; private readonly IDisplayHandler displayHandler; private readonly IDownloadHandler downloadHandler; @@ -47,6 +48,7 @@ namespace SafeExamBrowser.Browser public BrowserControl( Clipboard clipboard, ICefSharpControl control, + IContextMenuHandler contextMenuHandler, IDialogHandler dialogHandler, IDisplayHandler displayHandler, IDownloadHandler downloadHandler, @@ -58,8 +60,9 @@ namespace SafeExamBrowser.Browser IRenderProcessMessageHandler renderProcessMessageHandler, IRequestHandler requestHandler) { - this.control = control; this.clipboard = clipboard; + this.control = control; + this.contextMenuHandler = contextMenuHandler; this.dialogHandler = dialogHandler; this.displayHandler = displayHandler; this.downloadHandler = downloadHandler; @@ -89,31 +92,20 @@ namespace SafeExamBrowser.Browser { control.BrowserCore.EvaluateScriptAsync(code).ContinueWith(t => { - callback?.Invoke(new JavaScriptResult - { - Message = t.Result.Message, - Result = t.Result.Result, - Success = t.Result.Success - }); + callback?.Invoke(new JavaScriptResult { Message = t.Result.Message, Result = t.Result.Result, Success = t.Result.Success }); }); } else { - Task.Run(() => callback?.Invoke(new JavaScriptResult - { - Message = "JavaScript can't be executed in main frame!", - Success = false - })); + Task.Run(() => callback?.Invoke(new JavaScriptResult { Message = "Could not execute JavaScript in main frame!", Success = false })); } } catch (Exception e) { - logger.Error($"Failed to execute JavaScript '{(code.Length > 50 ? code.Take(50) : code)}'!", e); - Task.Run(() => callback?.Invoke(new JavaScriptResult - { - Message = $"Failed to execute JavaScript '{(code.Length > 50 ? code.Take(50) : code)}'! Reason: {e.Message}", - Success = false - })); + var message = "Failed to execute JavaScript in main frame!"; + + logger.Error(message, e); + Task.Run(() => callback?.Invoke(new JavaScriptResult { Message = $"{message} Reason: {e.Message}", Success = false })); } } @@ -129,10 +121,13 @@ namespace SafeExamBrowser.Browser control.AddressChanged += (o, e) => AddressChanged?.Invoke(e.Address); control.AuthCredentialsRequired += (w, b, o, i, h, p, r, s, c, a) => a.Value = requestHandler.GetAuthCredentials(w, b, o, i, h, p, r, s, c); control.BeforeBrowse += (w, b, f, r, u, i, a) => a.Value = requestHandler.OnBeforeBrowse(w, b, f, r, u, i); + control.BeforeContextMenu += (w, b, f, p, m) => contextMenuHandler.OnBeforeContextMenu(w, b, f, p, m); control.BeforeDownload += (w, b, d, c, a) => a.Value = a.Value = downloadHandler.OnBeforeDownload(w, b, d, c); control.BeforeUnloadDialog += (w, b, m, r, c, a) => a.Value = javaScriptDialogHandler.OnBeforeUnloadDialog(w, b, m, r, c); control.CanDownload += (w, b, u, r, a) => a.Value = downloadHandler.CanDownload(w, b, u, r); control.ContextCreated += (w, b, f) => renderProcessMessageHandler.OnContextCreated(w, b, f); + control.ContextMenuCommand += (w, b, f, p, c, e, a) => a.Value = contextMenuHandler.OnContextMenuCommand(w, b, f, p, c, e); + control.ContextMenuDismissed += (w, b, f) => contextMenuHandler.OnContextMenuDismissed(w, b, f); control.ContextReleased += (w, b, f) => renderProcessMessageHandler.OnContextReleased(w, b, f); control.DialogClosed += (w, b) => javaScriptDialogHandler.OnDialogClosed(w, b); control.DownloadUpdated += (w, b, d, c) => downloadHandler.OnDownloadUpdated(w, b, d, c); @@ -152,6 +147,7 @@ namespace SafeExamBrowser.Browser control.PreKeyEvent += (IWebBrowser w, IBrowser b, KeyType t, int k, int n, CefEventFlags m, bool i, ref bool s, GenericEventArgs a) => a.Value = keyboardHandler.OnPreKeyEvent(w, b, t, k, n, m, i, ref s); control.ResetDialogState += (w, b) => javaScriptDialogHandler.OnResetDialogState(w, b); control.ResourceRequestHandlerRequired += (IWebBrowser w, IBrowser b, IFrame f, IRequest r, bool n, bool d, string i, ref bool h, ResourceRequestEventArgs a) => a.Handler = requestHandler.GetResourceRequestHandler(w, b, f, r, n, d, i, ref h); + control.RunContextMenu += (w, b, f, p, m, c, a) => a.Value = contextMenuHandler.RunContextMenu(w, b, f, p, m, c); control.SetFocus += (w, b, s, a) => a.Value = focusHandler.OnSetFocus(w, b, s); control.TakeFocus += (w, b, n) => focusHandler.OnTakeFocus(w, b, n); control.TitleChanged += (o, e) => TitleChanged?.Invoke(e.Title); @@ -193,9 +189,21 @@ namespace SafeExamBrowser.Browser control.BrowserCore.SetZoomLevel(level); } - private void Clipboard_Changed(long id) + private void Clipboard_Changed(string id) { - ExecuteJavaScript($"SafeExamBrowser.clipboard.update({id}, '{clipboard.Content}');"); + try + { + var script = $"SafeExamBrowser.clipboard.update('{id}', '{clipboard.Content}');"; + + foreach (var frame in control.BrowserCore?.GetAllFrames() ?? Enumerable.Empty