Skip to content

Commit

Permalink
basicheaders: added whitelist support
Browse files Browse the repository at this point in the history
because alerts.etrade.com doesn't set a Date header in alerts
  • Loading branch information
msimerson committed May 23, 2012
1 parent 80b94eb commit 09935b0
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions plugins/check_basicheaders
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Checks for missing or empty values in the From or Date headers.
Optionally test if the Date header is too many days in the past or future. If
I<future> or I<past> are not defined, they are not tested.
If the remote IP is whitelisted, header validation is skipped.
=head1 CONFIGURATION
The following optional settings exist:
Expand Down Expand Up @@ -120,6 +122,8 @@ sub hook_data_post {
return ($deny, "missing header");
};

return DECLINED if $self->is_immune();

if ( ! $header->get('From') ) {
$self->log(LOGINFO, "fail: no from");
return ($deny, "We require a valid From header")
Expand Down Expand Up @@ -162,3 +166,24 @@ sub invalid_date_range {
$self->log(LOGINFO, "pass");
return;
}

sub is_immune {
my $self = shift;

if ( $self->qp->connection->relay_client() ) {
$self->log(LOGINFO, "skip: relay client");
return 1;
};

if ( $self->qp->connection->notes('whitelisthost') ) {
$self->log(LOGINFO, "skip: whitelisted host");
return 1;
};

if ( $self->qp->transaction->notes('whitelistsender') ) {
$self->log(LOGINFO, "skip: whitelisted sender");
return 1;
};

return;
};

0 comments on commit 09935b0

Please sign in to comment.