Filename | /usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Plugin/URIEval.pm |
Statements | Executed 25 statements in 1.47ms |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 97µs | 242µs | new | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 32µs | 32µs | BEGIN@20 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 26µs | 230µs | BEGIN@21 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 25µs | 58µs | BEGIN@24 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 24µs | 37µs | BEGIN@25 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 22µs | 48µs | BEGIN@23 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 20µs | 93µs | BEGIN@28 | Mail::SpamAssassin::Plugin::URIEval::
1 | 1 | 1 | 19µs | 84µs | BEGIN@26 | 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 | 58µ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 | 79µs | 2 | 434µs | # spent 230µs (26+204) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@21 which was called:
# once (26µs+204µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 21 # spent 230µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@21
# spent 204µs making 1 call to Exporter::import |
22 | |||||
23 | 2 | 84µs | 2 | 74µs | # spent 48µs (22+26) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@23 which was called:
# once (22µs+26µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 23 # spent 48µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@23
# spent 26µs making 1 call to strict::import |
24 | 2 | 73µs | 2 | 92µs | # spent 58µs (25+33) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@24 which was called:
# once (25µs+33µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 24 # spent 58µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@24
# spent 33µs making 1 call to warnings::import |
25 | 2 | 66µs | 2 | 51µs | # spent 37µs (24+14) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@25 which was called:
# once (24µs+14µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 25 # spent 37µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@25
# spent 14µs making 1 call to bytes::import |
26 | 2 | 84µs | 2 | 149µs | # spent 84µs (19+65) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@26 which was called:
# once (19µs+65µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 26 # spent 84µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@26
# spent 65µs making 1 call to re::import |
27 | |||||
28 | 2 | 936µs | 2 | 167µs | # spent 93µs (20+74) within Mail::SpamAssassin::Plugin::URIEval::BEGIN@28 which was called:
# once (20µs+74µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 28 # spent 93µs making 1 call to Mail::SpamAssassin::Plugin::URIEval::BEGIN@28
# spent 74µs making 1 call to vars::import |
29 | 1 | 14µs | @ISA = qw(Mail::SpamAssassin::Plugin); | ||
30 | |||||
31 | # constructor: register the eval rule | ||||
32 | # spent 242µs (97+144) within Mail::SpamAssassin::Plugin::URIEval::new which was called:
# once (97µs+144µ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 | 18µs | 1 | 28µs | my $self = $class->SUPER::new($mailsaobject); # spent 28µs making 1 call to Mail::SpamAssassin::Plugin::new |
39 | 1 | 2µs | bless ($self, $class); | ||
40 | |||||
41 | # the important bit! | ||||
42 | 1 | 15µs | 1 | 50µs | $self->register_eval_rule("check_for_http_redirector"); # spent 50µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
43 | 1 | 6µs | 1 | 38µs | $self->register_eval_rule("check_https_ip_mismatch"); # spent 38µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
44 | 1 | 6µs | 1 | 27µs | $self->register_eval_rule("check_uri_truncated"); # spent 27µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule |
45 | |||||
46 | 1 | 17µ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; |