From 48511d996cc33cdc961610962d54c521f0ce53e9 Mon Sep 17 00:00:00 2001 From: dbuechel Date: Thu, 21 Nov 2019 16:07:13 +0100 Subject: [PATCH] SEBWIN-312: Ensured application start failure does not crash SEB and clarified URL filter specification. --- .../ExternalApplication.cs | 24 ++++++++++++------- .../Filters/Rules/SimplifiedRuleTests.cs | 7 +++--- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/SafeExamBrowser.Applications/ExternalApplication.cs b/SafeExamBrowser.Applications/ExternalApplication.cs index 7d1a3cfe..b9f845b1 100644 --- a/SafeExamBrowser.Applications/ExternalApplication.cs +++ b/SafeExamBrowser.Applications/ExternalApplication.cs @@ -6,6 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +using System; using System.Collections.Generic; using System.Linq; using SafeExamBrowser.Applications.Contracts; @@ -42,17 +43,22 @@ namespace SafeExamBrowser.Applications public void Start() { - logger.Info("Starting application..."); + try + { + logger.Info("Starting application..."); - // TODO: Ensure that SEB does not crash if an application cannot be started!! + var process = processFactory.StartNew(executablePath); + var id = new ApplicationInstanceIdentifier(process.Id); + var instance = new ExternalApplicationInstance(Info.Icon, id, logger.CloneFor($"{Info.Name} {id}"), process); - var process = processFactory.StartNew(executablePath); - var id = new ApplicationInstanceIdentifier(process.Id); - var instance = new ExternalApplicationInstance(Info.Icon, id, logger.CloneFor($"{Info.Name} {id}"), process); - - instance.Initialize(); - instances.Add(instance); - InstanceStarted?.Invoke(instance); + instance.Initialize(); + instances.Add(instance); + InstanceStarted?.Invoke(instance); + } + catch (Exception e) + { + logger.Error("Failed to start application!", e); + } } public void Terminate() diff --git a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs index cce6bd45..e88952d6 100644 --- a/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs +++ b/SafeExamBrowser.Browser.UnitTests/Filters/Rules/SimplifiedRuleTests.cs @@ -84,10 +84,11 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules var positive = new[] { $"scheme://{expression}", - $"scheme://{expression}.org", // TODO: Is this correct? + // TODO: All these below should not be allowed! + $"scheme://{expression}.org", $"scheme://www.{expression}.org", $"scheme://subdomain.{expression}.com", - $"scheme://www.realhost.{expression}", // TODO: Is this correct? + $"scheme://www.realhost.{expression}", $"scheme://subdomain-1.subdomain-2.{expression}.org", $"scheme://user:password@www.{expression}.org/path/file.txt?param=123#fragment" }; @@ -122,7 +123,7 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules "scheme://hostname-12.org", "scheme://hostname-abc-def-123-456.org", "scheme://www.hostname-abc.org", - "scheme://www.realhost.hostname", //TODO: Is this correct? + "scheme://www.realhost.hostname", "scheme://subdomain.hostname-xyz.com", "scheme://hostname.realhost.org", "scheme://subdomain.hostname.realhost.org",