liuch / dmarc-srg

A php parser, viewer and summary report generator for incoming DMARC reports.
GNU General Public License v3.0
213 stars 31 forks source link

This report has already been loaded - "Column 'email' cannot be null" #84

Closed williamdes closed 1 year ago

williamdes commented 1 year ago
<?xml version="1.0" encoding="UTF-8" ?>
<feedback>
 <report_metadata>
  <org_name>synaq.com</org_name>
  <email></email>
  <report_id>phpmyadmin.net:1615601367</report_id>
  <date_range>
   <begin>1615500000</begin>
   <end>1615586400</end>
  </date_range>
 </report_metadata>
 <policy_published>
  <domain>phpmyadmin.net</domain>
  <adkim>s</adkim>
  <aspf>r</aspf>
  <p>quarantine</p>
  <sp>quarantine</sp>
  <pct>100</pct>
 </policy_published>
 <record>
  <row>
   <source_ip>94.130.222.149</source_ip>
   <count>1</count>
   <policy_evaluated>
    <disposition>none</disposition>
    <dkim>fail</dkim>
    <spf>pass</spf>
   </policy_evaluated>
  </row>
  <identifiers>
   <header_from>phpmyadmin.net</header_from>
  </identifiers>
  <auth_results>
   <spf>
    <domain>phpmyadmin.net</domain>
    <result>pass</result>
   </spf>
  </auth_results>
 </record>
</feedback>
string(83) "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'email' cannot be null"

The code hides this SQL error behind This report has already been loaded, I had to add a debug to see it.

williamdes commented 1 year ago

it's because the email is empty. This is my fix

- $st->bindValue(7, $data['email'], \PDO::PARAM_STR);
+ $st->bindValue(7, $data['email'] ?? '', \PDO::PARAM_STR);
liuch commented 1 year ago

Thank you for the report. Unfortunately, the both cases has the same error code. I don't know yet how to differ them except for parsing the error message.