line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ThreatNet::Filter; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=pod |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
ThreatNet::Filter - Interface for ThreatNet event filters |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 DESCRIPTION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
ThreatNet data sources can potentially generate a hell of a lot of |
12
|
|
|
|
|
|
|
events, and it's important to be able to filter these down to just |
13
|
|
|
|
|
|
|
the events that matter. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Many of the filters are stateful. For example, the standard |
16
|
|
|
|
|
|
|
L module provides cache objects |
17
|
|
|
|
|
|
|
that filter out any threats that have already been seen in the |
18
|
|
|
|
|
|
|
previous hour. (or whatever the state period is). |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
The filter API is quite simple, with only a few methods. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
3
|
|
|
3
|
|
35394
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
132
|
|
27
|
3
|
|
|
3
|
|
4842
|
use Params::Util '_INSTANCE'; |
|
3
|
|
|
|
|
8657
|
|
|
3
|
|
|
|
|
204
|
|
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
3
|
|
33
|
use vars qw{$VERSION}; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
119
|
|
30
|
|
|
|
|
|
|
BEGIN { |
31
|
3
|
|
|
3
|
|
252
|
$VERSION = '0.20'; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
##################################################################### |
39
|
|
|
|
|
|
|
# Constructor |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=pod |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head2 new ... |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Since some categories of filter do not strictly need to be in the |
46
|
|
|
|
|
|
|
form of an object, a default C constructor is provided which just |
47
|
|
|
|
|
|
|
creates an empty object. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns a new C object, or some sub-classes may |
50
|
|
|
|
|
|
|
return C on error. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=cut |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub new { |
55
|
9
|
|
|
9
|
1
|
2544
|
bless {}, shift; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=pod |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 keep $Message |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
The C method takes a L object and examines |
63
|
|
|
|
|
|
|
it to determine if the message should be kept, or filtered out. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
In the default implementation of the filter, all messages are kept. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Returns true if the message should be kept, or false if the message |
68
|
|
|
|
|
|
|
should be discarded. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=cut |
71
|
|
|
|
|
|
|
|
72
|
6
|
100
|
|
6
|
1
|
431
|
sub keep { _INSTANCE($_[1], 'ThreatNet::Message') ? 1 : undef } |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
1; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 SUPPORT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
All bugs should be filed via the bug tracker at |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
L |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
For other issues, or commercial enhancement and support, contact the author |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHORS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Adam Kennedy Eadamk@cpan.orgE |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 SEE ALSO |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
L, L |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 COPYRIGHT |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Copyright (c) 2004 - 2005 Adam Kennedy. All rights reserved. |
97
|
|
|
|
|
|
|
This program is free software; you can redistribute |
98
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
The full text of the license can be found in the |
101
|
|
|
|
|
|
|
LICENSE file included with this module. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |