| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Audit::DBI::Event; |
|
2
|
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
17720
|
use strict; |
|
|
18
|
|
|
|
|
27
|
|
|
|
18
|
|
|
|
|
547
|
|
|
4
|
18
|
|
|
18
|
|
84
|
use warnings; |
|
|
18
|
|
|
|
|
27
|
|
|
|
18
|
|
|
|
|
486
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
18
|
|
|
18
|
|
71
|
use Carp; |
|
|
18
|
|
|
|
|
25
|
|
|
|
18
|
|
|
|
|
1136
|
|
|
7
|
18
|
|
|
18
|
|
4082
|
use Data::Validate::Type; |
|
|
18
|
|
|
|
|
65370
|
|
|
|
18
|
|
|
|
|
908
|
|
|
8
|
18
|
|
|
18
|
|
5566
|
use Storable; |
|
|
18
|
|
|
|
|
22268
|
|
|
|
18
|
|
|
|
|
970
|
|
|
9
|
18
|
|
|
18
|
|
9531
|
use MIME::Base64 qw(); |
|
|
18
|
|
|
|
|
10985
|
|
|
|
18
|
|
|
|
|
6568
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 NAME |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Audit::DBI::Event - An event as logged by the Audit::DBI module. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 1.9.0 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
our $VERSION = '1.9.0'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Audit::DBI::Event; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $audit_event = Audit::DBI::Event->new( |
|
31
|
|
|
|
|
|
|
data => $data, #mandatory |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $audit_event_id = $audit_event->get_id(); |
|
35
|
|
|
|
|
|
|
my $information = $audit_event->get_information(); |
|
36
|
|
|
|
|
|
|
my $diff = $audit_event->get_diff(); |
|
37
|
|
|
|
|
|
|
my $ipv4_address = $audit_event->get_ipv4_address(); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 METHODS |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 new() |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Create a new Audit::DBI::Event object. |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $audit_event = Audit::DBI::Event->new( |
|
47
|
|
|
|
|
|
|
data => $data, #mandatory |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
Note that you should never have to instantiate Audit::DBI::Event objects |
|
51
|
|
|
|
|
|
|
directly. They are normally created by the Audit::DBI module. |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
49
|
|
|
49
|
1
|
3838
|
my ( $class, %args ) = @_; |
|
58
|
49
|
|
|
|
|
114
|
my $data = delete( $args{'data'} ); |
|
59
|
|
|
|
|
|
|
|
|
60
|
49
|
100
|
|
|
|
174
|
croak 'The parameter "data" is mandatory' |
|
61
|
|
|
|
|
|
|
if !defined( $data ); |
|
62
|
48
|
100
|
|
|
|
199
|
croak 'The parameter "data" must be a hashref' |
|
63
|
|
|
|
|
|
|
if !Data::Validate::Type::is_hashref( $data ); |
|
64
|
|
|
|
|
|
|
|
|
65
|
47
|
|
|
|
|
2022
|
return bless( $data, $class ); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 ACCESSORS |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head2 get_id() |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Return the audit event ID. |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $audit_event_id = $audit_event->get_id(); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub get_id |
|
80
|
|
|
|
|
|
|
{ |
|
81
|
1
|
|
|
1
|
1
|
51
|
my ( $self ) = @_; |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
12
|
return $self->{'audit_event_id'}; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 get_information() |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Retrieve the extra information stored, if any. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
my $information = $audit_event->get_information(); |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=cut |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub get_information |
|
96
|
|
|
|
|
|
|
{ |
|
97
|
1
|
|
|
1
|
1
|
29
|
my ( $self ) = @_; |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
return defined( $self->{'information'} ) |
|
100
|
1
|
50
|
|
|
|
8
|
? Storable::thaw( MIME::Base64::decode_base64( $self->{'information'} ) ) |
|
101
|
|
|
|
|
|
|
: undef; |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 get_diff() |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Retrieve the diff information stored, if any. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
my $diff = $audit_event->get_diff(); |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub get_diff |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
2
|
|
|
2
|
1
|
3
|
my ( $self ) = @_; |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
return defined( $self->{'diff'} ) |
|
118
|
2
|
50
|
|
|
|
20
|
? Storable::thaw( MIME::Base64::decode_base64( $self->{'diff'} ) ) |
|
119
|
|
|
|
|
|
|
: undef; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 get_diff_string_bytes() |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Return the size in bytes of all the text changes recorded inside the diff |
|
126
|
|
|
|
|
|
|
information stored for the event. |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This method can use two comparison types to calculate the size of the changes |
|
129
|
|
|
|
|
|
|
inside a diff: |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * Relative comparison (by default): |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
In this case, a string change from 'TestABC' to 'TestCDE' is a 0 bytes |
|
136
|
|
|
|
|
|
|
change (since there is the same number of characters). |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
my $diff_bytes = $audit_event->get_diff_string_bytes(); |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * Absolute comparison: |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
In this case, a string change from 'TestABC' to 'TestCDE' is a 6 bytes |
|
143
|
|
|
|
|
|
|
change (3 characters removed, and 3 added). |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
my $diff_bytes = $audit_event->get_diff_string_bytes( absolute => 1 ); |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Note that absolute comparison requires L to be installed. |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=back |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=cut |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub get_diff_string_bytes |
|
154
|
|
|
|
|
|
|
{ |
|
155
|
1
|
|
|
1
|
1
|
682
|
my ( $self, %args ) = @_; |
|
156
|
|
|
|
|
|
|
|
|
157
|
1
|
|
|
|
|
3
|
my $diff = $self->get_diff(); |
|
158
|
1
|
50
|
|
|
|
17
|
return 0 if !defined( $diff ); |
|
159
|
|
|
|
|
|
|
|
|
160
|
1
|
|
|
|
|
4
|
return Audit::DBI::Utils::get_diff_string_bytes( |
|
161
|
|
|
|
|
|
|
$diff, |
|
162
|
|
|
|
|
|
|
%args, |
|
163
|
|
|
|
|
|
|
); |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 get_ipv4_address() |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Return the IPv4 address associated with the audit event. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
my $ipv4_address = $audit_event->get_ipv4_address(); |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
sub get_ipv4_address |
|
176
|
|
|
|
|
|
|
{ |
|
177
|
1
|
|
|
1
|
1
|
2
|
my ( $self ) = @_; |
|
178
|
|
|
|
|
|
|
|
|
179
|
1
|
|
|
|
|
6
|
return Audit::DBI::Utils::integer_to_ipv4( $self->{'ipv4_address'} ); |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 BUGS |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
|
186
|
|
|
|
|
|
|
L. |
|
187
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
188
|
|
|
|
|
|
|
your bug as I make changes. |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 SUPPORT |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
perldoc Audit::DBI::Event |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
You can also look for information at: |
|
199
|
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=over 4 |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * GitHub's request tracker |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
207
|
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
L |
|
209
|
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
L |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=item * MetaCPAN |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
L |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=back |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 AUTHOR |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L, |
|
224
|
|
|
|
|
|
|
C<< >>. |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
Copyright 2010-2017 Guillaume Aubert. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This code is free software; you can redistribute it and/or modify it under the |
|
232
|
|
|
|
|
|
|
same terms as Perl 5 itself. |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
|
235
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
236
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the LICENSE file for more details. |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=cut |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
1; |