Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
edd8a42e2d | |||
fe0bd0470c | |||
1d92622f21 | |||
16e35505d6 | |||
5819107340 | |||
f08937111e | |||
dbb79dd567 | |||
e1d0f95a72 | |||
a2b000a05b | |||
8fbca20ffe | |||
0fc12e5f3c | |||
8502fbd9a1 | |||
7adb4c1fde | |||
419b775dcb | |||
20c12df5ba | |||
0225fc26a6 | |||
e949df8a83 | |||
5ae80b4d9b |
@ -13,6 +13,49 @@ steps:
|
|||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
when:
|
when:
|
||||||
- event: [push, tag]
|
- event: [push, tag]
|
||||||
|
|
||||||
|
scan_image:
|
||||||
|
image: aquasec/trivy
|
||||||
|
commands:
|
||||||
|
- env TRIVY_DISABLE_VEX_NOTICE=1 trivy image $FORGE_NAME/$CI_REPO:$CI_COMMIT_SHA --quiet --exit-code 1
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
|
generate_sbom:
|
||||||
|
image: quay.io/wollud1969/woodpecker-helper:0.5.1
|
||||||
|
environment:
|
||||||
|
TRIVY_TOKEN:
|
||||||
|
from_secret: trivy_token
|
||||||
|
TRIVY_URL:
|
||||||
|
from_secret: trivy_url
|
||||||
|
DTRACK_API_KEY:
|
||||||
|
from_secret: dtrack_api_key
|
||||||
|
DTRACK_API_URL:
|
||||||
|
from_secret: dtrack_api_url
|
||||||
|
commands:
|
||||||
|
- HOME=/home/`id -nu`
|
||||||
|
- TAG="${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||||
|
- |
|
||||||
|
trivy image \
|
||||||
|
--server $TRIVY_URL \
|
||||||
|
--token $TRIVY_TOKEN \
|
||||||
|
--format cyclonedx \
|
||||||
|
--scanners license \
|
||||||
|
--output /tmp/sbom.xml \
|
||||||
|
$FORGE_NAME/$CI_REPO:$CI_COMMIT_SHA
|
||||||
|
- cat /tmp/sbom.xml
|
||||||
|
- |
|
||||||
|
curl -X "POST" \
|
||||||
|
-H "Content-Type: multipart/form-data" \
|
||||||
|
-H "X-Api-Key: $DTRACK_API_KEY" \
|
||||||
|
-F "autoCreate=true" \
|
||||||
|
-F "projectName=$CI_REPO" \
|
||||||
|
-F "projectVersion=$TAG" \
|
||||||
|
-F "bom=@/tmp/sbom.xml"\
|
||||||
|
"$DTRACK_API_URL/api/v1/bom"
|
||||||
|
when:
|
||||||
|
- event: [push, tag]
|
||||||
|
|
||||||
build:
|
build:
|
||||||
image: plugins/kaniko
|
image: plugins/kaniko
|
||||||
settings:
|
settings:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM alpine:3.21.0
|
FROM alpine:3.21.3
|
||||||
|
|
||||||
LABEL Maintainer="Wolfgang Hottgenroth <woho@hottis.de>"
|
LABEL Maintainer="Wolfgang Hottgenroth <woho@hottis.de>"
|
||||||
LABEL ImageName="quay.io/wollud1969/exim-docker"
|
LABEL ImageName="quay.io/wollud1969/exim-docker"
|
||||||
@ -11,8 +11,11 @@ ENV SMARTHOST_USER=""
|
|||||||
ENV SMARTHOST_PASS=""
|
ENV SMARTHOST_PASS=""
|
||||||
# ip addresses or networks to allow for relaying, separate multiple ones by semicolon
|
# ip addresses or networks to allow for relaying, separate multiple ones by semicolon
|
||||||
ENV RELAYNETS="127.0.0.1/32"
|
ENV RELAYNETS="127.0.0.1/32"
|
||||||
|
# whitelist of recipient domains, colon-separated, if empty all no restrictions
|
||||||
|
ENV WHITELISTED_RECIPIENTS=""
|
||||||
|
|
||||||
RUN apk add --no-cache exim m4 openssl
|
|
||||||
|
RUN apk add --no-cache exim m4
|
||||||
|
|
||||||
COPY exim.conf.m4 /etc/exim
|
COPY exim.conf.m4 /etc/exim
|
||||||
COPY start.sh /etc/exim
|
COPY start.sh /etc/exim
|
||||||
|
@ -8,7 +8,7 @@ kubectl create secret generic smtp-secrets \
|
|||||||
--from-literal=SMARTHOST="smtprelaypool.ispgateway.de" \
|
--from-literal=SMARTHOST="smtprelaypool.ispgateway.de" \
|
||||||
--from-literal=SMARTHOST_USER="pseudosmarthostuser@hottis.de" \
|
--from-literal=SMARTHOST_USER="pseudosmarthostuser@hottis.de" \
|
||||||
--from-literal=SMARTHOST_PASS="$SMARTHOST_PASSWORD" \
|
--from-literal=SMARTHOST_PASS="$SMARTHOST_PASSWORD" \
|
||||||
--from-literal=RELAYNETS=":10.0.0.0/8" | \
|
--from-literal=RELAY_NETWORKS=":10.0.0.0/8" | \
|
||||||
kubectl apply -n system -f -
|
kubectl apply -n system -f -
|
||||||
|
|
||||||
kubectl apply -n system -f deploy.yml
|
kubectl apply -n system -f deploy.yml
|
||||||
|
@ -2,6 +2,7 @@ apiVersion: apps/v1
|
|||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
name: smtp
|
name: smtp
|
||||||
|
namespace: system
|
||||||
labels:
|
labels:
|
||||||
app: smtp
|
app: smtp
|
||||||
annotations:
|
annotations:
|
||||||
@ -18,7 +19,7 @@ spec:
|
|||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: smtp
|
- name: smtp
|
||||||
image: quay.io/wollud1969/exim-docker:0.2.2
|
image: quay.io/wollud1969/exim-docker:0.3.2
|
||||||
envFrom:
|
envFrom:
|
||||||
- secretRef:
|
- secretRef:
|
||||||
name: smtp-secrets
|
name: smtp-secrets
|
||||||
@ -30,6 +31,7 @@ apiVersion: v1
|
|||||||
kind: Service
|
kind: Service
|
||||||
metadata:
|
metadata:
|
||||||
name: smtp
|
name: smtp
|
||||||
|
namespace: system
|
||||||
spec:
|
spec:
|
||||||
type: ClusterIP
|
type: ClusterIP
|
||||||
selector:
|
selector:
|
||||||
|
12
exim.conf.m4
12
exim.conf.m4
@ -5,6 +5,8 @@ define(`SMARTHOST', esyscmd(`echo -n $SMARTHOST'))dnl
|
|||||||
define(`SMARTHOST_USER', esyscmd(`echo -n $SMARTHOST_USER'))dnl
|
define(`SMARTHOST_USER', esyscmd(`echo -n $SMARTHOST_USER'))dnl
|
||||||
define(`SMARTHOST_PASS', esyscmd(`echo -n $SMARTHOST_PASS'))dnl
|
define(`SMARTHOST_PASS', esyscmd(`echo -n $SMARTHOST_PASS'))dnl
|
||||||
define(`RELAYNETS', esyscmd(`echo -n $RELAYNETS'))dnl
|
define(`RELAYNETS', esyscmd(`echo -n $RELAYNETS'))dnl
|
||||||
|
define(`WHITELISTED_RECIPIENTS', esyscmd(`echo -n $WHITELISTED_RECIPIENTS'))dnl
|
||||||
|
|
||||||
|
|
||||||
ifelse(SMARTHOST, `', `
|
ifelse(SMARTHOST, `', `
|
||||||
errprint(`Error: SMARTHOST not set')
|
errprint(`Error: SMARTHOST not set')
|
||||||
@ -16,14 +18,15 @@ errprint(`Error: HOSTNAME not set')
|
|||||||
m4exit(1)
|
m4exit(1)
|
||||||
')
|
')
|
||||||
|
|
||||||
|
|
||||||
|
dnl ----------------------------------------------------------------
|
||||||
dnl template for exim.conf
|
dnl template for exim.conf
|
||||||
|
|
||||||
primary_hostname = HOSTNAME
|
primary_hostname = HOSTNAME
|
||||||
|
|
||||||
acl_smtp_rcpt = acl_check_rcpt
|
acl_smtp_rcpt = acl_check_rcpt
|
||||||
|
|
||||||
tls_certificate = /etc/exim/tls.crt
|
tls_advertise_hosts =
|
||||||
tls_privatekey = /etc/exim/tls.key
|
|
||||||
|
|
||||||
begin routers
|
begin routers
|
||||||
smarthost_route:
|
smarthost_route:
|
||||||
@ -58,8 +61,11 @@ begin acl
|
|||||||
acl_check_rcpt:
|
acl_check_rcpt:
|
||||||
accept
|
accept
|
||||||
hosts = RELAYNETS
|
hosts = RELAYNETS
|
||||||
|
ifelse(WHITELISTED_RECIPIENTS, `', `', `
|
||||||
|
domains = WHITELISTED_RECIPIENTS
|
||||||
|
')
|
||||||
deny
|
deny
|
||||||
message = "Relaying denied"
|
message = "550 5.7.1 Relaying denied"
|
||||||
|
|
||||||
ifelse(LOCALMAILNAME, `', `', `
|
ifelse(LOCALMAILNAME, `', `', `
|
||||||
begin rewrite
|
begin rewrite
|
||||||
|
@ -12,6 +12,7 @@ Four environment variables are used to configure the container:
|
|||||||
* `SMARTHOST_PASS`: Password for smarthost.
|
* `SMARTHOST_PASS`: Password for smarthost.
|
||||||
* `LOCALMAILNAME`: The domain name which shall be used as the domain part of the sender address in every outgoing mail. If not required, skip it.
|
* `LOCALMAILNAME`: The domain name which shall be used as the domain part of the sender address in every outgoing mail. If not required, skip it.
|
||||||
* `RELAYNETS`: Networks exim in this container accepts for relaying. Separate multiple networks by semicolon.
|
* `RELAYNETS`: Networks exim in this container accepts for relaying. Separate multiple networks by semicolon.
|
||||||
|
* `WHITELISTED_RECIPIENT`: Colon-separated list of whitelisted recipient domains, if empty no recipient restrictions will be applied
|
||||||
|
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
@ -24,7 +25,7 @@ Typically, don't expose the smtp port of this container to the default network o
|
|||||||
```
|
```
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
IMAGE=quay.io/wollud1969/exim-docker:0.2.2
|
IMAGE=quay.io/wollud1969/exim-docker:0.3.2
|
||||||
MAILER_NETWORK=mailer-network
|
MAILER_NETWORK=mailer-network
|
||||||
|
|
||||||
docker network create $MAILER_NETWORK || echo "mailer-network already exists"
|
docker network create $MAILER_NETWORK || echo "mailer-network already exists"
|
||||||
@ -38,6 +39,7 @@ docker run \
|
|||||||
-e SMARTHOST=smarthost.example.com \
|
-e SMARTHOST=smarthost.example.com \
|
||||||
-e LOCALMAILNAME=krohne.com \
|
-e LOCALMAILNAME=krohne.com \
|
||||||
-e RELAYNETS=$RELAYNETS \
|
-e RELAYNETS=$RELAYNETS \
|
||||||
|
-e WHITELISTED_RECIPIENT="example-recipients.com" \
|
||||||
--network $MAILER_NETWORK \
|
--network $MAILER_NETWORK \
|
||||||
--name mailer \
|
--name mailer \
|
||||||
--restart always \
|
--restart always \
|
||||||
@ -54,3 +56,4 @@ docker network connect mailer-network name_of_other_container
|
|||||||
|
|
||||||
Now you can use the name of the mailer container, here `mailer` as smarthost name in that other container.
|
Now you can use the name of the mailer container, here `mailer` as smarthost name in that other container.
|
||||||
|
|
||||||
|
|
||||||
|
7
start.sh
7
start.sh
@ -1,9 +1,4 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
openssl genpkey -algorithm RSA -out tls.key && \
|
m4 exim.conf.m4 > exim.conf && exim -bd -q15m -v
|
||||||
openssl req -new -key tls.key -out tls.csr -subj "/C=DE/CN=$HOSTNAME" && \
|
|
||||||
openssl x509 -req -in tls.csr -signkey tls.key -out tls.crt -days 3650 && \
|
|
||||||
chown exim tls.key tls.crt && \
|
|
||||||
m4 exim.conf.m4 > exim.conf && \
|
|
||||||
exim -bd -q15m -v
|
|
||||||
|
|
||||||
|
64
tools/smtp-dialog.exp
Executable file
64
tools/smtp-dialog.exp
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
#!/usr/bin/expect
|
||||||
|
|
||||||
|
package require base64
|
||||||
|
|
||||||
|
|
||||||
|
# SMTP-Server und Port definieren
|
||||||
|
set smtp_server "localhost"
|
||||||
|
set smtp_port "25"
|
||||||
|
set timeout 25
|
||||||
|
|
||||||
|
# Absender, Empfänger und Nachricht
|
||||||
|
set sender $env(SMTP_SENDER)
|
||||||
|
set recipient "test@hottis.de"
|
||||||
|
set message "Subject: Test Email\r\n\r\nThis is a test email sent via an expect script."
|
||||||
|
|
||||||
|
set smtp_user $env(SMTP_USER)
|
||||||
|
set smtp_pass $env(SMTP_PASS)
|
||||||
|
|
||||||
|
set smtp_user_64 [base64::encode $smtp_user]
|
||||||
|
set smtp_pass_64 [base64::encode $smtp_pass]
|
||||||
|
|
||||||
|
|
||||||
|
# Verbindung herstellen
|
||||||
|
spawn nc -C $smtp_server $smtp_port
|
||||||
|
|
||||||
|
# Begrüßung vom Server erwarten
|
||||||
|
expect "220 *"
|
||||||
|
|
||||||
|
# HELO/EHLO senden
|
||||||
|
send "EHLO de01rdsi01.krohnegroup.com\n"
|
||||||
|
expect "250 *"
|
||||||
|
|
||||||
|
send "AUTH LOGIN\n"
|
||||||
|
expect "334 VXNlcm5hbWU6"
|
||||||
|
|
||||||
|
send "$smtp_user_64\n"
|
||||||
|
expect "334 UGFzc3dvcmQ6"
|
||||||
|
|
||||||
|
send "$smtp_pass_64\n"
|
||||||
|
expect "235 2.7.0 Authentication successful"
|
||||||
|
|
||||||
|
# Absender definieren
|
||||||
|
send "MAIL FROM:<$sender>\n"
|
||||||
|
expect "250 *"
|
||||||
|
|
||||||
|
# Empfänger definieren
|
||||||
|
send "RCPT TO:<$recipient>\n"
|
||||||
|
expect "250 *"
|
||||||
|
|
||||||
|
# Datenübertragung starten
|
||||||
|
send "DATA\n"
|
||||||
|
expect "354 *"
|
||||||
|
|
||||||
|
# Nachricht senden und Übertragung abschließen
|
||||||
|
send "$message\n.\n"
|
||||||
|
expect "250 *"
|
||||||
|
|
||||||
|
# Verbindung schließen
|
||||||
|
send "QUIT\n"
|
||||||
|
expect "221 *"
|
||||||
|
|
||||||
|
# Beenden
|
||||||
|
interact
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user