From 07c16a2dd8c3901aed1eb52cf46552e928da1797 Mon Sep 17 00:00:00 2001 From: userjack6880 Date: Wed, 26 Apr 2023 10:35:15 -0500 Subject: [PATCH] version 2 fixes backport --- .github/ISSUE_TEMPLATE/bug_report.md | 6 +++--- .github/ISSUE_TEMPLATE/critical_report.md | 6 +++--- .github/PULL_REQUEST_TEMPLATE.md | 8 ++++---- README.md | 22 ++++++++++++---------- config.php.pub | 3 ++- docs/CHANGELOG.md | 3 +++ docs/SECURITY.md | 5 +++-- docs/SUPPORT.md | 5 +++-- includes/db.php | 10 +++++++++- includes/functions.php | 2 +- includes/template.php | 2 +- install.php | 9 ++++++++- pgsql.sql | 8 ++++++++ 13 files changed, 60 insertions(+), 29 deletions(-) create mode 100644 pgsql.sql diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 0991102..f959308 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -24,9 +24,9 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Software Version** -[ ] Version 1 Beta 2 -[ ] Version 1 Beta 1 -[ ] Other +[] Version 1 Beta 4 +[] Version 1 Beta 3 +[] Other **Desktop (please complete the following information):** - OS [e.g. macOS] diff --git a/.github/ISSUE_TEMPLATE/critical_report.md b/.github/ISSUE_TEMPLATE/critical_report.md index a767846..0a02c13 100644 --- a/.github/ISSUE_TEMPLATE/critical_report.md +++ b/.github/ISSUE_TEMPLATE/critical_report.md @@ -24,9 +24,9 @@ A clear and concise description of what you expected to happen. If applicable, add screenshots to help explain your problem. **Software Version** -[ ] Version 1 Beta 2 -[ ] Version 1 Beta 1 -[ ] Other +[] Version 1 Beta 4 +[] Version 1 Beta 3 +[] Other **Desktop (please complete the following information):** - OS [e.g. macOS] diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 417e4a0..9df755d 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -10,10 +10,10 @@ Fixes # (issue) Please delete options that are not relevant. -- [ ] Bug fix (non-breaking change which fixes an issue) -- [ ] New feature (non-breaking change which adds functionality) -- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) -- [ ] This change requires a documentation update +- [] Bug fix (non-breaking change which fixes an issue) +- [] New feature (non-breaking change which adds functionality) +- [] Breaking change (fix or feature that would cause existing functionality to not work as expected) +- [] This change requires a documentation update ## How Has This Been Tested? diff --git a/README.md b/README.md index e7cf546..c505fdc 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,18 @@ # Open DMARC Analyzer ![Open DMARC Analyzer Screenshot](docs/images/oda-screenshot.jpg?raw=true) -Open DMARC Analyzer is an Open Source DMARC Report Analyzer to be used with DMARC reports that have been parsed by [John Levine's rrdmarc script](http://www.taugh.com/rddmarc/) or [techsneeze's dmarcts-report-parser](https://github.com/techsneeze/dmarcts-report-parser). +Open DMARC Analyzer is an Open Source DMARC Report Analyzer to be used with DMARC reports that have been parsed by [Open Report Parser](https://github.com/userjack6880/Open-Report-Parser). Open DMARC Analyzer was written because there didn't seem to be a full-featured self-hosted report analyzer that provided enough details to make heads or tails of a large volume of DMARC reports that come into medium to large-sized organizations. While other solutions required paid subscriptions or have part of it hosted on AWS, Open DMARC Analyzer will run on any webserver that supports PHP 7.4+ and MySQL 15.1+. -Open DMARC Analyzer Version 1 Beta 3 (1-β3) is an [Anomaly \](https://systemanomaly.com/codebase) project by John Bradley (john@systemanomaly.com) +Open DMARC Analyzer Version 1 Beta 4 (1-β4) is an [Anomaly \](https://systemanomaly.com/codebase) project by John Bradley (john@systemanomaly.com) # Minimum Requirements - Apache 2 or equivalent - PHP 5 (PHP 7 required for phpWhois) - PHP PDO - MySQL 15.1 or equivalent -- **A database that is pre-populated with data from [rrdmarc](http://www.taugh.com/rddmarc/) or [dmarcts-report-parser](https://github.com/techsneeze/dmarcts-report-parser)** +- **A database that is pre-populated with data from [Open Report Parser](https://github.com/userjack6880/Open-Report-Parser)** # Dependencies @@ -97,9 +97,8 @@ Valid date signifiers are `m`, `w`, and `d` for "month", "week", and "day". # Latest Changes -## 1-β3 -- Tweaks to the `openda` and `openda_light` themes, including table widths and data coloring. -- Issue template fix per issue #78. +## 1-β4 +- PostgresSQL validation and fixes backported from future Version 2 Alpha 1 branch. See `CHANGELOG` under `docs` for full details of all changes. @@ -107,7 +106,10 @@ See `CHANGELOG` under `docs` for full details of all changes. | OS | HTTP | PHP | SQL | | --------------- | ------------- | ------ | --------------- | -| Debian 11.6 | Apache 2.4.52 | 8.2.3 | MariaDB 10.5.18 | +| Debian 11.6 | Apache 2.4.56 | 8.2.5 | MariaDB 10.5.18 | +| Debian 11.6 | Apache 2.4.56 | 8.2.5 | PostgreSQL 13.9 | +| Debian 11.6 | Apache 2.4.56 | 7.4.33 | MariaDB 10.5.18 | +| Debian 11.6 | Apache 2.4.56 | 7.4.33 | PostgreSQL 13.9 | | CentOS 7.6.1810 | Apache 2.4.6 | 5.4.16 | MariaDB 5.5.65 | If you have a system configuration not listed, and would like to contribue this data, please [provide feedback](https://github.com/userjack6880/Open-Dmarc-Analyzer/issues). @@ -122,9 +124,9 @@ Support will be provided as outlined in the following schedule. For more details | Version | Support Level | Released | End of Support | End of Life | | ----------------------------------- | ---------------- | ---------------- | ---------------- | ---------------- | -| Version 1 Beta 3 | Full Support | 19 April 2023 | 1-rc1 Release | TBD | -| Version 1 Beta 2 | Critical Support | 29 November 2022 | 19 April 2023 | 1-rc1 Release | -| Version 1 Beta 1 | End of Life | 4 November 2022 | 29 November 2022 | 19 April 2023 | +| Version 1 Beta 4 | Full Support | 26 April 2023 | 1-rc1 Release | TBD | +| Version 1 Beta 3 | Critical Support | 19 April 2023 | 26 April 2023 | 1-rc1 Release | +| Version 1 Beta 2 | End of Life | 29 November 2022 | 19 April 2023 | 26 April 2023 | # Contributing diff --git a/config.php.pub b/config.php.pub index 78ec6c2..d8f6167 100644 --- a/config.php.pub +++ b/config.php.pub @@ -33,7 +33,8 @@ define('DB_HOST', 'localhost'); define('DB_USER', 'dmarc'); define('DB_PASS', 'password'); define('DB_NAME', 'dmarc'); -define('DB_PORT', '3306'); // default port 3306 +define('DB_PORT', '3306'); // default port 3306, 5432 for pgsql +define('DB_TYPE', 'mysql'); // supported mysql and pgsql // Debug Settings diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 1d12b1f..1b0e50d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1-β4 +- PostgresSQL validation and fixes backported from future Version 2 Alpha 1 branch. + ## 1-β3 - Tweaks to the `openda` and `openda_light` themes, including table widths and data coloring. - Issue template fix per issue #78. diff --git a/docs/SECURITY.md b/docs/SECURITY.md index d50ac2d..050d69b 100644 --- a/docs/SECURITY.md +++ b/docs/SECURITY.md @@ -20,8 +20,9 @@ Open DMARC Analyzer Version Security Support | Version | Supported | End of Life | | -------------------------- | --------- | ---------------- | -| Version 1 Beta 3 | YES | TBD | -| Version 1 Beta 2 | YES | 1-rc1 Release | +| Version 1 Beta 4 | YES | TBD | +| Version 1 Beta 3 | YES | 1-rc1 Release | +| Version 1 Beta 2 | NO | 26 April 2023 | | Version 1 Beta 1 | NO | 19 April 2023 | | Version 1 Feature Complete | NO | 29 November 2022 | | Version 0 Alpha 9 | NO | 4 November 2022 | diff --git a/docs/SUPPORT.md b/docs/SUPPORT.md index 3a072da..8869d9c 100644 --- a/docs/SUPPORT.md +++ b/docs/SUPPORT.md @@ -4,8 +4,9 @@ Due to the limited time available to developrs to maintain support, dates must b | Version | Support Level | Released | End of Support | End of Life | | ----------------------------------- | ---------------- | ---------------- | ---------------- | ---------------- | -| Version 1 Beta 3 | Full Support | 19 April 2023 | 1-rc1 Release | TBD | -| Version 1 Beta 2 | Critical Support | 29 November 2022 | 19 April 2023 | 1-rc1 Release | +| Version 1 Beta 4 | Full Support | 26 April 2023 | 1-rc1 Release | TBD | +| Version 1 Beta 3 | Critical Support | 19 April 2023 | 26 April 2023 | 1-rc1 Release | +| Version 1 Beta 2 | End of Life | 29 November 2022 | 19 April 2023 | 26 April 2023 | | Version 1 Beta 1 | End of Life | 4 November 2022 | 29 November 2022 | 19 April 2023 | | Version 1 Feature Complete | End of Life | 27 July 2022 | 4 November 2022 | 29 November 2022 | | Version 0 Alpha 9 | End of Life | 2 May 2022 | 27 July 2022 | 4 November 2022 | diff --git a/includes/db.php b/includes/db.php index 2d91c54..489c260 100644 --- a/includes/db.php +++ b/includes/db.php @@ -30,7 +30,15 @@ // Connect to DB // function dbConn() { try { - $pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_PORT, DB_USER, DB_PASS); + if (DB_TYPE == "pgsql") { + $pdo = new PDO("pgsql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_PORT, DB_USER, DB_PASS); + } + elseif (DB_TYPE == "mysql") { + $pdo = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME.";port=".DB_PORT, DB_USER, DB_PASS); + } + else { + echo 'Incorrect DB Type: '.DB_TYPE; + } } catch (PDOException $e) { echo 'Connection failed: '.$e->getMessage(); diff --git a/includes/functions.php b/includes/functions.php index 2b8e0a6..e5c0508 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -84,7 +84,7 @@ function dashboard($dateRange,$domain) { domain, sum(rcount) AS total_messages, policy_p, policy_pct FROM report_stats WHERE mindate BETWEEN :startdate AND NOW() - GROUP BY domain + GROUP BY domain, policy_p, policy_pct ) t1 LEFT JOIN (SELECT domain, sum(rcount) AS none FROM report_stats diff --git a/includes/template.php b/includes/template.php index 91deeb9..6d83647 100644 --- a/includes/template.php +++ b/includes/template.php @@ -31,7 +31,7 @@ // Versioning ----------------------------------------------------------------- function oda_version() { - echo "1-β3"; + echo "1-β4"; } diff --git a/install.php b/install.php index 660772b..b81710b 100644 --- a/install.php +++ b/install.php @@ -40,7 +40,7 @@ $statement =''; echo "opening file..."; -$lines = file('mysql.sql'); +$lines = file(DB_TYPE.'.sql'); echo " success
"; foreach ($lines as $line) @@ -89,6 +89,13 @@ echo "FAILED → mysql.sql
"; } +if (unlink('pgsql.sql') == true) { + echo "DELETED → pgsql.sql
"; +} +else { + echo "FAILED → pgsql.sql
"; +} + if (unlink(__FILE__) == true) { echo "DELETED → install.php
"; } diff --git a/pgsql.sql b/pgsql.sql new file mode 100644 index 0000000..17875d3 --- /dev/null +++ b/pgsql.sql @@ -0,0 +1,8 @@ +CREATE OR REPLACE VIEW report_stats AS ( + SELECT + report.serial, domain, rcount, disposition, reason, + policy_p, policy_pct, dkimdomain, dkimresult, dkim_align, + spfdomain, spfresult, spf_align, mindate, maxdate + FROM report RIGHT JOIN rptrecord + ON report.serial=rptrecord.serial +);