line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Parse::Snort::Strict; |
2
|
1
|
|
|
1
|
|
65018
|
use base qw(Parse::Snort); |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
476
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
9
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
46
|
|
5
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
6
|
1
|
|
|
1
|
|
4
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
7
|
1
|
|
|
1
|
|
4
|
use List::Util qw(any); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
55
|
|
8
|
1
|
|
|
1
|
|
420
|
use Sub::Util qw(set_subname); |
|
1
|
|
|
|
|
266
|
|
|
1
|
|
|
|
|
244
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.9'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# valid values for rule parts |
13
|
|
|
|
|
|
|
my $rule_parts_validation = { |
14
|
|
|
|
|
|
|
action => [qw( alert pass drop sdrop log activate dynamic reject )], |
15
|
|
|
|
|
|
|
proto => [qw( tcp udp ip icmp )], |
16
|
|
|
|
|
|
|
direction => [qw( -> <> <- )], |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# method generator for simple rule parts, copypasta reduction |
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my $generator = sub { |
22
|
|
|
|
|
|
|
# closures are teh awesome. |
23
|
|
|
|
|
|
|
my ($part,$value_ref) = @_; |
24
|
|
|
|
|
|
|
my $method = "SUPER::$part"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return sub { |
27
|
21
|
|
|
21
|
1
|
16699
|
my ($self,$value) = @_; |
|
|
|
|
21
|
1
|
|
|
|
|
|
|
21
|
1
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# do validation |
30
|
21
|
100
|
|
70
|
|
91
|
croak "Invalid rule $part: '$value'" unless (any { $value eq $_ } @{ $value_ref }); |
|
70
|
|
|
|
|
185
|
|
|
21
|
|
|
|
|
73
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# call parent's method for value setting |
33
|
18
|
|
|
|
|
99
|
$self->$method($value); |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
}; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
6
|
no strict qw(refs); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
59
|
|
38
|
|
|
|
|
|
|
while (my ($part,$value_ref) = each %$rule_parts_validation) { |
39
|
|
|
|
|
|
|
*{$part} = set_subname($part,$generator->($part,$value_ref)); |
40
|
|
|
|
|
|
|
} |
41
|
1
|
|
|
1
|
|
13
|
use strict qw(refs); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
53
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# TODO: validate formatting of src/dst address and port, make sure they look like $VARIABLEs or [a:range] |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
1; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__; |