Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/techsneeze/dmarcts-report-parser.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Kersten <kerstenpatrick@gmail.com>2021-01-02 01:46:30 +0300
committerPatrick Kersten <kerstenpatrick@gmail.com>2021-01-02 01:46:30 +0300
commit987c176b4865152058438a293622a2dd2512f1d6 (patch)
treee76e28e9b2fa64891aef79e43bd1d40e8bada625
parent1c0655e9db6df21916f27708b47f55d0ee75df67 (diff)
Update dmarcts-report-parser.pl
Add information to the script so that the SPF information also gets saved to the database.
-rwxr-xr-xdmarcts-report-parser.pl30
1 files changed, 30 insertions, 0 deletions
diff --git a/dmarcts-report-parser.pl b/dmarcts-report-parser.pl
index 053550d..2de3b04 100755
--- a/dmarcts-report-parser.pl
+++ b/dmarcts-report-parser.pl
@@ -850,6 +850,36 @@ sub storeXMLInDatabase {
}
}
+ $rp = $r{'auth_results'}->{'spf'};
+ if(ref $rp eq "HASH") {
+ $spf = $rp->{'domain'};
+ $spf = undef if ref $spf eq "HASH";
+ $spfresult = $rp->{'result'};
+ } else { # array, i.e. multiple dkim results (usually from multiple domains)
+ # glom sigs together
+ $spf = join '/',map { my $d = $_->{'domain'}; ref $d eq "HASH"?"": $d } @$rp;
+ # report results
+ my $rp_len = scalar(@$rp);
+ for ( my $i=0; $i < $rp_len; $i++ ) {
+ if ( $rp->[$i]->{'result'} eq "pass" ) {
+ # If any one spf result is a "pass", this should yield an overall "pass" and immediately exit the for loop, ignoring any remaing results
+ $spfresult = "pass";
+ last;
+ } else {
+ for ( my $j=$i+1; $j < $rp_len; $j++ ) {
+ if ( $rp->[$i]->{'result'} eq $rp->[$j]->{'result'} ) {
+ # Compare each spf result to the next one to see if all of the spf results are the same.
+ # If all of the spf results are the same, that will be the overall result.
+ # If any of them are different, and don't contain a "pass" result, then $spfresult will be empty
+ $spfresult = $rp->[0]->{'result'};
+ } else {
+ $spfresult = undef;
+ }
+ }
+ }
+ }
+ }
+
$rp = $r{'row'}->{'policy_evaluated'}->{'reason'};
if(ref $rp eq "HASH") {
$reason = $rp->{'type'};