lucent firewall ruleset parser
Monday, December 1st, 2008Recently I had to go through the ruleset of a Lucent firewall, and the truth is that the export format of the rules is everything but easy to read.
The information is split into three files:
- rules file: Contains the rules, each one takes about 72 lines (rules have many properties, each property is written in a separate line). Rules match source hosts with destination hosts and services, no surprise there, but the value of any of this three key fields can be an alias.
- hosts file: in this file the aliases for host groups are defined.
- services file: service groups are defined here.
So the challenge here is: how do we merge this three files into something meaningful?
I know that purists can do this with a bash one-liner that uses grep, awk and sed, but ruby is my weapon of choice, so I created the lucent_metaparser.rb script. It basically takes the three files and applies some regular expressions to extract the information and store it into data structures and then outputs the rules in format that is easy to go through. Here is an example:-
1047: (CH43) 10.0.1.12 ---(both)--- RF400 [permit https - change 43] - enabled | pass CH43: tcp/443/* () 10.0.1.12 RF400: 192.168.1.140-192.168.1.145;192.252.1.155;192.252.1.120; 1048: (tcp/80) RF132 ---(both)--- PK012 [web traffic to the dmz - change 74] - enabled | pass tcp/80 RF132: 172.0.1.38-172.0.1.226 (external reverse proxies) PK012: 10.15.2.1;10.15.2.2; (internal servers)
I know that it is not perfect and there is room for improvement, but the idea is that the script can be used as a starting point for the review process, and hopefully this will save us some time in the future ![]()
