gutmensch / docker-dmarc-report

245 stars 27 forks source link

pgsql is the wrong identifier #29

Closed Perlenjaeger closed 1 year ago

Perlenjaeger commented 1 year ago

changed pgsql to Pg identifier in dmarc-report-parser.conf

here the smale change directly as pr

gutmensch commented 1 year ago

Hey @madman-sf , good catch, thank you! However, we don't need any change in the config file, but just in the README https://github.com/gutmensch/docker-dmarc-report/blob/aab0d1798082bd8d7e86e8d4794a67d21927fbbb/README.md?plain=1#L85 for reference. The perl logic just uses mysql as a default, if the env variable is not defined. But you can of course set the environment variable for the docker container correctly to REPORT_DB_TYPE=Pg whenever you wish. The reasoning here was that MySQL is probably a sane default and we don't really want to manage every possible dbx perl plugins name here in this repo that might be added now or later to the original repository.

Perlenjaeger commented 1 year ago

Hi @gutmensch , to be honest I don't properly understand your answer. my first guess was as well just changing the "REPORT_DB_TYPE=pgsql" but that is not working. Then the "report parser" is not woking. To get the "report parser" working I need to use "REPORT_DB_TYPE=Pg". But if set to "Pg" the "report viewer" is not working. Because the Parser needs the dbtype set to Pg and the Viewer needs the db type set to pgsql I have changed it in the config of the parser.

You can test it yourself with the docker compose file

` version: '3.6'

services: db: image: postgres:alpine

image: mariadb:10

restart: always
env_file:
  - db.env
environment:
  # MYSQL_DATABASE: dmarc_report
  POSTGRES_DB: dmarc_report

dmarc-report: image: madman0sf/dmarc-report:latest

image: "gutmensch/dmarc-report:latest"

restart: always
hostname: dmarc-report
container_name: dmarc-report
ports:
  - "80:80"
depends_on:
  - db
env_file:
  - db.env
environment:
  REPORT_DB_TYPE: pgsql #Pg pgsql
  # REPORT_DB_TYPE: mysql
  REPORT_DB_HOST: db
  REPORT_DB_PORT: 5432 # postgres
  # REPORT_DB_PORT: 3306 # mysql
  REPORT_DB_NAME: dmarc_report
  PARSER_IMAP_SERVER: your.mail
  PARSER_IMAP_PORT: 143
  PARSER_IMAP_READ_FOLDER: DMARC
  PARSER_IMAP_MOVE_FOLDER: DMARC.processed
  PARSER_IMAP_MOVE_FOLDER_ERR: DMARC.error

`

And I know it's a pain in the ass that it has to be defined for every db. But that is because of the not same naming of "Pg" and "pgsql" in the different projects. A solution could be also to provide a DB_TYPE_REPORT and DB_TYPE_VIEWER in the config file.

gutmensch commented 1 year ago

@madman-sf You are correct, the values are 'pgsql' for the viewer and 'Pg' for the parser. How about you rebase against current master and then shorten the statement, because the double checking at the end is not really necessary?

$ REPORT_DB_TYPE=pgsql perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : 'mysql'"
Pg%
$ REPORT_DB_TYPE=mysql perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : 'mysql'"
mysql%
$ perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : 'mysql'"
mysql%

$ REPORT_DB_TYPE=pgsql perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : \$ENV{'REPORT_DB_TYPE'} // 'mysql'"
Pg%
$ REPORT_DB_TYPE=mysql perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : \$ENV{'REPORT_DB_TYPE'} // 'mysql'"
mysql%
$ perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : \$ENV{'REPORT_DB_TYPE'} // 'mysql'"
mysql%
Perlenjaeger commented 1 year ago

ja super Idee. Schreibe jetzt einfach auf deutsch geht eh nur zwischen uns beiden hin und her. Habe es nach deinem Vorschlag abgeändert. Hatte nur im Kopf:

$ REPORT_DB_TYPE=RANDOMnEWdB perl -e "print \$ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : $ENV{'REPORT_DB_TYPE'}"
RANDOMnEWdB%

Daher hatte ich die doppelte Abfrage drin.