| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Audit::DBI::TT2; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
15818
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
105
|
|
|
4
|
4
|
|
|
4
|
|
15
|
use warnings; |
|
|
4
|
|
|
|
|
4
|
|
|
|
4
|
|
|
|
|
94
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
11
|
use base 'Template::Plugin'; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
1876
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
17711
|
use Data::Dump qw(); |
|
|
4
|
|
|
|
|
24055
|
|
|
|
4
|
|
|
|
|
98
|
|
|
9
|
4
|
|
|
4
|
|
2004
|
use HTML::Entities qw(); |
|
|
4
|
|
|
|
|
20132
|
|
|
|
4
|
|
|
|
|
114
|
|
|
10
|
4
|
|
|
4
|
|
2233
|
use POSIX qw(); |
|
|
4
|
|
|
|
|
25382
|
|
|
|
4
|
|
|
|
|
104
|
|
|
11
|
4
|
|
|
4
|
|
2284
|
use Template::Stash; |
|
|
4
|
|
|
|
|
46416
|
|
|
|
4
|
|
|
|
|
814
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Audit::DBI::TT2 - A Template Toolkit plugin to display audit events recorded by L. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 2.3.0 |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '2.3.0'; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
In your Perl code: |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use Audit::DBI::TT2; |
|
33
|
|
|
|
|
|
|
use Template; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $template = Template->new( |
|
36
|
|
|
|
|
|
|
{ |
|
37
|
|
|
|
|
|
|
PLUGINS => |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
audit => 'Audit::DBI::TT2', |
|
40
|
|
|
|
|
|
|
}, |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
) || die $Template::ERROR; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
In your TT2 template: |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
[% USE audit %] |
|
47
|
|
|
|
|
|
|
[% FOREACH result IN audit.format_results( results ) %] |
|
48
|
|
|
|
|
|
|
... |
|
49
|
|
|
|
|
|
|
[% END %] |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Note: a fully operational example of a search interface for Audit::DBI events |
|
52
|
|
|
|
|
|
|
using this module for the display of the results is available in the |
|
53
|
|
|
|
|
|
|
C directory of this distribution. |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 format_results() |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Format the following fields for display as HTML: |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=over 4 |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item * diff |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
(accessible as diff_formatted) |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item * information |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
(accessible as information_formatted) |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item * event_time |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
(accessible as event_time_formatted) |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=back |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
[% FOREACH result IN audit.format_results( results ) %] |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Formatted information: [% result.information_formatted %] |
|
81
|
|
|
|
|
|
|
Formatted diff: [% result.diff_formatted %] |
|
82
|
|
|
|
|
|
|
Formatted event time: [% result.event_time_formatted %] |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
[% END %] |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub format_results |
|
89
|
|
|
|
|
|
|
{ |
|
90
|
1
|
|
|
1
|
1
|
10733
|
my ( $self, $results ) = @_; |
|
91
|
|
|
|
|
|
|
|
|
92
|
1
|
|
|
|
|
4
|
foreach my $result ( @$results ) |
|
93
|
|
|
|
|
|
|
{ |
|
94
|
1
|
|
|
|
|
7
|
$result->{information_formatted} = html_dumper( $result->get_information() ); |
|
95
|
1
|
|
|
|
|
7
|
$result->{diff_formatted} = html_dumper( $result->get_diff() ); |
|
96
|
|
|
|
|
|
|
$result->{event_time_formatted} = POSIX::strftime( |
|
97
|
|
|
|
|
|
|
"%Y-%m-%d %H:%M:%S", |
|
98
|
1
|
|
|
|
|
10
|
POSIX::localtime( $result->{event_time} ), |
|
99
|
|
|
|
|
|
|
); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
1
|
|
|
|
|
217
|
return $results; |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 html_dumper() |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Format a data structure for display as HTML. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
my $formatted_data = Audit::DBI::TT2::html_dumper( $data ); |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub html_dumper |
|
115
|
|
|
|
|
|
|
{ |
|
116
|
3
|
|
|
3
|
1
|
497
|
my ( $data ) = @_; |
|
117
|
|
|
|
|
|
|
return undef |
|
118
|
3
|
50
|
|
|
|
11
|
if !defined( $data ); |
|
119
|
|
|
|
|
|
|
|
|
120
|
3
|
|
|
|
|
14
|
my $string = Data::Dump::dump( $data ); |
|
121
|
3
|
|
|
|
|
703
|
$string = HTML::Entities::encode_entities( $string ); |
|
122
|
3
|
|
|
|
|
86
|
$string =~ s/ / /g; |
|
123
|
3
|
|
|
|
|
6
|
$string =~ s/\n/ /g; |
|
124
|
|
|
|
|
|
|
|
|
125
|
3
|
|
|
|
|
12
|
return $string; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 BUGS |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Please report any bugs or feature requests through the web interface at |
|
132
|
|
|
|
|
|
|
L. |
|
133
|
|
|
|
|
|
|
I will be notified, and then you'll automatically be notified of progress on |
|
134
|
|
|
|
|
|
|
your bug as I make changes. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 SUPPORT |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
perldoc Audit::DBI::TT2 |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
You can also look for information at: |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=over 4 |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=item * GitHub's request tracker |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
L |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * MetaCPAN |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=back |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 AUTHOR |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
L, C<< >>. |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
I originally developed this project for ThinkGeek |
|
175
|
|
|
|
|
|
|
(L). Thanks for allowing me to open-source it! |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Copyright 2010-2017 Guillaume Aubert. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
This code is free software; you can redistribute it and/or modify it under the |
|
183
|
|
|
|
|
|
|
same terms as Perl 5 itself. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
|
186
|
|
|
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
|
187
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the LICENSE file for more details. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
1; |