| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package PIX::Object; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
36
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
730
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.10'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=pod |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
PIX::Object - Factory class for the various object-groups found in a PIX config |
|
15
|
|
|
|
|
|
|
from a PIX::Walker object. This object is not meant to be instantiated directly. |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
PIX::Walker uses this factory class to create perl objects for each object-group |
|
20
|
|
|
|
|
|
|
found within a firewall configuration. Programs will interface with this object |
|
21
|
|
|
|
|
|
|
but will practically never instantiate objects from this factory directly. |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
B, B, B |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 EXAMPLE |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
my $obj = new PIX::Object($type, $name, $conf_block, $pix_walker_ref); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 METHODS |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=over |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub new { |
|
38
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
|
39
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
|
40
|
0
|
|
|
|
|
|
my $self = { }; |
|
41
|
0
|
|
|
|
|
|
my ($type, $name, $config, $walker) = @_; |
|
42
|
0
|
0
|
0
|
|
|
|
croak("Must provide the object-group type, name and config block") unless ($type and $name and $config); |
|
|
|
|
0
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$class .= "::" . lc $type; |
|
45
|
0
|
|
|
|
|
|
$class =~ tr/-/_/; |
|
46
|
0
|
|
|
|
|
|
eval "require $class"; |
|
47
|
0
|
0
|
|
|
|
|
if ($@) { |
|
48
|
0
|
|
|
|
|
|
die("Object subclass '$class' has compile time errors:\n$@\n"); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$self->{class} = $class; |
|
52
|
0
|
|
|
|
|
|
$self->{name} = $name; |
|
53
|
0
|
|
|
|
|
|
$self->{type} = $type; |
|
54
|
0
|
|
|
|
|
|
$self->{config} = [ @$config ]; |
|
55
|
0
|
|
|
|
|
|
$self->{config_block} = [ @$config ]; |
|
56
|
0
|
|
|
|
|
|
$self->{walker} = $walker; |
|
57
|
|
|
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
bless($self, $class); |
|
59
|
0
|
|
|
|
|
|
$self->_init; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
return $self; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item B |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=over |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Returns the type of the object group. One of "network", "service", "protocol", |
|
69
|
|
|
|
|
|
|
or "icmp_type" |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=back |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
|
74
|
0
|
|
|
0
|
1
|
|
sub type { $_[0]->{type} } |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=item B |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=over |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Returns the name of the object group as configured. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=back |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
|
85
|
0
|
|
|
0
|
1
|
|
sub name { $_[0]->{name} } |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item B |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=over |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns a list of items from the object group. The structure of the list |
|
92
|
|
|
|
|
|
|
returned will vary depending on the object-group type. See each sub-class for |
|
93
|
|
|
|
|
|
|
more information. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
B, B, B |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
|
100
|
0
|
|
|
0
|
1
|
|
sub list { undef } |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item B |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=over |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the first object from the object-group list. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=back |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |
|
111
|
|
|
|
|
|
|
sub first { |
|
112
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
113
|
0
|
|
|
|
|
|
my @list = $self->list; |
|
114
|
0
|
0
|
|
|
|
|
return @list ? $list[0] : undef; |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item B |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Returns the IP of the alias given in $alias. If no alias is found than the |
|
122
|
|
|
|
|
|
|
string is returned unchanged. This simply deligates to the alias sub from the |
|
123
|
|
|
|
|
|
|
PIX::Walker object as given in new(). |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=back |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
|
128
|
|
|
|
|
|
|
sub alias { |
|
129
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
130
|
0
|
|
|
|
|
|
my $alias = shift; |
|
131
|
0
|
0
|
|
|
|
|
return defined $self->{walker} ? $self->{walker}->alias($alias) : $alias; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
sub _init { |
|
135
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# It's possible for the config block to be an empty list, in which case |
|
138
|
|
|
|
|
|
|
# we don't count that as being invalid. |
|
139
|
0
|
0
|
0
|
|
|
|
if (@{$self->{config_block}} and |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
@{$self->{config_block}}[0] !~ /^object-group \S+ \S+/i) { |
|
141
|
0
|
|
|
|
|
|
carp("Invalid config block passed to $self->{class}"); |
|
142
|
0
|
|
|
|
|
|
return undef; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
0
|
|
|
0
|
|
|
sub _nextline { shift @{$_[0]->{config_block}} } |
|
|
0
|
|
|
|
|
|
|
|
147
|
0
|
|
|
0
|
|
|
sub _rewind { unshift @{$_[0]->{config_block}}, $_[1] } |
|
|
0
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=pod |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
Jason Morriss |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 BUGS |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
160
|
|
|
|
|
|
|
C, or through the web interface at |
|
161
|
|
|
|
|
|
|
L. |
|
162
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
163
|
|
|
|
|
|
|
your bug as I make changes. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SUPPORT |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
perldoc PIX::Walker |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
perldoc PIX::Accesslist |
|
170
|
|
|
|
|
|
|
perldoc PIX::Accesslist::Line |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
perldoc PIX::Object |
|
173
|
|
|
|
|
|
|
perldoc PIX::Object::network |
|
174
|
|
|
|
|
|
|
perldoc PIX::Object::service |
|
175
|
|
|
|
|
|
|
perldoc PIX::Object::protocol |
|
176
|
|
|
|
|
|
|
perldoc PIX::Object::icmp_type |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Copyright 2006-2008 Jason Morriss, all rights reserved. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
183
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |