← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Tue Nov 7 05:38:10 2017
Reported on Tue Nov 7 06:16:05 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm
StatementsExecuted 23 statements in 1.55ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11177µs138µsMail::SpamAssassin::Plugin::HTTPSMismatch::::newMail::SpamAssassin::Plugin::HTTPSMismatch::new
11139µs39µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@20Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@20
11129µs38µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@22Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22
11129µs95µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@27Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27
11127µs34µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@24Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24
11124µs204µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@21Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21
11124µs57µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@23Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23
11122µs83µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@25Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25
0000s0sMail::SpamAssassin::Plugin::HTTPSMismatch::::check_https_http_mismatchMail::SpamAssassin::Plugin::HTTPSMismatch::check_https_http_mismatch
Call graph for these subroutines as a Graphviz dot language file.
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
18package Mail::SpamAssassin::Plugin::HTTPSMismatch;
19
20279µs139µs
# spent 39µs within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@20 which was called: # once (39µs+0s) by Mail::SpamAssassin::PluginHandler::load_plugin at line 20
use Mail::SpamAssassin::Plugin;
21273µs2384µs
# spent 204µs (24+180) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21 which was called: # once (24µs+180µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 21
use Mail::SpamAssassin::Logger;
# spent 204µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21 # spent 180µs making 1 call to Exporter::import
22272µs246µs
# spent 38µs (29+9) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22 which was called: # once (29µs+9µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 22
use strict;
# spent 38µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22 # spent 9µs making 1 call to strict::import
23271µs291µs
# spent 57µs (24+34) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23 which was called: # once (24µs+34µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 23
use warnings;
# spent 57µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23 # spent 34µs making 1 call to warnings::import
24268µs241µs
# spent 34µs (27+7) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24 which was called: # once (27µs+7µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 24
use bytes;
# spent 34µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24 # spent 7µs making 1 call to bytes::import
25274µs2143µs
# spent 83µs (22+60) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25 which was called: # once (22µs+60µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 25
use re 'taint';
# spent 83µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25 # spent 60µs making 1 call to re::import
26
2721.02ms2162µs
# spent 95µs (29+66) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27 which was called: # once (29µs+66µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 27
use vars qw(@ISA);
# spent 95µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27 # spent 66µs making 1 call to vars::import
28112µs@ISA = qw(Mail::SpamAssassin::Plugin);
29
30# constructor: register the eval rule
31
# spent 138µs (77+61) within Mail::SpamAssassin::Plugin::HTTPSMismatch::new which was called: # once (77µs+61µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 1 of (eval 85)[Mail/SpamAssassin/PluginHandler.pm:129]
sub new {
3212µs my $class = shift;
3312µs my $mailsaobject = shift;
34
35 # some boilerplate...
3612µs $class = ref($class) || $class;
37121µs125µs my $self = $class->SUPER::new($mailsaobject);
# spent 25µs making 1 call to Mail::SpamAssassin::Plugin::new
3812µs bless ($self, $class);
39
40 # the important bit!
41121µs135µs $self->register_eval_rule ("check_https_http_mismatch");
# spent 35µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule
42
43116µs return $self;
44}
45
46# [lt]a href="http://baboz-njeryz.de/"[gt]https://bankofamerica.com/[lt]/a[gt]
47# ("<" and ">" replaced with "[lt]" and "[gt]" to avoid Kaspersky Desktop AV
48# false positive ;)
49sub check_https_http_mismatch {
50 my ($self, $permsgstatus, undef, $minanchors, $maxanchors) = @_;
51
52 $minanchors ||= 1;
53
54 if (!exists $permsgstatus->{chhm_hit}) {
55 $permsgstatus->{chhm_hit} = 0;
56 $permsgstatus->{chhm_anchors} = 0;
57
58 foreach my $v ( values %{$permsgstatus->{html}->{uri_detail}} ) {
59 # if the URI wasn't used for an anchor tag, or the anchor text didn't
60 # exist, skip this.
61 next unless (exists $v->{anchor_text} && @{$v->{anchor_text}});
62
63 my $uri;
64 foreach (@{$v->{cleaned}}) {
65 if (m@^https?://([^/:]+)@i) {
66 $uri = $1;
67
68 # Skip IPs since there's another rule to catch that already
69 if ($uri =~ /^\d+\.\d+\.\d+\.\d+$/) {
70 undef $uri;
71 next;
72 }
73
74 # want to compare whole hostnames instead of domains?
75 # comment this next section to the blank line.
76 $uri = $self->{main}->{registryboundaries}->trim_domain($uri);
77 undef $uri unless ($self->{main}->{registryboundaries}->is_domain_valid($uri));
78
79 last if $uri;
80 }
81 }
82
83 next unless $uri;
84 $permsgstatus->{chhm_anchors}++ if exists $v->{anchor_text};
85
86 foreach (@{$v->{anchor_text}}) {
87 if (m@https://([^/:]+)@i) {
88 my $https = $1;
89
90 # want to compare whole hostnames instead of domains?
91 # comment this next section to the blank line.
92 if ($https !~ /^\d+\.\d+\.\d+\.\d+$/) {
93 $https = $self->{main}->{registryboundaries}->trim_domain($https);
94 undef $https unless ($self->{main}->{registryboundaries}->is_domain_valid($https));
95 }
96 next unless $https;
97
98 dbg("https_http_mismatch: domains $uri -> $https");
99
100 next if $uri eq $https;
101 $permsgstatus->{chhm_hit} = 1;
102 last;
103 }
104 }
105 }
106 dbg("https_http_mismatch: anchors ".$permsgstatus->{chhm_anchors});
107 }
108
109 return ( $permsgstatus->{chhm_hit} && $permsgstatus->{chhm_anchors} >= $minanchors && (defined $maxanchors && $permsgstatus->{chhm_anchors} < $maxanchors) );
110}
111
112113µs1;