-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TLS-RPT Support #107
base: v2.0
Are you sure you want to change the base?
TLS-RPT Support #107
Conversation
Adds two new tables, tls_report and tls_rptrecord, and their respective columns, to add TLS report parsing functionality.
Updates the README.md to reflect the new TLS Report parsing functionality. Updates required packages to include perl-JSON.
Extends the parser's ability to processing JSON, in both compressed and uncompressed files Includes documentation to support extension.
Includes documentation.
No change in functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed the code for creating tables in PostgreSQL and some minor changes are necessary.
I'd suggest using docker to run a PostgreSQL instance. Easy to setup, doesn't affect the rest of the system, and it's easy to delete everything and start again (often necessary when testing table creation).
I haven't tested the actual insertion of reports in the database yet.
Co-authored-by: Eduardo Kalinowski <[email protected]>
Co-authored-by: Eduardo Kalinowski <[email protected]>
Co-authored-by: Eduardo Kalinowski <[email protected]>
This really is up to @techsneeze to judge, my in my opinion changing the name of the config option isn't great. At least the code should check if the previous config option is set and print a warning that |
Point taken. |
Co-authored-by: Eduardo Kalinowski <[email protected]>
Not having a return statement at the end of the getDATAFrom* functions breaks the code that calls them if there is an error getting XML or JSON data, since it is expecting an array of return values in all cases and getting nothing. That also breaks the handling of the Adding Now that that's sorted, I'm letting it parse incoming DMARC and TLS-RPT reports in debug mode over the next few days, to see how that goes. |
Another problem found with getDATAFromMessage, in that the MIME::Parser cleanup at the end of the function is never done (leaving behind temporary files) if XML or JSON data is found. I fixed this by setting a variable |
Of course, trying to do the return and cleanup properly results in another problem. I had to rewrite the part of the function that reads and parses the attachment. If I had more than zero experience with git, I could help more directly...
It seems to work cleanly now, as far as reading MIME email messages, but I'll keep running it in debug mode over the next couple of days. I still haven't gotten any TLS-RPT reports to try with it, but I tend to get at least one per day from Google. |
A couple of days of processing both kinds of reports, and everything seems happy. I didn't have any negative TLS reports to exercise the tls_rptrecord code, but aside from that... |
After turning off debug mode, I'm still getting "No failure details in report" from the TLS-RPT processing. That seems more like a debug message to me. |
@Maeglin73 It would be more helpful if you could submit your suggestions through git (I didn't know how to use git either before I started helping with this project - and most of it is still a mystery to me). |
@jnew-gh Feels like trying to give myself a crash course would either take a while or do more harm than good, considering I'm not even sure where to start for something like this. If it works for you, what I could do is make my copy of the parser script available on a web server. You could run a diff, and go from there. |
@Maeglin73 |
Ah, ok. Here you go, then. |
Show TLS-RPT message "No failure details in report" only when $debug is set.
…ctions Set up @ret_arr variable to handle errors getting XML or JSON data Rearrange logic when parsing files for XML or JSON data
Looks good. |
Sure, it works well. I eventually want to merge the three separate getDATAFrom* functions into one so I applied the same logic to all three. |
Just tested TLS-RPT support. It seems to fork fine. |
Any idea when this one will get merged? I have been trying to manually inject the modified files into my docker image. https://github.com/gutmensch/docker-dmarc-report Edit: Got it working. The JSON module seems to be a new dependencies. I can see reports being added to the database which is really cool. Need to move my Grafana dashboard over to this db now and should be fully in business! Edit2: @jnew-gh
|
does this work with mysql? i am not able to execute the scripts to create the tls table/colums to the database Erroor: |
Where did that file come from? It's not anywhere in the repository that I see. To answer the question, though, I've had no trouble using it with MySQL or MariaDB. |
I figured out the error, my database doesnt have the required table/columns for the tls records to be stored, any idea why its not getting created when i run the script, if you have the working script kindly share the same. Error: BD::mysql::st execute failed: Table 'dmarc.tls_report' doesn't exist at ./dmarcts-report-parser-tls.pl line 1310. DBD::mysql::st fetchrow_array failed: fetch() without execute() at ./dmarcts-report-parser-tls.pl line 1311. Use of uninitialized value $raw_data_max_size in numeric gt (>) at ./dmarcts-report-parser-tls.pl line 1372. Skipping storage of large JSON (400 bytes) as defined in config file. DBD::mysql::db do failed: Table 'dmarc.tls_report' doesn't exist at ./dmarcts-report-parser-tls.pl line 1376. Cannot add report to database (Table 'dmarc.tls_report' doesn't exist). Skipped. ./dmarcts-report-parser-tls.pl: Skipping tlsreports/google.com!mydomain.com!1680220800!1680307199!001.json due to database errors. |
If you download what's in the main repository, then download the changed files from this pull request and overwrite the original files with those, you'll have what I'm running. Of course, then you'll have to create or update the config file based on the changed sample, since some of the value names have changed. |
I was able to download the changed files, but still not able to read the json data. └──╼ $./dmarcts-report-parser.pl -x tls* -d Processing file tlsType: 2
|
It's expecting data file names, and you're giving it a directory name. |
These commits add functionality to parse SMTP TLS Reports (TLS-RPT) and add the results into the database.
Two new tables, tls-report and tls-rptrecord, are created along with their corresponding columns.