line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Faker::Plugin::HttpUserAgent; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
21044
|
use 5.018; |
|
1
|
|
|
|
|
4
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use Venus::Class 'base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
base 'Faker::Plugin'; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
689
|
use POSIX 'strftime'; |
|
1
|
|
|
|
|
6627
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '1.18'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# METHODS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub execute { |
21
|
3
|
|
|
3
|
1
|
1516
|
my ($self, $data) = @_; |
22
|
|
|
|
|
|
|
|
23
|
3
|
|
|
|
|
13
|
my $faker = $self->faker; |
24
|
3
|
|
|
|
|
1357
|
my $random = $faker->random; |
25
|
3
|
|
|
|
|
6
|
my $class = 'Mozilla'; |
26
|
3
|
|
|
|
|
13
|
my $version = join '.', $random->range(5, 9), $random->range(0, 9); |
27
|
3
|
|
|
|
|
103
|
my $product = join '/', $class, $version; |
28
|
3
|
|
|
|
|
214
|
my $this_year = strftime '%Y', localtime; |
29
|
3
|
|
|
|
|
27
|
my $rand_year = $random->select([($this_year-20)..$this_year]); |
30
|
3
|
|
|
|
|
221
|
my $engine = join '/', 'Gecko', join('', $rand_year, (strftime '%m%d', localtime)); |
31
|
3
|
|
|
|
|
39
|
my $platform = $random->select([ |
32
|
|
|
|
|
|
|
['Macintosh', ['Mac OS ##.#', 'Max OS X ##.#'], ['Chrome', 'Safari']], |
33
|
|
|
|
|
|
|
['Windows', ['Windows ##.#', 'Windows NT ##.#'], ['Chrome', 'Edge', 'Firefox']], |
34
|
|
|
|
|
|
|
['X11', ['Linux x86', 'Linux x86_64'], ['Chrome', 'Firefox']], |
35
|
|
|
|
|
|
|
]); |
36
|
3
|
|
|
|
|
99
|
my $locale = $random->select([ |
37
|
|
|
|
|
|
|
'cs-CZ', |
38
|
|
|
|
|
|
|
'da-DK', |
39
|
|
|
|
|
|
|
'de-DE', |
40
|
|
|
|
|
|
|
'en-GB', |
41
|
|
|
|
|
|
|
'en-US', |
42
|
|
|
|
|
|
|
'es-ES', |
43
|
|
|
|
|
|
|
'ja-JP', |
44
|
|
|
|
|
|
|
'nb-NO', |
45
|
|
|
|
|
|
|
'pl-PL', |
46
|
|
|
|
|
|
|
'pt-BR', |
47
|
|
|
|
|
|
|
'sv-SE', |
48
|
|
|
|
|
|
|
'tr-TR', |
49
|
|
|
|
|
|
|
'zh-CN', |
50
|
|
|
|
|
|
|
'zh-TW', |
51
|
|
|
|
|
|
|
]); |
52
|
3
|
|
|
|
|
86
|
my $software = join ':', 'rv', $faker->software_version; |
53
|
3
|
|
|
|
|
229
|
my $os_name = $platform->[0]; |
54
|
3
|
|
|
|
|
243
|
my $os_desc = $self->process_markers( |
55
|
|
|
|
|
|
|
$self->process_format($random->select($platform->[1])) |
56
|
|
|
|
|
|
|
); |
57
|
3
|
|
|
|
|
15
|
my $comment = sprintf('(%s)', join('; ', $os_name, 'U', $os_desc, $software)); |
58
|
3
|
|
|
|
|
11
|
my $client = $random->select($platform->[2]); |
59
|
3
|
|
|
|
|
88
|
my $client_version = $faker->software_version; |
60
|
3
|
|
|
|
|
223
|
my $user_agent = "$product $comment $engine $os_name $client/$client_version"; |
61
|
|
|
|
|
|
|
|
62
|
3
|
|
|
|
|
145
|
return $user_agent; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Faker::Plugin::HttpUserAgent - HTTP User-Agent |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=cut |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 ABSTRACT |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
HTTP User-Agent for Faker |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 VERSION |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1.18 |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=cut |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SYNOPSIS |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
package main; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 DESCRIPTION |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This package provides methods for generating fake data for HTTP user-agents. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=encoding utf8 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 INHERITS |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
This package inherits behaviors from: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
L |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This package provides the following methods: |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=cut |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 execute |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
execute(HashRef $data) (Str) |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
The execute method returns a returns a random fake HTTP user-agent. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
I> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=over 4 |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=item execute example 1 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
package main; |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# "Mozilla/6.1 (Macintosh; U; Max OS X 50.7; rv:6.8.4) ... Safari/5.4.4"; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# "Mozilla/9.0 (X11; U; Linux x86_64; rv:0.3) Gecko/20210406 X11 Chrome/5.8"; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# my $result = $plugin->execute; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
# "Mozilla/9.8 (Macintosh; U; Max OS X 52.3; rv:0.9.1) ... Chrome/2.50"; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=back |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=cut |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head2 new |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
new(HashRef $data) (Plugin) |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
The new method returns a new instance of the class. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
I> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=over 4 |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item new example 1 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
package main; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
use Faker::Plugin::HttpUserAgent; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
my $plugin = Faker::Plugin::HttpUserAgent->new; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# bless(..., "Faker::Plugin::HttpUserAgent") |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=back |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=cut |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 AUTHORS |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Awncorp, C |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=cut |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 LICENSE |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Copyright (C) 2000, Al Newkirk. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
This program is free software, you can redistribute it and/or modify it under |
192
|
|
|
|
|
|
|
the terms of the Apache license version 2.0. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |