| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# vim: set ts=3 sw=3 tw=0: |
|
5
|
|
|
|
|
|
|
# vim: set expandtab: |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Rex::JobControl::Mojolicious::Plugin::Audit; |
|
8
|
|
|
|
|
|
|
$Rex::JobControl::Mojolicious::Plugin::Audit::VERSION = '0.7.0'; |
|
9
|
1
|
|
|
1
|
|
1275
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
40
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Mojolicious::Plugin; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
28
|
use base 'Mojolicious::Plugin'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
80
|
|
|
15
|
1
|
|
|
1
|
|
561
|
use Rex::JobControl::Helper::AuditLog; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
28
|
|
|
16
|
1
|
|
|
1
|
|
47
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
376
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub register { |
|
19
|
1
|
|
|
1
|
1
|
70
|
my ( $plugin, $app ) = @_; |
|
20
|
|
|
|
|
|
|
|
|
21
|
1
|
|
|
|
|
13
|
my $log = Rex::JobControl::Helper::AuditLog->new( |
|
22
|
|
|
|
|
|
|
path => $app->config->{log}->{audit_log}, |
|
23
|
|
|
|
|
|
|
level => 'info' |
|
24
|
|
|
|
|
|
|
); |
|
25
|
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
2
|
my %audit_calls = %{ $app->config->{audit} }; |
|
|
1
|
|
|
|
|
6
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$app->hook( |
|
29
|
|
|
|
|
|
|
around_action => sub { |
|
30
|
0
|
|
|
0
|
|
|
my ( $next, $c, $action, $last ) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $ctrl_name = $c->stash('controller'); |
|
33
|
0
|
|
|
|
|
|
my $action_name = $c->stash('action'); |
|
34
|
|
|
|
|
|
|
|
|
35
|
0
|
0
|
0
|
|
|
|
if ( exists $audit_calls{$ctrl_name} |
|
36
|
|
|
|
|
|
|
&& exists $audit_calls{$ctrl_name}->{$action_name} ) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
0
|
|
|
|
|
|
my %params; |
|
39
|
0
|
|
|
|
|
|
@params{ @{ $audit_calls{$ctrl_name}->{$action_name}->{params} } } = |
|
|
0
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$c->param( $audit_calls{$ctrl_name}->{$action_name}->{params} ); |
|
41
|
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
$log->audit( |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
|
|
|
|
|
|
controller => $ctrl_name, |
|
45
|
|
|
|
|
|
|
action => $action_name, |
|
46
|
|
|
|
|
|
|
data => \%params, |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
); |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
return $next->(); |
|
52
|
|
|
|
|
|
|
}, |
|
53
|
1
|
|
|
|
|
37
|
); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |