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:
authorWolfgang Karall-Ahlborn <wolfgangkarall@users.noreply.github.com>2021-03-17 22:00:13 +0300
committerWolfgang Karall-Ahlborn <wolfgangkarall@users.noreply.github.com>2021-03-17 22:08:54 +0300
commitb663dee14ae97dd1480936bb5a7df147f85064fd (patch)
treee31833a7a1a59518675eb097f232d373bc00346b
parent73bbb0ff546a332e7d1953d6d76d392d2840857f (diff)
Reduce chances of getting a 'mystery' result
Handle seen-in-the-wild cases of - no <record></record> at all - empty <source_ip/> Also use 'return' instead of 'next' for leaving dorow().
-rwxr-xr-xdmarcts-report-parser.pl14
1 files changed, 11 insertions, 3 deletions
diff --git a/dmarcts-report-parser.pl b/dmarcts-report-parser.pl
index dffd41f..9136d24 100755
--- a/dmarcts-report-parser.pl
+++ b/dmarcts-report-parser.pl
@@ -758,6 +758,12 @@ sub storeXMLInDatabase {
$policy_pct = $xml->{'policy_published'}[0]->{'pct'};
}
+ my $record = $xml->{'record'};
+ if ( ! defined($record) ) {
+ warn "$scriptname: $org: $id: No records in report. Skipped.\n";
+ return 0;
+ }
+
# begin transaction
if ($db_tx_support) {
$dbh->do(qq{START TRANSACTION});
@@ -819,13 +825,15 @@ sub storeXMLInDatabase {
if ($debug){
print " serial $serial \n";
}
- my $record = $xml->{'record'};
sub dorow($$$$) {
my ($serial,$recp,$org,$id) = @_;
my %r = %$recp;
my $ip = $r{'row'}->{'source_ip'};
- #print "ip $ip\n";
+ if ( $ip eq '' ) {
+ warn "$scriptname: $org: $id: source_ip is empty. Skipped.\n";
+ return 0;
+ }
my $count = $r{'row'}->{'count'};
my $disp = $r{'row'}->{'policy_evaluated'}->{'disposition'};
# some reports don't have dkim/spf, "unknown" is default for these
@@ -928,7 +936,7 @@ sub storeXMLInDatabase {
$iptype = "ip6";
} else {
warn "$scriptname: $org: $id: ??? mystery ip $ip\n";
- next; # of dorow
+ return 0;
}
$dbh->do(qq{INSERT INTO rptrecord(serial,$iptype,rcount,disposition,spf_align,dkim_align,reason,dkimdomain,dkimresult,spfdomain,spfresult,identifier_hfrom)