private void CreateURLFilterRule(string resourceURLString) { urlFilter.UpdateFilterRules(); // Check if resource URL gets allowed by current filter rules and if not, add a rule for the resource URL if (Uri.TryCreate(resourceURLString, UriKind.Absolute, out Uri resourceURL)) { if (urlFilter.TestURLAllowed(resourceURL) != URLFilterRuleActions.allow) { // If resource URL is not allowed: Create one using the full resource URL DictObj selectedResource = GetSelectedResource(); ListObj resourceURLFilterRules; if (selectedResource.TryGetValue(SEBSettings.KeyURLFilterRules, out object keyURLFilterRulesValue)) { resourceURLFilterRules = (ListObj)keyURLFilterRulesValue; } else { resourceURLFilterRules = new ListObj(); } DictObj newURLFilterRule = new DictObj(); newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleAction, (int)URLFilterRuleActions.allow); newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleActive, true); newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleExpression, resourceURLString); newURLFilterRule.Add(SEBSettings.KeyURLFilterRuleRegex, false); // Add this resource URL allow rule to the URL filters of this additional resource resourceURLFilterRules.Add(newURLFilterRule); selectedResource[SEBSettings.KeyURLFilterRules] = resourceURLFilterRules; // Update UI InitializeUrlFilters(selectedResource); } } }
private static void OnClientMessageBinary(byte[] obj) { // Check if we're running in exam mode already, if yes, then refuse to load a .seb file if (SEBClientInfo.examMode) { Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data is not allowed because it is already running in exam mode, sending command ReconfigureAborted to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted)); SebWindowsClientMain.LoadingSebFile(false); SebWindowsClientForm.ShowReconfigureNotAllowed(); return; } HasBeenReconfiguredByMessage = true; Logger.AddInformation("Received downloaded Config File data, " + obj.Length + " bytes. Sending command SebFileTransfer to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.SebFileTransfer, true)); if (SEBClientInfo.SebWindowsClientForm.ReconfigureWithSettings(obj)) { Logger.AddInformation("SEB was successfully reconfigured using the downloaded Config File data"); // Convert new URL Filter rules to XUL seb2 rules // and add Start URL to allowed rules SEBURLFilter urlFilter = new SEBURLFilter(); urlFilter.UpdateFilterRules(); // Create JSON object with XULRunner parameters to pass to firefox.exe as base64 string var xulRunnerSettings = DeepClone(SEBSettings.settingsCurrent); string XULRunnerParameters = SEBXulRunnerSettings.XULRunnerConfigDictionarySerialize(xulRunnerSettings); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.Reconfigure, new { configBase64 = XULRunnerParameters })); } else { Logger.AddInformation("Reconfiguring SEB using the downloaded Config File data failed, sending command ReconfigureAborted to browser"); SEBXULRunnerWebSocketServer.SendMessage(new SEBXULMessage(SEBXULMessage.SEBXULHandler.ReconfigureAborted)); } HasBeenReconfiguredByMessage = false; }