pfsense/pfsense — pull request #876 by kantlivelong (2014-01-05 07:01:29+00:00)
Title: process_alias_urltable: Added data validation

I had noticed that if the downloaded file had unexpected data(In my case a simple
tag) that pf would stop functioning properly. I have added data validation and tested various entries. Skipped entries are logged to the system log.

Test results below:

192.168.1.100	|| OK
2607:f0d0:1002:51::4	|| OK
192.168.256.100	|| SKIPPED
2607:x0d0:1002:51::4	|| SKIPPED

192.168.1.0/24	|| OK
2001:1234::5678:5:6:7:8/64	|| OK
192.168.1x.0/24	|| SKIPPED
2001:1234::x678:5:6:7:8/64	|| SKIPPED

!192.168.1.100	|| OK
!2607:f0d0:1002:51::4	|| OK
!192.168.256.100	|| SKIPPED
!2607:x0d0:1002:51::4	|| SKIPPED

!192.168.1.0/24	|| OK
!2001:1234::5678:5:6:7:8/64	|| OK
!192.168.1x.0/24	|| SKIPPED
!2001:1234::x678:5:6:7:8/64	|| SKIPPED

192.168.1.0/24 #test	|| OK (Rewritten as 192.168.1.0/24)
192.168.1.0/24 ;test	|| OK (Rewritten as 192.168.1.0/24)
!192.168.1.0/24 #test	|| OK (Rewritten as !192.168.1.0/24)
!192.168.1.0/24 ;test	|| OK (Rewritten as !192.168.1.0/24)

123.123.123.0/24\n	|| OK (Rewritten as 123.123.123.0/24)
123.123.123.0/24
|| OK (Rewritten as 123.123.123.0/24)
123.123.123.0/24
|| OK (Rewritten as 123.123.123.0/24)
123.123.123.0/24
|| OK (Rewritten as 123.123.123.0/24)

####comment_test	|| SKIPPED
## ##comment_test	|| SKIPPED
#comment_test	|| SKIPPED
# comment_test	|| SKIPPED
# comment_test	|| SKIPPED
#!11.11.1.0/24 #test	|| SKIPPED

Error establishing DB connection	|| SKIPPED
br
|| SKIPPED

/***************** BELOW IS FOR "urltable_ports" WHEN SUPPORTED *****************/
80	|| OK
443	|| OK
!21	|| OK
8080:8082	|| OK
8080-8082	|| OK (Rewritten as 8080:8082)
!8080:8082	|| OK
!8080-8082	|| OK (Rewritten as !8080:8082)
8080 : 8082	|| OK (Rewritten as 8080:8082)
8080 - 8082	|| OK (Rewritten as 8080:8082)
8080,8081,8082	|| SKIPPED

8000 #test	|| OK (Rewritten as 8000)
8001 ;test	|| OK (Rewritten as 8001)
!8000 #test	|| OK (Rewritten as !8000)
!8001 ;test	|| OK (Rewritten as !8001)

1234\n	|| OK
1234
|| OK (Rewritten to 1234\n)
1234
|| OK (Rewritten to 1234\n)
1234
|| OK (Rewritten to 1234\n)