| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTTP::Lint::UserAgent; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
HTTP::Lint::UserAgent - HTTP User agent that warns for suspicious transactions |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Do not overload LWP::UserAgent::request; |
|
10
|
|
|
|
|
|
|
use HTTP::Lint::UserAgent qw/:noinject/; |
|
11
|
|
|
|
|
|
|
new HTTP::Lint::UserAgent->request ($request); |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# Do overload LWP::UserAgent::request; |
|
14
|
|
|
|
|
|
|
use HTTP::Lint::UserAgent; |
|
15
|
|
|
|
|
|
|
use LWP::UserAgent; |
|
16
|
|
|
|
|
|
|
new LWP::UserAgent->request ($request); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Overload LWP::UserAgent::request without script modification; |
|
19
|
|
|
|
|
|
|
perl -MHTTP::Lint::UserAgent client.pl |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
L subclasses L, providing |
|
24
|
|
|
|
|
|
|
B method that checks each transaction and messages involved |
|
25
|
|
|
|
|
|
|
when it finishes with L and produces warning on console |
|
26
|
|
|
|
|
|
|
(with B). |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Unless loaded with B<:noinject>, it replaces the B method |
|
29
|
|
|
|
|
|
|
in L package, transparently intercepting all |
|
30
|
|
|
|
|
|
|
requests. |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
|
33
|
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
24127
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
34
|
|
|
35
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
27
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
1
|
|
|
1
|
|
522
|
use HTTP::Lint qw/http_lint/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
96
|
|
|
38
|
1
|
|
|
1
|
|
14
|
use base qw/LWP::UserAgent/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1127
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub request |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
0
|
|
|
0
|
1
|
0
|
my $response = lwp_request (@_); |
|
43
|
0
|
0
|
|
|
|
0
|
if ($response) { |
|
44
|
0
|
|
|
|
|
0
|
warn $_ foreach http_lint ($response) |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
0
|
return $response; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub import |
|
50
|
|
|
|
|
|
|
{ |
|
51
|
1
|
|
|
1
|
|
12
|
my $class = shift; |
|
52
|
1
|
50
|
|
|
|
7
|
return if grep { $_ eq ':noinject' } @_; |
|
|
0
|
|
|
|
|
0
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
68320
|
no warnings 'redefine'; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
104
|
|
|
55
|
1
|
|
|
|
|
6
|
*HTTP::Lint::UserAgent::lwp_request = \&LWP::UserAgent::request; |
|
56
|
1
|
|
|
|
|
16
|
*LWP::UserAgent::request = \&request; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 BUGS |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
It's hackish, use it only for debugging and avoid |
|
62
|
|
|
|
|
|
|
using it in production code! |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Not much can go wrong, but it's just not nice. |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=over |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=item * |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
L -- The User Agent |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=item * |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
L -- Checker module |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=back |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Copyright 2011, Lubomir Rintel |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
85
|
|
|
|
|
|
|
under the same terms as Perl itself. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Lubomir Rintel C |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
1; |