2828pass () { print -- " PASS $* " ; }
2929fail () { print -- " FAIL $* " ; FAIL=1; }
3030
31+ TLS12_AEAD_CIPHERS=' ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256'
32+
3133check_file () {
3234 _file=" $1 "
3335 _label=" $2 "
@@ -53,6 +55,21 @@ check_regex() {
5355 fi
5456}
5557
58+ check_no_regex () {
59+ _file=" $1 "
60+ _regex=" $2 "
61+ _label=" $3 "
62+ if [ ! -f " ${_file} " ]; then
63+ fail " ${_label} missing: ${_file} "
64+ return 0
65+ fi
66+ if grep -Eiq " ${_regex} " " ${_file} " ; then
67+ fail " ${_label} forbidden pattern found in ${_file} "
68+ else
69+ pass " ${_label} "
70+ fi
71+ }
72+
5673check_no_upper_placeholders () {
5774 _file=" $1 "
5875 _label=" $2 "
@@ -67,6 +84,16 @@ check_no_upper_placeholders() {
6784 fi
6885}
6986
87+ check_nginx_tls_policy () {
88+ _root=" $1 "
89+ _label=" $2 "
90+ _ssl_template=" ${_root} /etc/nginx/templates/ssl.tmpl"
91+
92+ check_regex " ${_ssl_template} " ' ^ssl_protocols TLSv1\.2 TLSv1\.3;$' " ${_label} nginx TLS protocols limited to TLS 1.2 and TLS 1.3"
93+ check_regex " ${_ssl_template} " " ^ssl_ciphers ${TLS12_AEAD_CIPHERS} ;$" " ${_label} nginx TLS 1.2 ciphers are explicit AEAD-only suites"
94+ check_no_regex " ${_ssl_template} " ' (^|[^A-Z0-9])CBC([^A-Z0-9]|$)|AES[0-9]*-SHA($|:)|AES256\+EECDH|EECDH\+AES|EDH\+AES' " ${_label} nginx TLS template has no CBC-capable broad cipher tokens"
95+ }
96+
7097check_mail_root () {
7198 _root=" $1 "
7299 _label=" $2 "
@@ -81,6 +108,7 @@ check_mail_root() {
81108 check_regex " ${_root} /etc/dovecot/dovecot.conf" ' protocols *= *imap lmtp' " ${_label} dovecot protocol set"
82109 check_regex " ${_root} /etc/dovecot/local.conf" ' mail_location *= *maildir:' " ${_label} dovecot maildir location"
83110 check_regex " ${_root} /etc/nginx/sites-available/main-ssl.conf" ' include /etc/nginx/templates/ssl\.tmpl;' " ${_label} nginx ssl template include"
111+ check_nginx_tls_policy " ${_root} " " ${_label} "
84112 check_regex " ${_root} /etc/rspamd/local.d/worker-proxy.inc" ' milter *= *yes;' " ${_label} rspamd proxy milter enabled"
85113 check_regex " ${_root} /etc/rspamd/local.d/worker-controller.inc" ' bind_socket *= *"' " ${_label} rspamd controller bind configured"
86114 check_regex " ${_root} /var/www/postfixadmin/config.local.php" " \$ CONF\['configured'\] = true;" " ${_label} postfixadmin configured flag"
0 commit comments