| 1 | package Antispam::httpBL; | ||||||||||
| 2 | 1 | ▶ | BEGIN { | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 1 | $Antispam::httpBL::VERSION = '0.02'; | |||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Antispam::Toolkit 0.06; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 1 | ▶ | use Antispam::Toolkit::Result; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 1 | ▶ | use MooseX::Types::Moose qw( Str ); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | 1 | ▶ | use WWW::Honeypot::httpBL; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | 1 | ▶ | use MooseX::StrictConstructor; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 17 | |||||||||||
| 18 | 1 | with 'Antispam::Toolkit::Role::IPChecker'; | |||||||||
| 19 | |||||||||||
| 20 | 1 | has access_key => ( | |||||||||
| 21 | is => 'ro', | ||||||||||
| 22 | isa => Str, | ||||||||||
| 23 | required => 1, | ||||||||||
| 24 | ); | ||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | sub check_ip { | ||||||||
|
Subroutine
check_ip: called CC=5 SCAR=16.1
| |||||||||||
| 27 | 2 | my $self = shift; | |||||||||
| 28 | 2 | my %p = @_; | |||||||||
| 29 | |||||||||||
| 30 | 2 | my $hp | |||||||||
| 31 | = WWW::Honeypot::httpBL->new( { access_key => $self->access_key() } ); | ||||||||||
| 32 | |||||||||||
| 33 | 2 | $hp->fetch( $p{ip} ); | |||||||||
| 34 | |||||||||||
| 35 | 2 | my @details; | |||||||||
| 36 | |||||||||||
| 37 | 2 | ▶ | push @details, 'IP address is a comment spammer' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | if $hp->is_comment_spammer(); | ||||||||||
| 39 | 2 | ▶ | push @details, 'IP address is an email harvester' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 40 | if $hp->is_harvester(); | ||||||||||
| 41 | 2 | ▶ | push @details, 'IP address is suspicious' | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | if $hp->is_suspicious(); | ||||||||||
| 43 | 2 | push @details, 'IP address threat score is ' . $hp->threat_score(); | |||||||||
| 44 | 2 | push @details, 'Days since last activity for this IP: ' | |||||||||
| 45 | . $hp->days_since_last_activity(); | ||||||||||
| 46 | |||||||||||
| 47 | # See http://www.projecthoneypot.org/threat_info.php - a score that's much | ||||||||||
| 48 | # above 75 is ridiculously unlikely, so we'll just treat >= 75 as a 10. | ||||||||||
| 49 | 2 | ▶ | my $score = $hp->threat_score() > 75 ? 10 : $hp->threat_score() / 7.5; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 50 | |||||||||||
| 51 | 2 | return Antispam::Toolkit::Result->new( | |||||||||
| 52 | score => $score, | ||||||||||
| 53 | details => \@details, | ||||||||||
| 54 | ); | ||||||||||
| 55 | } | ||||||||||
| 56 | |||||||||||
| 57 | { | ||||||||||
| 58 | 1 | ▶ | unless ( WWW::Honeypot::httpBL->can('days_since_last_activity') ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | 1 | *WWW::Honeypot::httpBL::days_since_last_activity | |||||||||
| 60 | = \&WWW::Honeypot::httpBL::days_since_last_actvity; | ||||||||||
| 61 | } | ||||||||||
| 62 | } | ||||||||||
| 63 | |||||||||||
| 64 | 1 | __PACKAGE__->meta()->make_immutable(); | |||||||||
| 65 | |||||||||||
| 66 | 1 | 1; | |||||||||
| 67 | |||||||||||
| 68 | # ABSTRACT: Antispam checks using Project Honeypot's http blacklist | ||||||||||
| 69 | |||||||||||
| 70 | |||||||||||
| 71 | |||||||||||
| 72 | =pod | ||||||||||
| 73 | |||||||||||
| 74 | =head1 NAME | ||||||||||
| 75 | |||||||||||
| 76 | Antispam::httpBL - Antispam checks using Project Honeypot's http blacklist | ||||||||||
| 77 | |||||||||||
| 78 | =head1 VERSION | ||||||||||
| 79 | |||||||||||
| 80 | version 0.02 | ||||||||||
| 81 | |||||||||||
| 82 | =head1 SYNOPSIS | ||||||||||
| 83 | |||||||||||
| 84 | my $bl = Antispam::httpBL->new( access_key => 'abc123' ); | ||||||||||
| 85 | |||||||||||
| 86 | my $result = $bl->check_ip( ip => '1.2.3.4' ); | ||||||||||
| 87 | |||||||||||
| 88 | if ( $result->score() ) { ... } | ||||||||||
| 89 | |||||||||||
| 90 | =head1 DESCRIPTION | ||||||||||
| 91 | |||||||||||
| 92 | This module implements the L<Antispam::Toolkit::Role::IPChecker> role using | ||||||||||
| 93 | Project Honeypot's Http:BL API to check whether a given IP address is | ||||||||||
| 94 | associated with spamming or email harvesting. | ||||||||||
| 95 | |||||||||||
| 96 | =head1 METHODS | ||||||||||
| 97 | |||||||||||
| 98 | This class provides the following methods: | ||||||||||
| 99 | |||||||||||
| 100 | =head2 Antispam::httpBL->new( access_key => ... ) | ||||||||||
| 101 | |||||||||||
| 102 | This method constructs a new object. It requires an access key. You can get an | ||||||||||
| 103 | access key from the Project Honeypot website at | ||||||||||
| 104 | L<http://www.projecthoneypot.org/>. | ||||||||||
| 105 | |||||||||||
| 106 | =head2 $bl->check_ip( ip => ... ) | ||||||||||
| 107 | |||||||||||
| 108 | This method checks whether an ip address is associated with some sort of | ||||||||||
| 109 | spam-related behavior. | ||||||||||
| 110 | |||||||||||
| 111 | It returns an L<Antispam::Toolkit::Result> object. | ||||||||||
| 112 | |||||||||||
| 113 | While the Http:BL API allows for threat scores from 0-255, the result will | ||||||||||
| 114 | contain a score from 0-10. This score is the Http:NL threat score divided by | ||||||||||
| 115 | 7.5, and capped at 10. | ||||||||||
| 116 | |||||||||||
| 117 | The details in the result object will break down all the results returned by | ||||||||||
| 118 | the Http:BL API. | ||||||||||
| 119 | |||||||||||
| 120 | =head1 BUGS | ||||||||||
| 121 | |||||||||||
| 122 | Please report any bugs or feature requests to | ||||||||||
| 123 | C<bug-antispam-httpbl@rt.cpan.org>, or through the web interface at | ||||||||||
| 124 | L<http://rt.cpan.org>. I will be notified, and then you'll automatically be | ||||||||||
| 125 | notified of progress on your bug as I make changes. | ||||||||||
| 126 | |||||||||||
| 127 | =head1 DONATIONS | ||||||||||
| 128 | |||||||||||
| 129 | If you'd like to thank me for the work I've done on this module, please | ||||||||||
| 130 | consider making a "donation" to me via PayPal. I spend a lot of free time | ||||||||||
| 131 | creating free software, and would appreciate any support you'd care to offer. | ||||||||||
| 132 | |||||||||||
| 133 | Please note that B<I am not suggesting that you must do this> in order for me | ||||||||||
| 134 | to continue working on this particular software. I will continue to do so, | ||||||||||
| 135 | inasmuch as I have in the past, for as long as it interests me. | ||||||||||
| 136 | |||||||||||
| 137 | Similarly, a donation made in this way will probably not make me work on this | ||||||||||
| 138 | software much more, unless I get so many donations that I can consider working | ||||||||||
| 139 | on free software full time, which seems unlikely at best. | ||||||||||
| 140 | |||||||||||
| 141 | To donate, log into PayPal and send money to autarch@urth.org or use the | ||||||||||
| 142 | button on this page: L<http://www.urth.org/~autarch/fs-donation.html> | ||||||||||
| 143 | |||||||||||
| 144 | =head1 AUTHOR | ||||||||||
| 145 | |||||||||||
| 146 | Dave Rolsky <autarch@urth.org> | ||||||||||
| 147 | |||||||||||
| 148 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 149 | |||||||||||
| 150 | This software is Copyright (c) 2010 by Dave Rolsky. | ||||||||||
| 151 | |||||||||||
| 152 | This is free software, licensed under: | ||||||||||
| 153 | |||||||||||
| 154 | The Artistic License 2.0 | ||||||||||
| 155 | |||||||||||
| 156 | =cut | ||||||||||
| 157 | |||||||||||
| 158 | |||||||||||
| 159 | __END__ | ||||||||||