Compare commits

...

42 Commits
v0.5 ... master

Author SHA1 Message Date
jorgegv
78144ee1e4
fix mariadb root password interpolation in health check configuration (#73)
* fix mariadb root password interpolation in health check configuration

* fix env.example typo

---------

Co-authored-by: Robert Schumann <robert@schumann.link>
2025-03-20 12:59:09 +01:00
github-actions[bot]
2bd4fa2677
[chore] update contributors svg (#72)
Co-authored-by: gutmensch <gutmensch@users.noreply.github.com>
2025-03-20 12:57:45 +01:00
Simon
5e95ad2e14
Resolve small issues in the docker-compose files (#71)
And move optional extended configs directly into the compose/.env files
2025-02-12 20:07:14 +01:00
github-actions[bot]
81cad2e81e
[chore] update contributors svg (#69)
Co-authored-by: gutmensch <gutmensch@users.noreply.github.com>
2025-01-21 15:28:18 +01:00
Perlenjaeger
919fe857ae
remove of some inconsistency in the docker compose examples (#63)
Co-authored-by: Sven Förster <acc_gitlab@svfo.de>
2025-01-20 18:27:27 +01:00
github-actions[bot]
b28ae804bf
[chore] update contributors svg (#62)
Co-authored-by: gutmensch <gutmensch@users.noreply.github.com>
2024-08-27 18:24:33 +02:00
corelgott
552f67da65
docs: Manual Update and docker-compose cleanup (#61)
* Added command to trigger a manual report update. Removes verison-tag from docker-compose, since its deprecated

* chore: Added docker-compose examples and env-file

- Added examples-folder
- Added an example for a docker-compose with mysql
- Added an example for a docker-compose with postgres
- Extracted the most important variables to an env.example file
- Added some documentation on how to use the env-file and the compose files
2024-08-27 18:23:15 +02:00
Robert Schumann
072c8e5e33
chore: add arm64 image, fixes #34 (#37) 2024-02-18 14:40:46 +01:00
Robert Schumann
7455b3a4bc
fix: pin dbd mysql version, also add some build tools (#54)
* fix: pin dbd mysql version, also add some build tools

  * fixes #53

* fix: add flag for outdated dists
2024-02-05 18:03:15 +01:00
Robert Schumann
36b5748844 fix: more environment vars for parser, fixes #52
* also update source dates
2024-02-04 23:44:22 +01:00
Robert Schumann
58d3e23ff1 chore: bump upstream sources 2024-02-04 23:24:59 +01:00
github-actions[bot]
07a932ae19
[chore] update contributors svg (#41)
Co-authored-by: gutmensch <gutmensch@users.noreply.github.com>
2023-09-22 11:57:05 +02:00
Marvin Scham
e7c55a0d2c
Added db persistence and healthcheck to compose sample (#38) 2023-09-22 11:50:06 +02:00
github-actions[bot]
2bcf0673d2
[chore] update contributors svg (#33)
Co-authored-by: gutmensch <gutmensch@users.noreply.github.com>
2023-04-07 12:16:07 +02:00
Robert Schumann
1e7c3d841d fix: add empty CONTRIBUTORS.svg 2023-04-07 12:14:57 +02:00
Robert Schumann
f8e7050f94 chore: add contributors and stargazers 2023-04-07 12:12:53 +02:00
Chris van Meer
8f1fb13960
Include PARSER_XML_MAXSIZE env variable. (#32) 2023-03-01 09:37:59 +01:00
Robert Schumann
4486d7d8bf fix(env): postgres env var handling by @madman-sf
* fixes #28
2023-01-10 22:12:15 +01:00
madman-sf
0cc77fd254
pgsql is the wrong identifier (#29)
changed pgsql to Pg identifier in dmarc-report-parser.conf
2023-01-10 22:09:47 +01:00
Robert Schumann
73baf6f923 chore(docs): update build status icon 2023-01-07 23:48:36 +01:00
Robert Schumann
8981d3afbf chore(build): add github action
* update documentation

  * fix report parser option and defaults

  * fixes #28

  * fixes #31
2023-01-07 23:05:36 +01:00
Robert Schumann
aab0d17980 fix paths in entrypoint 2022-08-10 09:31:56 +02:00
Kim Oliver Drechsel
07b5a195b4
Fix execution order in entrypoint.sh (#23)
I just checked my changes in PR #22 and I made a mistake in my commit yesterday that makes my code changes in the `entrypoint.sh` unreachable because supervisord is running in foreground mode.
It should be right before the line to start supervisord like in this PR.
Sorry for that.
2022-08-10 00:41:26 +02:00
Robert Schumann
da49afba3d update README 2022-08-10 00:38:04 +02:00
Robert Schumann
19f680a865 fix latest changes to viewer and parser
* new dependency postgres and PDO

	* php8 compatible
2022-08-10 00:08:41 +02:00
Robert Schumann
87e271d084 fix: disable concurrent builds 2022-08-09 21:16:39 +02:00
Kim Oliver Drechsel
87ee0534df
Get and parse dmarc reports once at startup (#22)
Run the dmarc report parser script once at startup to avoid PHP errors with a new database.
Also show additional information in the container logs if something failed there.
This should also fix issues #17 and #19
2022-08-09 20:48:04 +02:00
Kim Oliver Drechsel
b895501242
Add tzdata package to fix wrong system time (#21)
Without the tzdata package, the TZ env var won't have effect on the system time within the container, what will lead to wrong timestamps in any logs.
2022-08-09 20:45:07 +02:00
Gene Wood
6a21e9efab
Remove note about upstream parser needing to merge a PR (#20)
The upstream PR was merged
2022-07-28 23:36:53 +02:00
Robert Schumann
bf2f61f236 update readme and pipeline 2021-12-12 12:03:39 +01:00
Robert Schumann
9637263016 update build status 2021-12-11 00:04:47 +01:00
Robert Schumann
b7a924ea5a test1 2021-12-10 22:48:00 +01:00
Robert Schumann
aadc22d760 test1 2021-12-10 22:45:19 +01:00
Robert Schumann
3ff0de46cd test1 2021-12-10 22:38:42 +01:00
Robert Schumann
3da8a5ff63 echo repo url 2021-12-10 22:08:06 +01:00
Robert Schumann
28e21af0f5 fix space 2021-12-10 21:51:08 +01:00
Robert Schumann
a5ff675bc9 fix upstream image 2021-12-10 21:49:25 +01:00
Robert Schumann
b5271abc8a update pipeline and remove chmod for entrypoint 2021-12-10 21:46:14 +01:00
Robert Schumann
a1358b9187
Update README.md 2021-12-08 01:00:52 +01:00
saltzimania
71d487cb9d
Environment Variable for PARSER_IMAP_IGNORE_ERROR (#14)
* Update dmarcts-report-parser.conf

Was getting the example error so added env variable so we can use docker-compose.yml to ignore errors.  This was experienced with Exchange Online in Microsoft 365.  This appears to have resolved the issue and dmarc reports were successfully retrieved and moved into the processed folder.

* Update README.md

* Update README.md

Fixed tab character
2021-11-21 13:23:06 +01:00
Robert Schumann
526e230616 fixes #13
* explicitly disable ro for compressed tables on mariadb example image
2021-07-24 13:59:01 +02:00
Robert Schumann
c74bc90d20 Bump version and image, fixes #10
* alpine 3.5 to 3.13

	* openssl upgrade, remove MimeInfo and SSL perl pkg hacks

	* mysql client library upgrades (compatibility with 8)

	* image size reduction 703 to 322 MB

	* bump upstream sources for viewer and parser

	* introduce tags (current and latest docker image 1.0, old image
          still available as 0.5)
2021-07-04 13:36:03 +02:00
13 changed files with 575 additions and 97 deletions

35
.github/workflows/contributors.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Contributors
on:
push:
branches:
- master
jobs:
contributors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: wow-actions/contributors-list@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
svgPath: CONTRIBUTORS.svg
sort: true
round: true
includeBots: false
userNameHeight: 19
# This job does not have commit powers to the `master` branch
noCommit: true
itemTemplate: >
<g transform="translate({{ x }}, {{ y }})">
<a xlink:href="{{{ url }}}" class="contributor-link" target="_blank" rel="nofollow sponsored" title="{{{ name }}}" id="{{{ name }}}">
<image width="{{ width }}" height="{{ height }}" xlink:href="{{{ avatar }}}" />
<text x="32" y="74" text-anchor="middle" alignment-baseline="middle" font-size="10">{{{ name }}}</text>
</a>
</g>
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
commit-message: '[chore] update contributors svg'
title: '[chore] update contributors svg'
delete-branch: true
assignees: gutmensch
reviewers: gutmensch

54
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,54 @@
name: Docker Image CI
on:
push:
branches:
- master
tags:
- "v*"
pull_request:
branches:
- master
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: gutmensch/dmarc-report
flavor: latest=true
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
- name: Login to DockerHub
if: github.ref_type == 'tag'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64, linux/arm64
file: Dockerfile
push: ${{ github.ref_type == 'tag' }}
tags: |
${{ steps.meta.outputs.tags }}
gutmensch/dmarc-report:latest
labels: ${{ steps.meta.outputs.labels }}

63
CONTRIBUTORS.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 3.5 MiB

View File

@ -1,47 +1,83 @@
FROM boxedcode/alpine-nginx-php-fpm:v1.7.2
ARG UPSTREAM_IMAGE=trafex/php-nginx:2.6.0
MAINTAINER Robert Schumann <gutmensch@n-os.org>
FROM $UPSTREAM_IMAGE
LABEL maintainer="Robert Schumann <rs@n-os.org>"
ENV REPORT_PARSER_SOURCE="https://github.com/techsneeze/dmarcts-report-parser/archive/master.zip" \
REPORT_VIEWER_SOURCE="https://github.com/techsneeze/dmarcts-report-viewer/archive/master.zip"
REPORT_VIEWER_SOURCE="https://github.com/techsneeze/dmarcts-report-viewer/archive/master.zip"
USER root
WORKDIR /
COPY ./manifest/ /
RUN set -x \
&& apk update \
&& apk add expat-dev mariadb-dev gzip \
&& wget -q --no-check-certificate -O parser.zip $REPORT_PARSER_SOURCE \
&& wget -q --no-check-certificate -O viewer.zip $REPORT_VIEWER_SOURCE \
&& unzip parser.zip && cp -av dmarcts-report-parser-master/* /usr/bin/ && rm -f parser.zip \
&& unzip viewer.zip && cp -av dmarcts-report-viewer-master/* /var/www/viewer/ && rm -f viewer.zip \
&& sed -i "1s/^/body { font-family: Sans-Serif; }\n/" /var/www/viewer/default.css \
&& (echo y;echo o conf prerequisites_policy follow;echo o conf commit)|cpan \
&& cpan install SULLR/IO-Socket-SSL-2.060.tar.gz \
&& cpan install MICHIELB/File-MimeInfo-0.28.tar.gz \
&& for i in \
CPAN \
IO::Compress::Gzip \
Getopt::Long \
Mail::IMAPClient \
Mail::Mbox::MessageParser \
MIME::Base64 \
MIME::Words \
MIME::Parser \
MIME::Parser::Filer \
XML::Parser \
XML::Simple \
DBI \
DBD::mysql \
Socket \
Socket6 \
PerlIO::gzip \
; do cpan install $i; done \
&& apk del mariadb-dev expat-dev \
&& apk add mariadb-client-libs \
&& sed -i 's%.*root /var/www/html;% root /var/www/viewer;%g' /etc/nginx/conf.d/default.conf \
&& sed -i 's/.*index index.php index.html index.htm;/ index dmarcts-report-viewer.php;/g' /etc/nginx/conf.d/default.conf \
&& chmod 755 /entrypoint.sh
RUN set -e -x \
&& apk add -U \
bash \
cmake \
expat-dev \
g++ \
gpg \
gzip \
libpq \
libpq-dev \
make \
mariadb-client \
mariadb-connector-c \
mariadb-dev \
musl-obstack \
musl-obstack-dev \
openssl \
openssl-dev \
perl-dev \
perl-utils \
php81-pdo \
php81-pdo_mysql \
php81-pdo_pgsql \
tzdata \
wget \
&& wget -4 -q --no-check-certificate -O parser.zip $REPORT_PARSER_SOURCE \
&& wget -4 -q --no-check-certificate -O viewer.zip $REPORT_VIEWER_SOURCE \
&& unzip parser.zip && cp -av dmarcts-report-parser-master/* /usr/bin/ && rm -vf parser.zip && rm -rvf dmarcts-report-parser-master \
&& unzip viewer.zip && cp -av dmarcts-report-viewer-master/* /var/www/viewer/ && rm -vf viewer.zip && rm -rvf dmarcts-report-viewer-master \
&& sed -i "1s/^/body { font-family: Sans-Serif; }\n/" /var/www/viewer/default.css \
&& sed -i 's%.*listen [::]:8080 default_server;% listen [::]:80 default_server;%g' /etc/nginx/nginx.conf \
&& sed -i 's%.*listen 8080 default_server;% listen 80 default_server;%g' /etc/nginx/nginx.conf \
&& sed -i 's%.*root /var/www/html;% root /var/www/viewer;%g' /etc/nginx/nginx.conf \
&& sed -i 's/.*index index.php index.html;/ index dmarcts-report-viewer.php;/g' /etc/nginx/nginx.conf \
&& sed -i 's%files = /etc/supervisor.d/\*.ini%files = /etc/supervisor/conf.d/*.conf%g' /etc/supervisord.conf \
&& (echo y;echo o conf allow_installing_outdated_dists yes;echo o conf prerequisites_policy follow;echo o conf commit)|cpan \
&& for i in \
IO::Socket::SSL \
CPAN \
CPAN::DistnameInfo \
File::MimeInfo \
IO::Compress::Gzip \
Getopt::Long \
Mail::IMAPClient \
Mail::Mbox::MessageParser \
MIME::Base64 \
MIME::Words \
MIME::Parser \
MIME::Parser::Filer \
XML::Parser \
XML::Simple \
DBI \
# XXX: pinning to a version, which does not suffer from mariadb 10 version comparison issues
# TODO: replace with DBD::mysql again, when issue is resolved
# https://forum.bestpractical.com/t/mysql-dependency-error-with-mariadb-and-debian-12/38748/2
DVEEDEN/DBD-mysql-4.052.tar.gz \
DBD::Pg \
Socket \
Socket6 \
PerlIO::gzip \
; do cpan install $i; done \
&& apk del mariadb-dev expat-dev openssl-dev perl-dev g++ cmake make musl-obstack-dev libpq-dev
EXPOSE 443 80
HEALTHCHECK --interval=1m --timeout=3s CMD curl --silent --fail http://127.0.0.1:80/fpm-ping
EXPOSE 80
CMD ["/bin/bash", "/entrypoint.sh"]

125
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,125 @@
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
import java.text.SimpleDateFormat
DOCKER_IMAGE_NAME = ''
DOCKER_IMAGE = ''
DOCKER_ARGS = '--network=services_default'
DOCKER_REGISTRY = 'registry.n-os.org:5000'
properties([
disableConcurrentBuilds(),
parameters([
booleanParam(name: 'SKIP_TESTS', defaultValue: false, description: 'Do you want to run the build with tests?')
])
])
node {
try {
pipeline()
}
catch(e) {
setBuildStatus(e.toString().take(140), 'FAILURE')
throw e
}
finally {
cleanup()
}
}
/*
******************************************************************
standard functions
these functions below implement the standard docker image pipeline
******************************************************************
*/
def pipeline() {
stage('checkout git') {
checkout scm
setBuildStatus('In progress...', 'PENDING')
}
// https://docs.cloudbees.com/docs/admin-resources/latest/plugins/docker-workflow
stage('build image') {
DOCKER_IMAGE_NAME = "${DOCKER_REGISTRY}/${getDockerImage()}:${getDockerTag()}"
DOCKER_IMAGE = docker.build(DOCKER_IMAGE_NAME, "--no-cache ${DOCKER_ARGS} .")
}
stage('run tests') {
if (fileExists('./test/run.sh') && !params.SKIP_TESTS) {
DOCKER_IMAGE.inside("${DOCKER_ARGS} --entrypoint=") {
sh 'bash /usr/build/test/run.sh'
}
}
else {
Utils.markStageSkippedForConditional('run tests')
}
}
stage('push image') {
if (BRANCH_NAME == 'master') {
DOCKER_IMAGE.push()
}
else {
Utils.markStageSkippedForConditional('push image')
}
}
stage('delete image') {
if (BRANCH_NAME == 'master') {
Utils.markStageSkippedForConditional('delete image')
}
else {
deleteDockerImage(DOCKER_IMAGE_NAME)
}
setBuildStatus('Success', 'SUCCESS')
}
}
void deleteDockerImage(image) {
sh(script: "docker rmi -f ${image}")
}
void cleanup() {
stage('schedule cleanup') {
build job: '/maintenance/starter', wait: false
}
}
String getDockerImage() {
return sh(script: "echo '${JOB_NAME}' | awk -F/ '{print \$(NF-1)}' | sed 's%docker-%%'", returnStdout: true).trim()
}
String getDockerTag() {
def shortHash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim()
def date = new Date()
def sdf = new SimpleDateFormat("yyyyMMddHHmmss")
// semver in TAG_ID file or reference to ARG in Dockerfile
if (!fileExists('./TAG_ID')) {
return "${sdf.format(date)}.${shortHash}.b${BUILD_ID}"
}
def tagId = sh(script: 'cat ./TAG_ID', returnStdout: true).trim()
if (tagId ==~ /^[A-Z_]+$/) {
return sh(script: "awk -F= '/ARG ${tagId}=/{print \$2}' Dockerfile", returnStdout: true).trim()
}
else {
return tagId
}
}
void setBuildStatus(message, state) {
def repoUrl = sh(script: 'git config --get remote.origin.url', returnStdout: true).trim()
step([
$class: "GitHubCommitStatusSetter",
reposSource: [$class: "ManuallyEnteredRepositorySource", url: repoUrl],
contextSource: [$class: "ManuallyEnteredCommitContextSource", context: "ci/jenkins/build-status"],
errorHandlers: [[$class: "ChangingBuildStatusErrorHandler", result: "UNSTABLE"]],
statusResultSource: [ $class: "ConditionalStatusResultSource", results: [[$class: "AnyBuildResult", message: message, state: state]] ]
]);
}

View File

@ -1,75 +1,74 @@
# docker-dmarc-report [![Docker Pulls](https://img.shields.io/docker/pulls/gutmensch/dmarc-report.svg)](https://registry.hub.docker.com/u/gutmensch/dmarc-report/)
# docker-dmarc-report ![Docker Build](https://github.com/gutmensch/docker-dmarc-report/actions/workflows/docker-image.yml/badge.svg) [![Docker Pulls](https://img.shields.io/docker/pulls/gutmensch/dmarc-report.svg)](https://registry.hub.docker.com/u/gutmensch/dmarc-report/)
This image is intended to combine a dmarc report parser (see https://github.com/techsneeze/dmarcts-report-parser by TechSneeze.com and John Bieling) with a report viewer (see https://github.com/techsneeze/dmarcts-report-viewer/ by the same people) into a runnable docker image / microservice.
It fetches dmarc report mails regularly from an IMAP server, stores them into a MySQL DB and visualizes them via Webserver/PHP module.
## Howto
1. Create a _dmarc.example.com TXT DNS record for your domain, containg an IMAP postbox, e.g.
```
1. Create a \_dmarc.example.com TXT DNS record for your domain, containg an IMAP postbox, e.g.
```bash
17:18 $ dig TXT _dmarc.schumann.link +short
"v=DMARC1\; p=quarantine\; fo=1\; rua=mailto:dmarc@schumann.link\; ruf=mailto:dmarc@schumann.link\; adkim=s\; aspf=s\;"
```
2. Create a MySQL Database and a user for this service
3. Run this docker image with below mentioned env vars
4. Access port 80 on the container (or 443) or put it behind a reverse proxy to view reports
```
1. Create a MySQL Database and a user for this service
1. Run this docker image with below mentioned env vars
1. Access port 80 on the container (or 443) or put it behind a reverse proxy to view reports
```bash
docker pull gutmensch/dmarc-report
docker run -e ... -ti gutmensch/dmarc-report
```
New dmarc reports will be fetched every 15 minutes past the hour, every hour. Therefore it can take up to one hour for the first report to be fetched.
## Versions for last build latest
dmarcts report viewer: 2020-09-06
## Versions for last build latest and docker image tag 1.4
dmarcts report parser: 2020-09-06
dmarcts report viewer: 2024-02-04
dmarcts report parser: 2024-02-04
CAUTION: The old gutmensch/dmarc-report:latest image (older alpine, php5, etc.) is available still as gutmensch/dmarc-report:0.5. The current latest (and 1.0) uses the latest alpine version, newer MySQL client libraries, newer OpenSSL, etc. and improves compatibilitiy with MySQL 8+.
## Frontend Screenshot
![DMARC Report Viewer](https://github.com/gutmensch/docker-dmarc-report/blob/master/screenshot.png?raw=true)
## Sample docker compose / Environment variables
The variables should be self-explanatory. Make sure to create the IMAP folders before the cron job runs!
**docker-compose.yml**
```yaml
version: '3.6'
Make sure to create the IMAP-Folders for processed and error reports before the cron job runs!
services:
dmarc-report:
image: "gutmensch/dmarc-report:latest"
hostname: dmarc-report
container_name: dmarc-report
depends_on:
- db
ports:
- "80:80"
environment:
- "REPORT_DB_HOST=db"
- "REPORT_DB_NAME=dmarc_report"
- "REPORT_DB_USER=dmarc_report"
- "REPORT_DB_PASS=dbpassword"
- "PARSER_IMAP_SERVER=mail"
- "PARSER_IMAP_PORT=143"
- "PARSER_IMAP_USER=foobar@example.com"
- "PARSER_IMAP_PASS=foobar"
- "PARSER_IMAP_READ_FOLDER=Inbox"
- "PARSER_IMAP_MOVE_FOLDER=processed"
- "PARSER_IMAP_MOVE_FOLDER_ERR=error"
The default foldernames are are [`error`](examples/env.example) & [`processed`](examples/env.example) but they can be changed within the [`env-file`](examples/env.example).
db:
image: mariadb:10
environment:
- "MYSQL_ROOT_PASSWORD=dbrootpassword"
- "MYSQL_DATABASE=dmarc_report"
- "MYSQL_USER=dmarc_report"
- "MYSQL_PASSWORD=dbpassword"
Make sure to rename the [`env.example`](examples/env.example) file to `.env` and adjust the values to your needs.
You can find templates for both, [`postgreql`](examples/docker-compose.postgres.yml)
and [`mysql`](examples/docker-compose.mysql.yml)
db in the [`examples`](examples) directory. Just rename the setup you want to use to `docker-compose.yml`.
## Manual update
If you are using the docker-compose file above, you can use this command to trigger an manual update. It will fetch the latest reports and parse them.
```bash
docker compose exec dmarc-report /usr/bin/dmarcts-report-parser.pl -i -d -r=1
```
## Optional extended configuration
Use SSL instead of default TLS. Set both to 0 to turn off encryption. (not recommended)
```yaml
- "PARSER_IMAP_SSL=1"
- "PARSER_IMAP_TLS=0"
```
For further optional configuration see the docker-compose [`env-file`](examples/env.example).
## Contributors
<img src="./CONTRIBUTORS.svg">
## Stargazers over time
[![Stargazers over time](https://starchart.cc/gutmensch/docker-dmarc-report.svg)](https://starchart.cc/gutmensch/docker-dmarc-report)

View File

@ -0,0 +1,46 @@
services:
dmarc-report:
image: "gutmensch/dmarc-report:latest"
hostname: dmarc-report
container_name: dmarc-report
restart: always
depends_on:
db:
condition: service_healthy
ports:
- "80:80"
environment:
- "REPORT_DB_HOST=${DB_HOST:-db}"
- "REPORT_DB_TYPE=${DB_TYPE:-mysql}"
- "REPORT_DB_PORT=${DB_PORT:-3306}"
- "REPORT_DB_NAME=${DB_NAME:-dmarc_report}"
- "REPORT_DB_USER=${DB_USER:-dmarc_report}"
- "REPORT_DB_PASS=${DB_PASSWORD}"
- "PARSER_IMAP_SERVER=${IMAP_SERVER}"
- "PARSER_IMAP_PORT=${IMAP_PORT:-993}"
- "PARSER_IMAP_USER=${IMAP_USER}"
- "PARSER_IMAP_PASS=${IMAP_PASSWORD}"
- "PARSER_IMAP_READ_FOLDER=${IMAP_READ_FOLDER:-Inbox}"
- "PARSER_IMAP_MOVE_FOLDER=${IMAP_MOVE_FOLDER:-processed}"
- "PARSER_IMAP_MOVE_FOLDER_ERR=${IMAP_MOVE_FOLDER_ERR:-error}"
- "PARSER_IMAP_SSL=${PARSER_IMAP_SSL}"
- "PARSER_IMAP_TLS=${PARSER_IMAP_TLS}"
- "PARSER_IMAP_IGNORE_ERROR=${PARSER_IMAP_IGNORE_ERROR}"
- "PARSER_XML_MAXSIZE=${PARSER_XML_MAXSIZE}"
db:
image: mariadb:10
command: --skip-innodb-read-only-compressed
restart: always
environment:
- "MYSQL_ROOT_PASSWORD=${ROOT_DB_PASSWORD}"
- "MYSQL_DATABASE=${DB_NAME:-dmarc_report}"
- "MYSQL_USER=${DB_USER:-dmarc_report}"
- "MYSQL_PASSWORD=${DB_PASSWORD}"
volumes:
- ./run/db:/var/lib/mysql
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${ROOT_DB_PASSWORD}"]
interval: 10s
timeout: 10s
retries: 5

View File

@ -0,0 +1,44 @@
services:
dmarc-report:
image: "gutmensch/dmarc-report:latest"
hostname: dmarc-report
container_name: dmarc-report
restart: always
depends_on:
db:
condition: service_healthy
ports:
- "80:80"
environment:
- "REPORT_DB_HOST=${DB_HOST:-db}"
- "REPORT_DB_TYPE=${DB_TYPE:-pgsql}"
- "REPORT_DB_PORT=${DB_PORT:-5432}"
- "REPORT_DB_NAME=${DB_NAME:-dmarc_report}"
- "REPORT_DB_USER=${DB_USER:-dmarc_report}"
- "REPORT_DB_PASS=${DB_PASSWORD}"
- "PARSER_IMAP_SERVER=${IMAP_SERVER}"
- "PARSER_IMAP_PORT=${IMAP_PORT:-993}"
- "PARSER_IMAP_USER=${IMAP_USER}"
- "PARSER_IMAP_PASS=${IMAP_PASSWORD}"
- "PARSER_IMAP_READ_FOLDER=${IMAP_READ_FOLDER:-Inbox}"
- "PARSER_IMAP_MOVE_FOLDER=${IMAP_MOVE_FOLDER:-processed}"
- "PARSER_IMAP_MOVE_FOLDER_ERR=${IMAP_MOVE_FOLDER_ERR:-error}"
- "PARSER_IMAP_SSL=${PARSER_IMAP_SSL}"
- "PARSER_IMAP_TLS=${PARSER_IMAP_TLS}"
- "PARSER_IMAP_IGNORE_ERROR=${PARSER_IMAP_IGNORE_ERROR}"
- "PARSER_XML_MAXSIZE=${PARSER_XML_MAXSIZE}"
db:
image: postgres:latest
restart: always
environment:
- "POSTGRES_DB=${DB_NAME:-dmarc_report}"
- "POSTGRES_USER=${DB_USER:-dmarc_report}"
- "POSTGRES_PASSWORD=${DB_PASSWORD}"
volumes:
- ./run/db:/var/lib/postgresql/data
healthcheck:
test: ["CMD-SHELL", "pg_isready -U dmarc_report"]
interval: 10s
timeout: 10s
retries: 5

53
examples/env.example Normal file
View File

@ -0,0 +1,53 @@
# database host address, leave empty for default host "db"
DB_HOST=
# the database type mysql or pgsql, leave empty for default (depending on your docker-compose.yml)
DB_TYPE=
# the database port (mysql 3306) (pqsql 5432), leave empty for default (depending on your docker-compose.yml)
DB_PORT=
# the database name, leave empty for default "dmarc_report"
DB_NAME=
# the database name, leave empty for default "dmarc_report"
DB_USER=
# mysql root password. Irrelevant if you are using postgres
ROOT_DB_PASSWORD=
# database password for the database user
DB_PASSWORD=
# the email address receiving the DMARC reports
IMAP_USER=
# the password for the email address receiving the DMARC reports
IMAP_PASSWORD=
# the server the email address is hosted on
IMAP_SERVER=
# optional: default is 993 (or 143)
IMAP_PORT=
# optional: default is "Inbox"
IMAP_READ_FOLDER=
# optional: default is "processed"
IMAP_MOVE_FOLDER=
# optional: default is "error"
IMAP_MOVE_FOLDER_ERR=
# Enable SSL and/or (START-)TLS. Set both to 0 to disable encryption (not recommended)
PARSER_IMAP_SSL=0
PARSER_IMAP_TLS=1
# Ignore ERROR: message_string() issue experienced with Exchange Online. Set to 1 to enable
PARSER_IMAP_IGNORE_ERROR=0
# Increase the maximum size of the XML file. (default is 50000 bytes)
# When the size exceeds the maximum, one could experience an error Uncaught ValueError: DOMDocument::loadXML():
# Argument #1 ($source) must not be empty.
PARSER_XML_MAXSIZE=50000

30
manifest/entrypoint.sh Normal file → Executable file
View File

@ -1,14 +1,17 @@
#!/usr/bin/env bash
# change according to alpine and php release
PHP_VERSION=81
# Display PHP error's or not
if [[ "$ERRORS" != "1" ]] ; then
sed -i -e "s/error_reporting =.*=/error_reporting = E_ALL/g" /usr/etc/php.ini
sed -i -e "s/display_errors =.*/display_errors = stdout/g" /usr/etc/php.ini
sed -i -e "s/error_reporting =.*/error_reporting = E_ALL/g" /etc/php${PHP_VERSION}/php.ini
sed -i -e "s/display_errors =.*/display_errors = stdout/g" /etc/php${PHP_VERSION}/php.ini
fi
# Disable opcache?
if [[ -v NO_OPCACHE ]]; then
sed -i -e "s/zend_extension=opcache.so/;zend_extension=opcache.so/g" /etc/php.d/zend-opcache.ini
sed -i -e "s/zend_extension=opcache.so/;zend_extension=opcache.so/g" /etc/php${PHP_VERSION}/conf.d/00_opcache.ini
fi
# Tweak nginx to match the workers to cpu's
@ -16,9 +19,26 @@ procs=$(cat /proc/cpuinfo | grep processor | wc -l)
sed -i -e "s/worker_processes 5/worker_processes $procs/" /etc/nginx/nginx.conf
# Copy important env vars for PHP-FPM to access
PHP_ENV_FILE="/usr/etc/php-fpm.d/${PHP_ENV_FILE:-env.conf}"
PHP_ENV_FILE="/etc/php${PHP_VERSION}/php-fpm.d/${PHP_ENV_FILE:-env.conf}"
echo '[www]' > "$PHP_ENV_FILE"
env | grep -e 'REPORT_DB_HOST' -e 'REPORT_DB_NAME' -e 'REPORT_DB_USER' -e 'REPORT_DB_PASS' | sed "s/\(.*\)=\(.*\)/env[\1]='\2'/" >> "$PHP_ENV_FILE"
echo 'user = nginx' >> "$PHP_ENV_FILE"
echo 'group = www-data' >> "$PHP_ENV_FILE"
echo 'listen.owner = nginx' >> "$PHP_ENV_FILE"
echo 'listen.group = www-data' >> "$PHP_ENV_FILE"
env | grep -e 'REPORT_DB_TYPE' -e 'REPORT_DB_HOST' -e 'REPORT_DB_PORT' -e 'REPORT_DB_NAME' -e 'REPORT_DB_USER' -e 'REPORT_DB_PASS' | sed "s/\(.*\)=\(.*\)/env[\1] = '\2'/" >> "$PHP_ENV_FILE"
# compat from older image where variable was not existing
grep -e ^REPORT_DB_PORT "$PHP_ENV_FILE" || echo env[REPORT_DB_PORT] = 3306 >> "$PHP_ENV_FILE"
# Get and parse dmarc reports once at startup to avoid PHP errors with a new database
if /usr/bin/dmarcts-report-parser.pl -i -d -r > /var/log/nginx/dmarc-reports.log 2>&1; then
echo 'INFO: Dmarc reports parsed successfully'
else
echo 'CRIT: Dmarc reports could not be parsed. Check your IMAP and MYSQL Settings.'
echo -e "DEBUG: Parsing failed with the following output:\n"
cat /var/log/nginx/dmarc-reports.log
exit 1
fi
# Start supervisord and services
/usr/bin/supervisord -n -c /etc/supervisord.conf

View File

@ -5,13 +5,15 @@
# If IMAP access is not used, config options starting with $imap do not need to
# be set and are ignored.
$debug = 0;
$delete_reports = 0;
$debug = $ENV{'PARSER_DEBUG'} // 0;
$delete_reports = $ENV{'PARSER_DELETE_REPORTS'} // 0;
$dbname = $ENV{'REPORT_DB_NAME'};
$dbuser = $ENV{'REPORT_DB_USER'};
$dbpass = $ENV{'REPORT_DB_PASS'};
$dbhost = $ENV{'REPORT_DB_HOST'}; # Set the hostname if we can't connect to the local socket.
$dbport = $ENV{'REPORT_DB_PORT'} // 3306;
$dbtype = $ENV{'REPORT_DB_TYPE'} eq 'pgsql' ? 'Pg' : 'mysql';
if(exists $ENV{PARSER_IMAP_SERVER_WITH_PORT} && defined $ENV{PARSER_IMAP_SERVER_WITH_PORT}) {
my @server_attr = split ':', $ENV{PARSER_IMAP_SERVER_WITH_PORT};
@ -27,7 +29,7 @@ $imappass = $ENV{'PARSER_IMAP_PASS'};
$imapssl = $ENV{'PARSER_IMAP_SSL'} // '0'; # If set to 1, remember to change server port to 993 and disable imaptls.
$imaptls = $ENV{'PARSER_IMAP_TLS'} // '1'; # Enabled as the default and best-practice.
$tlsverify = $ENV{'PARSER_IMAP_VERIFY'} // '0'; # Enable verify server cert as the default and best-practice.
$imapignoreerror = 0; # set it to 1 if you see an "ERROR: message_string()
$imapignoreerror = $ENV{'PARSER_IMAP_IGNORE_ERROR'} // '0';# set it to 1 if you see an "ERROR: message_string()
# expected 119613 bytes but received 81873 you may
# need the IgnoreSizeErrors option" because of malfunction
# imap server as MS Exchange 2007, ...
@ -39,12 +41,12 @@ $imapmovefolder = $ENV{'PARSER_IMAP_MOVE_FOLDER'};
$imapmovefoldererr = $ENV{'PARSER_IMAP_MOVE_FOLDER_ERR'};
# maximum size of XML files to store in database, long files can cause transaction aborts
$maxsize_xml = 50000;
$maxsize_xml = $ENV{'PARSER_XML_MAXSIZE'} // 50000;
# store XML as base64 encopded gzip in database (save space, harder usable)
$compress_xml = 0;
$compress_xml = $ENV{'PARSER_XML_COMPRESS'} // 0;
# if there was an error during file processing (message does not contain XML or ZIP parts,
# or a database error) the parser reports an error and does not delete the file, even if
# delete_reports is set (or --delete is given). Deletion can be enforced by delete_failed,
# however not for database errors.
$delete_failed = 0;
$delete_failed = $ENV{'PARSER_DELETE_FAILED'} // 0;

View File

@ -4,11 +4,12 @@
// ### configuration ##################################################
// ####################################################################
$dbtype=getenv('REPORT_DB_TYPE');
$dbhost=getenv('REPORT_DB_HOST');
$dbport=getenv('REPORT_DB_PORT');
$dbname=getenv('REPORT_DB_NAME');
$dbuser=getenv('REPORT_DB_USER');
$dbpass=getenv('REPORT_DB_PASS');
$dbport='3306';
$cssfile="default.css";

Binary file not shown.

Before

Width:  |  Height:  |  Size: 571 KiB

After

Width:  |  Height:  |  Size: 568 KiB