Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Plugin/URIEval.pm |
Statements | Executed 25 statements in 1.46ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 89µs | 215µs | new | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 33µs | 67µs | BEGIN@24 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 32µs | 32µs | BEGIN@20 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 29µs | 40µs | BEGIN@25 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 28µs | 92µs | BEGIN@26 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 28µs | 42µs | BEGIN@23 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 24µs | 217µs | BEGIN@21 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 19µs | 99µs | BEGIN@28 | Mail::SpamAssassin::Plugin::URIEval::
0 | 0 | 0 | 0s | 0s | check_for_http_redirector | Mail::SpamAssassin::Plugin::URIEval::
0 | 0 | 0 | 0s | 0s | check_https_ip_mismatch | Mail::SpamAssassin::Plugin::URIEval::
0 | 0 | 0 | 0s | 0s | check_uri_truncated | Mail::SpamAssassin::Plugin::URIEval::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | # <@LICENSE> | ||||
2 | # Licensed to the Apache Software Foundation (ASF) under one or more | ||||
3 | # contributor license agreements. See the NOTICE file distributed with | ||||
4 | # this work for additional information regarding copyright ownership. | ||||
5 | # The ASF licenses this file to you under the Apache License, Version 2.0 | ||||
6 | # (the "License"); you may not use this file except in compliance with | ||||
7 | # the License. You may obtain a copy of the License at: | ||||
8 | # | ||||
9 | # http://www.apache.org/licenses/LICENSE-2.0 | ||||
10 | # | ||||
11 | # Unless required by applicable law or agreed to in writing, software | ||||
12 | # distributed under the License is distributed on an "AS IS" BASIS, | ||||
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
14 | # See the License for the specific language governing permissions and | ||||
15 | # limitations under the License. | ||||
16 | # </@LICENSE> | ||||
17 | |||||
18 | package Mail::SpamAssassin::Plugin::URIEval; | ||||
19 | |||||
20 | 2 | 70µs | 1 | 32µs | # spent 32µs within Mail::SpamAssassin::Plugin::URIEval::BEGIN@20 which was called:
# once (32µs+0s) by Mail::SpamAssassin::PluginHandler::load_plugin at line 20 # spent 32µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@20 |
21 | 2 | 74µs | 2 | 410µs | # spent 217µs (24+193) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@21 which was called:
# once (24µs+193µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 21 # spent 217µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@21
# spent 193µs making 1 call to Exporter::import |
22 | |||||
23 | 2 | 78µs | 2 | 55µs | # spent 42µs (28+14) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@23 which was called:
# once (28µs+14µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 23 # spent 42µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@23
# spent 14µs making 1 call to strict::import |
24 | 2 | 80µs | 2 | 101µs | # spent 67µs (33+34) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@24 which was called:
# once (33µs+34µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 24 # spent 67µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@24
# spent 34µs making 1 call to warnings::import |
25 | 2 | 85µs | 2 | 52µs | # spent 40µs (29+12) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@25 which was called:
# once (29µs+12µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 25 # spent 40µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@25
# spent 12µs making 1 call to bytes::import |
26 | 2 | 67µs | 2 | 157µs | # spent 92µs (28+64) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@26 which was called:
# once (28µs+64µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 26 # spent 92µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@26
# spent 64µs making 1 call to re::import |
27 | |||||
28 | 2 | 913µs | 2 | 179µs | # spent 99µs (19+80) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@28 which was called:
# once (19µs+80µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 28 # spent 99µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@28
# spent 80µs making 1 call to vars::import |
29 | 1 | 12µs | @ISA = qw(Mail::SpamAssassin::Plugin); | ||
30 | |||||
31 | # constructor: register the eval rule | ||||
32 | # spent 215µs (89+125) within Mail::SpamAssassin::Plugin::URIEval::new which was called:
# once (89µs+125µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 1 of (eval 103)[Mail/SpamAssassin/PluginHandler.pm:129] | ||||
33 | 1 | 2µs | my $class = shift; | ||
34 | 1 | 2µs | my $mailsaobject = shift; | ||
35 | |||||
36 | # some boilerplate... | ||||
37 | 1 | 2µs | $class = ref($class) || $class; | ||
38 | 1 | 22µs | 1 | 21µs | my $self = $class->SUPER::new($mailsaobject); # spent 21µs making 1 call to Mail::SpamAssassin::Plugin::new |
39 | 1 | 2µs | bless ($self, $class); | ||
40 | |||||
41 | # the important bit! | ||||
42 | 1 | 11µs | 1 | 52µs | $self->register_eval_rule("check_for_http_redirector"); # spent 52µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
43 | 1 | 6µs | 1 | 23µs | $self->register_eval_rule("check_https_ip_mismatch"); # spent 23µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
44 | 1 | 6µs | 1 | 29µs | $self->register_eval_rule("check_uri_truncated"); # spent 29µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
45 | |||||
46 | 1 | 16µs | return $self; | ||
47 | } | ||||
48 | |||||
49 | ########################################################################### | ||||
50 | |||||
51 | sub check_for_http_redirector { | ||||
52 | my ($self, $pms) = @_; | ||||
53 | |||||
54 | foreach ($pms->get_uri_list()) { | ||||
55 | while (s{^https?://([^/:\?]+).+?(https?:/{0,2}?([^/:\?]+).*)$}{$2}i) { | ||||
56 | my ($redir, $dest) = ($1, $3); | ||||
57 | foreach ($redir, $dest) { | ||||
58 | $_ = $self->{main}->{registryboundaries}->uri_to_domain($_) || $_; | ||||
59 | } | ||||
60 | next if ($redir eq $dest); | ||||
61 | dbg("eval: redirect: found $redir to $dest, flagging"); | ||||
62 | return 1; | ||||
63 | } | ||||
64 | } | ||||
65 | return 0; | ||||
66 | } | ||||
67 | |||||
68 | ########################################################################### | ||||
69 | |||||
70 | sub check_https_ip_mismatch { | ||||
71 | my ($self, $pms) = @_; | ||||
72 | |||||
73 | while (my($k,$v) = each %{$pms->{html}->{uri_detail}}) { | ||||
74 | next if ($k !~ m%^https?:/*(?:[^\@/]+\@)?\d+\.\d+\.\d+\.\d+%i); | ||||
75 | foreach (@{$v->{anchor_text}}) { | ||||
76 | next if (m%^https:/*(?:[^\@/]+\@)?\d+\.\d+\.\d+\.\d+%i); | ||||
77 | if (m%https:%i) { | ||||
78 | keys %{$self->{html}->{uri_detail}}; # resets iterator, bug 4829 | ||||
79 | return 1; | ||||
80 | } | ||||
81 | } | ||||
82 | } | ||||
83 | |||||
84 | return 0; | ||||
85 | } | ||||
86 | |||||
87 | ########################################################################### | ||||
88 | |||||
89 | # is there a better way to do this? | ||||
90 | sub check_uri_truncated { | ||||
91 | my ($self, $pms) = @_; | ||||
92 | return $pms->{'uri_truncated'}; | ||||
93 | } | ||||
94 | |||||
95 | 1 | 8µs | 1; |