Algorithm-ToNumberMunger
view release on metacpan or search on metacpan
lib/Algorithm/ToNumberMunger.pm view on Meta::CPAN
=head2 postfix_status_enum
{ munger => 'postfix_status_enum', default => -1 }
Named-map enum (lookup rules as L</dns_rcode_enum>) for Postfix's delivery
C<status=> disposition, numbered in a rough sent-to-failed severity order so
a threshold split is meaningful: C<sent> 0, C<deferred> 1, C<bounced> 2,
C<expired> 3, C<deliverable> 4, C<undeliverable> 5, C<hold> 6, C<discard> 7,
C<filtered> 8, C<reject> 9, C<softbounce> 10. Stock delivery agents emit only
C<sent>/C<deferred>/C<bounced>/C<expired>; C<deliverable>/C<undeliverable> come
from address verification (C<verify>), and the remainder cover HOLD/DISCARD
actions and values common log normalizers emit. Being labels of this module's
numbering, numeric inputs are not passed through.
=head2 spf_result_enum
{ munger => 'spf_result_enum', default => -1 }
Named-map enum (lookup rules as L</dns_rcode_enum>) for an SPF check result
(RFC 7208), as logged by policyd-spf or carried in an C<Authentication-Results>
header, numbered pass-to-fail: C<pass> 0, C<neutral> 1, C<none> 2, C<softfail>
t/mungers.t view on Meta::CPAN
is( $ac->('blocked'), 1, 'suricata_action blocked' );
is( $ac->('drop'), 3, 'suricata_action drop (IPS)' );
}
# ---- Postfix / mail named enums ---------------------------------------------
{
my $ps = $M->build( { munger => 'postfix_status_enum', default => -1 } );
is( $ps->('sent'), 0, 'postfix_status sent' );
is( $ps->('DEFERRED'), 1, 'postfix_status is case-insensitive' );
is( $ps->('bounced'), 2, 'postfix_status bounced' );
is( $ps->('undeliverable'), 5, 'postfix_status undeliverable (verify)' );
is( $ps->('whatever'), -1, 'postfix_status default for unlisted' );
ok( $ps->('sent') < $ps->('bounced'), 'postfix_status ordered sent-before-bounced' );
my $spf = $M->build( { munger => 'spf_result_enum' } );
is( $spf->('pass'), 0, 'spf pass' );
is( $spf->('softfail'), 3, 'spf softfail' );
is( $spf->('permerror'), 6, 'spf permerror' );
is( $spf->('error'), $spf->('temperror'), 'spf error aliases temperror' );
is( $spf->('unknown'), $spf->('permerror'), 'spf unknown aliases permerror' );
( run in 0.502 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )