public override int Parse(ScreenOSCommand command, int baseParamIndex)
        {
            base.Parse(command, baseParamIndex);

            Protocol     = command.GetParam(baseParamIndex);
            ProtocolType = ProtocolTypeEnum.Sun_rpc;
            baseParamIndex++;

            if (command.GetParam(baseParamIndex) == "program")
            {
                string[] commandString = command.GetParam(baseParamIndex + 1).Split('-');
                if (commandString.Length == 2)
                {
                    ProgramStart = commandString[0];
                    if (int.Parse(ProgramStart) < _minProgram)
                    {
                        ProgramStart = _minProgram.ToString();
                    }
                    ProgramEnd = commandString[1];
                    if (int.Parse(ProgramEnd) > _maxProgram)
                    {
                        ProgramEnd = _maxProgram.ToString();
                    }

                    if (ProgramStart != ProgramEnd)
                    {
                        ConversionIncidentMessage = "ScreenOS SUN-RPC service object with program range is not supported in Check Point. Using only first program number in range";
                    }
                }
            }

            return(baseParamIndex + 2);
        }
Exemple #2
0
        private void ParseCommands(string filename)
        {
            string[] lines = File.ReadAllLines(filename, Encoding.GetEncoding("us-ascii", new EncoderReplacementFallback(""), new DecoderReplacementFallback("")));
            ParsedLines = lines.Count();

            int lineId = 0;

            foreach (string line in lines)
            {
                lineId++;

                // Check for an empty line or line with just spaces.
                if (line.Trim().Length == 0)
                {
                    continue;
                }

                ScreenOSCommand command = new ScreenOSCommand()
                {
                    Id   = lineId,
                    Text = line
                };

                _flatList.Add(FindCommand(command));
                _flatList.Last().Parse(command);
            }

            _screenOSCommands = _flatList.AggregateCommands();

            HandleDuplicatedAddressName();
        }
        public override int Parse(ScreenOSCommand command, int baseParamIndex)
        {
            base.Parse(command, baseParamIndex);

            /* Get Ip protocol id if exist*/
            ProtocolType = ProtocolTypeEnum.Ip;
            Protocol     = command.GetParam(baseParamIndex);
            baseParamIndex++;

            /* Source port range*/
            if (command.GetParam(baseParamIndex) == "src-port")
            {
                string[] stringCommand = command.GetParam(baseParamIndex + 1).Split('-');
                SrcPortStart = int.Parse(stringCommand[0]);
                SrcPortEnd   = int.Parse(stringCommand[1]);
            }

            /* Destination port range*/
            if (command.GetParam(baseParamIndex + 2) == "dst-port")
            {
                string[] stringCommand = command.GetParam(baseParamIndex + 3).Split('-');
                DestPortStart = int.Parse(stringCommand[0]);
                DestPortEnd   = int.Parse(stringCommand[1]);
            }

            return(baseParamIndex + 4);
        }
        public override int Parse(ScreenOSCommand command, int baseParamIndex)
        {
            base.Parse(command, baseParamIndex);

            Protocol     = command.GetParam(baseParamIndex);
            ProtocolType = ProtocolTypeEnum.Ms_rpc;
            baseParamIndex++;

            if (command.GetParam(baseParamIndex) == "uuid")
            {
                Uuid = command.GetParam(baseParamIndex + 1);
            }

            return(baseParamIndex + 2);
        }
Exemple #5
0
        private ScreenOSCommand FindCommand(ScreenOSCommand command)
        {
            string[] irrelevantCommands =
            {
                "key",    "clock",  "vrouter", "auto-route-export", "protocol", "area", "alg", "auth-server", "auth",   "admin", "flow", "hostname",   "pki",       "nsrp",
                "dns",    "user",   "ike",     "crypto-policy",     "ipsec",    "vpn",  "url", "syslog",      "nsmgmt", "ssh",   "snmp", "user-group", "scheduler", "console",
                "telnet", "snmpv3", "config"
            };

            string[] relevantCommands =
            {
                "dst-address", "src-address", "vsys-id"
            };

            if (irrelevantCommands.Contains(command.ObjectWord))
            {
                command.NotAnInterestingCommand = true;
                return(command);
            }

            if (relevantCommands.Contains(command.ObjectWord))
            {
                if (command.ObjectWord == "vsys-id")
                {
                    _numOfVsysInConfiguration++;
                }
                command.KnownCommand = true;
                return(command);
            }

            IEnumerable <Type> ScreenOSCommandTypes = Assembly.GetExecutingAssembly().GetTypes().Where(commandType => commandType.GetInterfaces().Contains(typeof(IScreenOSCommand)));

            foreach (Type commandType in ScreenOSCommandTypes)
            {
                object knownCommand     = Activator.CreateInstance(commandType);
                string knownCommandName = (string)knownCommand.GetType().GetMethod("Name").Invoke(knownCommand, null);

                if (knownCommandName == command.ObjectWord)
                {
                    ((ScreenOSCommand)knownCommand).Id   = command.Id;
                    ((ScreenOSCommand)knownCommand).Text = command.Text;
                    return((ScreenOSCommand)knownCommand);
                }
            }

            return(command);
        }
        public override int Parse(ScreenOSCommand command, int baseParamIndex)
        {
            int index = base.Parse(command, baseParamIndex);

            ProtocolType = ProtocolTypeEnum.Tcp;

            if (SrcPort != "any")
            {
                ConversionIncidentMessage = "ScreenOS service object with source port other then Any will not be considered during migration. Check Point service object is not supporting source port";
            }

            if (_destPortStart == 0)
            {
                string errorString = "ScreenOS service object with destination port 0 is not valid in Check Point. Modifying port to 1";
                ConversionIncidentMessage += string.IsNullOrEmpty(ConversionIncidentMessage) == false ?
                                             "\n" + errorString :
                                             errorString;
            }

            return(index);
        }
        public override int Parse(ScreenOSCommand command, int baseParamIndex)
        {
            base.Parse(command, baseParamIndex);

            ProtocolType = ProtocolTypeEnum.Icmp;
            Protocol     = command.GetParam(baseParamIndex);
            baseParamIndex++;

            /* Type*/
            if (command.GetParam(baseParamIndex) == "type")
            {
                IcmpType = byte.Parse(command.GetParam(baseParamIndex + 1));
            }

            /* Code*/
            if (command.GetParam(baseParamIndex + 2) == "code")
            {
                IcmpCode = byte.Parse(command.GetParam(baseParamIndex + 3));
            }

            return(baseParamIndex + 4);
        }
 public virtual int Parse(ScreenOSCommand command, int baseParamIndex)
 {
     return(baseParamIndex);
 }