Skip to content

Commit 36ab664

Browse files
authored
Merge pull request #69 from Botinoc/master
Fortinet: changing the logic for creating zones (VDOM mod)
2 parents 7238922 + ea025af commit 36ab664

File tree

1 file changed

+42
-33
lines changed

1 file changed

+42
-33
lines changed

FortinetMigration/FortiGateConverter.cs

Lines changed: 42 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,8 +3557,6 @@ public void Add_ParentLayer(CheckPoint_Package package, List<FgCommand> fgComman
35573557
cpRuleLayer.Rules.Add(cpSubRuleZone);
35583558
}
35593559

3560-
bool isIntfContainsAny = false;
3561-
35623560
NewFortigateAnalizStatistic._fullrullPackcount = fgCommandsList.Count;
35633561
foreach (FgCommand fgCommandE in fgCommandsList)
35643562
{
@@ -3616,20 +3614,20 @@ public void Add_ParentLayer(CheckPoint_Package package, List<FgCommand> fgComman
36163614
{
36173615
fgSrcIntfs = fgCommand_Set.Value.Trim('"').Split(new string[] { "\" \"" }, StringSplitOptions.None).ToArray();
36183616

3619-
if (Array.IndexOf(fgSrcIntfs.Select(s => s.ToLowerInvariant()).ToArray(), "any") > -1)
3620-
{
3621-
isIntfContainsAny = true;
3622-
}
3617+
//if (Array.IndexOf(fgSrcIntfs.Select(s => s.ToLowerInvariant()).ToArray(), "any") > -1)
3618+
//{
3619+
// isIntfContainsAny = true;
3620+
//}
36233621
}
36243622

36253623
if (fgCommand_Set.Field.Equals("dstintf"))
36263624
{
36273625
fgDstIntfs = fgCommand_Set.Value.Trim('"').Split(new string[] { "\" \"" }, StringSplitOptions.None).ToArray();
36283626

3629-
if (Array.IndexOf(fgDstIntfs.Select(s => s.ToLowerInvariant()).ToArray(), "any") > -1)
3630-
{
3631-
isIntfContainsAny = true;
3632-
}
3627+
//if (Array.IndexOf(fgDstIntfs.Select(s => s.ToLowerInvariant()).ToArray(), "any") > -1)
3628+
//{
3629+
// isIntfContainsAny = true;
3630+
//}
36333631
}
36343632

36353633

@@ -4108,41 +4106,52 @@ public void Add_ParentLayer(CheckPoint_Package package, List<FgCommand> fgComman
41084106

41094107
//if Src or Dst Intf DO NOT contain ANY then we create sub-layers
41104108
//otherwise policy is plain
4111-
if (!isIntfContainsAny)
4109+
List<CheckPoint_Rule> newRootRulesList = new List<CheckPoint_Rule>();
4110+
foreach (CheckPoint_Rule rootRule in rootRulesList)
41124111
{
4113-
package.ParentLayer.Rules.AddRange(rootRulesList);
4112+
if (!rootRule.Name.Contains("any"))
4113+
{
4114+
newRootRulesList.Add(rootRule);
4115+
}
4116+
}
4117+
package.ParentLayer.Rules.AddRange(newRootRulesList);
41144118

4115-
foreach (string key in extraZonesMap.Keys)
4119+
4120+
foreach (string key in extraZonesMap.Keys)
4121+
{
4122+
if (key.Contains("any"))
41164123
{
4117-
AddCpObjectToLocalMapper(key, extraZonesMap[key]);
4118-
AddCheckPointObject(extraZonesMap[key]);
4124+
continue;
41194125
}
4126+
AddCpObjectToLocalMapper(key, extraZonesMap[key]);
4127+
AddCheckPointObject(extraZonesMap[key]);
4128+
}
41204129

4121-
_warningsList.AddRange(extraZonesWarnMsgsList);
4130+
_warningsList.AddRange(extraZonesWarnMsgsList);
41224131

4123-
foreach (string key in rootLayersMap.Keys)
4132+
foreach (string key in rootLayersMap.Keys)
4133+
{
4134+
if (key.Contains("any"))
41244135
{
4125-
CheckPoint_Layer cpLayer = rootLayersMap[key];
4136+
continue;
4137+
}
4138+
CheckPoint_Layer cpLayer = rootLayersMap[key];
41264139

4127-
CheckPoint_Rule cpRuleCU = new CheckPoint_Rule();
4128-
if(!OptimizeConf) NewFortigateAnalizStatistic._cleanupServicesRuleCount++;
4129-
NewFortigateAnalizStatistic._totalServicesRulesCount++;
4130-
cpRuleCU.Name = "Sub-Policy Cleanup";
4131-
cpRuleCU.Layer = cpLayer.Name;
4140+
CheckPoint_Rule cpRuleCU = new CheckPoint_Rule();
4141+
if (!OptimizeConf) NewFortigateAnalizStatistic._cleanupServicesRuleCount++;
4142+
NewFortigateAnalizStatistic._totalServicesRulesCount++;
4143+
cpRuleCU.Name = "Sub-Policy Cleanup";
4144+
cpRuleCU.Layer = cpLayer.Name;
41324145

4133-
cpLayer.Rules.Add(cpRuleCU);
4146+
cpLayer.Rules.Add(cpRuleCU);
41344147

4135-
package.SubPolicies.Add(cpLayer);
4136-
validatePackage(package);
4137-
}
4148+
package.SubPolicies.Add(cpLayer);
4149+
validatePackage(package);
41384150
}
4139-
else
4151+
foreach (CheckPoint_Rule ruleAdd in realRulesList)
41404152
{
4141-
foreach (CheckPoint_Rule ruleAdd in realRulesList)
4142-
{
4143-
ruleAdd.Layer = package.ParentLayer.Name;
4144-
package.ParentLayer.Rules.Add(ruleAdd);
4145-
}
4153+
ruleAdd.Layer = package.ParentLayer.Name;
4154+
package.ParentLayer.Rules.Add(ruleAdd);
41464155
}
41474156

41484157
var cpRuleFake = new CheckPoint_Rule();

0 commit comments

Comments
 (0)