-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/uk-language
- Loading branch information
Showing
26 changed files
with
475 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
CSETWebApi/CSETWeb_Api/CSETWebCore.Business/Diagram/analysis/rules/MalcolmRules/Rule8.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
//////////////////////////////// | ||
// | ||
// Copyright 2023 Battelle Energy Alliance, LLC | ||
// | ||
// | ||
//////////////////////////////// | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using CSETWebCore.Business; | ||
using CSETWebCore.Business.BusinessManagers.Diagram.analysis; | ||
using CSETWebCore.Business.Diagram.Analysis; | ||
using CSETWebCore.Business.Diagram.analysis.rules; | ||
|
||
namespace CSETWeb_Api.BusinessLogic.BusinessManagers.Diagram.analysis.rules.MalcolmRules | ||
{ | ||
class Rule8 : AbstractRule, IRuleEvaluate | ||
{ | ||
|
||
private String rule8 = "The subnet should have an IPS (Intrusion Prevention System) inline to " + | ||
"provide a swift response if malicious traffic penetrates the firewall."; | ||
|
||
private SimplifiedNetwork network; | ||
|
||
public Rule8(SimplifiedNetwork simplifiedNetwork) | ||
{ | ||
this.network = simplifiedNetwork; | ||
} | ||
|
||
public List<IDiagramAnalysisNodeMessage> Evaluate() | ||
{ | ||
var firewalls = network.Nodes.Values.Where(x => x.IsFirewall).ToList(); | ||
foreach (var firewall in firewalls) | ||
{ | ||
Visited.Clear(); | ||
CheckRule8(firewall); | ||
} | ||
return this.Messages; | ||
} | ||
|
||
private HashSet<String> Visited = new HashSet<string>(); | ||
|
||
/// <summary> | ||
/// Check Firewall for IPS and IDS past the firewall | ||
/// </summary> | ||
/// <param name="multiServiceComponent"></param> | ||
/// <param name="visitedNodes"></param> | ||
private void CheckRule8(NetworkComponent firewall) | ||
{ | ||
// This code is here because component can be a multiple service component that is IPS | ||
if (firewall.IsIPS) | ||
{ | ||
return; | ||
} | ||
|
||
//recurse through all the edges and see if you can find an ids or ips | ||
//if it is in the same zone | ||
foreach (NetworkComponent child in firewall.Connections) | ||
{ | ||
if (child.IsInSameZone(firewall)) | ||
{ | ||
if (child.IsIPS) | ||
{ | ||
return; | ||
} | ||
else if (RecurseDownConnections(child, firewall)) | ||
{ | ||
return; | ||
} | ||
} | ||
} | ||
|
||
String componentName = "unnamed"; | ||
if (!String.IsNullOrWhiteSpace(firewall.ComponentName)) | ||
{ | ||
componentName = firewall.ComponentName; | ||
} | ||
|
||
String text = String.Format(rule8, componentName).Replace("\n", " "); | ||
SetNodeMessage(firewall, text, 8); // 8 because rule8 was violated | ||
} | ||
|
||
private bool RecurseDownConnections(NetworkComponent itemToCheck, NetworkComponent firewall) | ||
{ | ||
foreach (NetworkComponent child in itemToCheck.Connections) | ||
{ | ||
if (Visited.Add(child.ID)) | ||
{ | ||
//Trace.WriteLine("->" + child.ComponentName + ":" + firewall.ComponentName); | ||
if (child.IsInSameZone(firewall)) | ||
{ | ||
if (child.IsIPS) | ||
{ | ||
//Trace.WriteLine("Found it"); | ||
return true; | ||
} | ||
else if (RecurseDownConnections(child, firewall)) | ||
{ | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.