← Index
NYTProf Performance Profile   « line view »
For /usr/local/bin/sa-learn
  Run on Sun Nov 5 02:36:06 2017
Reported on Sun Nov 5 02:56:22 2017

Filename/usr/local/lib/perl5/site_perl/Mail/SpamAssassin/Plugin/HTTPSMismatch.pm
StatementsExecuted 23 statements in 1.53ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11176µs134µsMail::SpamAssassin::Plugin::HTTPSMismatch::::newMail::SpamAssassin::Plugin::HTTPSMismatch::new
11140µs40µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@20Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@20
11138µs104µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@27Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27
11133µs43µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@22Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22
11126µs88µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@25Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25
11125µs36µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@24Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24
11124µs56µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@23Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23
11124µs225µsMail::SpamAssassin::Plugin::HTTPSMismatch::::BEGIN@21Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21
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
20274µs140µs
# spent 40µs within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@20 which was called: # once (40µs+0s) by Mail::SpamAssassin::PluginHandler::load_plugin at line 20
use Mail::SpamAssassin::Plugin;
21289µs2426µs
# spent 225µs (24+201) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21 which was called: # once (24µs+201µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 21
use Mail::SpamAssassin::Logger;
# spent 225µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@21 # spent 201µs making 1 call to Exporter::import
22280µs253µs
# spent 43µs (33+10) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22 which was called: # once (33µs+10µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 22
use strict;
# spent 43µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@22 # spent 10µs making 1 call to strict::import
23277µs288µs
# spent 56µs (24+32) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23 which was called: # once (24µs+32µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 23
use warnings;
# spent 56µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@23 # spent 32µs making 1 call to warnings::import
24269µs246µs
# spent 36µs (25+10) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24 which was called: # once (25µs+10µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 24
use bytes;
# spent 36µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@24 # spent 10µs making 1 call to bytes::import
25272µs2150µs
# spent 88µs (26+62) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25 which was called: # once (26µs+62µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 25
use re 'taint';
# spent 88µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@25 # spent 62µs making 1 call to re::import
26
272959µs2171µs
# spent 104µs (38+67) within Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27 which was called: # once (38µs+67µs) by Mail::SpamAssassin::PluginHandler::load_plugin at line 27
use vars qw(@ISA);
# spent 104µs making 1 call to Mail::SpamAssassin::Plugin::HTTPSMismatch::BEGIN@27 # spent 67µs making 1 call to vars::import
28116µs@ISA = qw(Mail::SpamAssassin::Plugin);
29
30# constructor: register the eval rule
31
# spent 134µs (76+58) within Mail::SpamAssassin::Plugin::HTTPSMismatch::new which was called: # once (76µs+58µ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;
37124µs121µs my $self = $class->SUPER::new($mailsaobject);
# spent 21µs making 1 call to Mail::SpamAssassin::Plugin::new
3812µs bless ($self, $class);
39
40 # the important bit!
41121µs137µs $self->register_eval_rule ("check_https_http_mismatch");
# spent 37µs making 1 call to Mail::SpamAssassin::Plugin::register_eval_rule
42
43120µ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
112118µs1;