From 28796b98d10297aa5c177bf31f1604b1ef706bdd Mon Sep 17 00:00:00 2001 From: Jose Antonio Carmona Date: Tue, 14 Feb 2023 12:31:12 +0100 Subject: [PATCH] [bitnami/apache] Add VIB tests (#23837) * [bitnami/apache] Add VIB tests Signed-off-by: Jose Antonio Carmona * Remove VIB trigger Signed-off-by: Jose Antonio Carmona --------- Signed-off-by: Jose Antonio Carmona --- .vib/apache/goss/apache.yaml | 49 ++++++++++++++++++++++++++++++++++++ .vib/apache/goss/goss.yaml | 12 +++++++++ .vib/apache/goss/vars.yaml | 49 ++++++++++++++++++++++++++++++++++++ .vib/apache/vib-publish.json | 16 +++++++++++- .vib/apache/vib-verify.json | 16 +++++++++++- 5 files changed, 140 insertions(+), 2 deletions(-) create mode 100644 .vib/apache/goss/apache.yaml create mode 100644 .vib/apache/goss/goss.yaml create mode 100644 .vib/apache/goss/vars.yaml diff --git a/.vib/apache/goss/apache.yaml b/.vib/apache/goss/apache.yaml new file mode 100644 index 000000000000..853a110b0b36 --- /dev/null +++ b/.vib/apache/goss/apache.yaml @@ -0,0 +1,49 @@ +file: + # Main Apache config file includes other config files + {{ .Vars.root_dir }}/apache/conf/httpd.conf: + exists: true + filetype: file + contains: + - /^Include.*{{ .Vars.root_dir }}/apache/conf/bitnami/bitnami.conf/ + - /^Include.*{{ .Vars.root_dir }}/apache/conf/vhosts/\*.conf/ + - /^Include.*{{ .Vars.root_dir }}/apache/conf/deflate.conf/ + # Main Bitnami config file was correctly generated + {{ .Vars.root_dir }}/apache/conf/bitnami/bitnami.conf: + exists: true + filetype: file + contains: + - /DocumentRoot.*{{ .Vars.root_dir }}/apache/htdocs/ + - /^Include.*{{ .Vars.root_dir }}/apache/conf/bitnami/bitnami-ssl.conf/ + # Main Bitnami ssl config file was correctly generated + {{ .Vars.root_dir }}/apache/conf/bitnami/bitnami-ssl.conf: + exists: true + filetype: file + contains: + - "SSLProtocol all -SSLv2 -SSLv3" + - /SSLCertificateFile.*bitnami/certs/server.crt/ + - /SSLCertificateKeyFile.*bitnami/certs/server.key/ + # CGI folder has been removed, as recommended by Apache + {{ .Vars.root_dir }}/apache/cgi-bin: + exists: false + # Compiled disabled modules should have been generated + {{ range $module := .Vars.modules.extra }} + {{ $.Vars.root_dir }}/apache/modules/mod_{{ $module }}.so: + exists: true + filetype: file + {{ end }} +command: + # There are no syntax error in the configuration + check-configuration: + exec: apachectl -t + exit-status: 0 + # Check explicitly enabled and disabled modules + check-loaded-modules: + exec: apachectl -M + exit-status: 0 + stdout: + {{ range $module := .Vars.modules.loaded }} + - "{{ $module }}_module" + {{ end }} + {{ range $module := .Vars.modules.disabled }} + - "!{{ $module }}_module" + {{ end }} diff --git a/.vib/apache/goss/goss.yaml b/.vib/apache/goss/goss.yaml new file mode 100644 index 000000000000..7497d0914bfb --- /dev/null +++ b/.vib/apache/goss/goss.yaml @@ -0,0 +1,12 @@ +gossfile: + # Goss tests exclusive to the current container + ../../apache/goss/apache.yaml: {} + # Load scripts from .vib/common/goss/templates + ../../common/goss/templates/check-app-version.yaml: {} + ../../common/goss/templates/check-broken-symlinks.yaml: {} + ../../common/goss/templates/check-ca-certs.yaml: {} + ../../common/goss/templates/check-components-binaries.yaml: {} + ../../common/goss/templates/check-components-files.yaml: {} + ../../common/goss/templates/check-directories-permissions.yaml: {} + ../../common/goss/templates/check-linked-libraries.yaml: {} + ../../common/goss/templates/check-sed-in-place.yaml: {} \ No newline at end of file diff --git a/.vib/apache/goss/vars.yaml b/.vib/apache/goss/vars.yaml new file mode 100644 index 000000000000..36d70f7b61a4 --- /dev/null +++ b/.vib/apache/goss/vars.yaml @@ -0,0 +1,49 @@ +components: + binaries: + - httpd + - gosu + - render-template + files: + - /opt/bitnami/apache/conf/modsecurity.conf + - /opt/bitnami/apache/conf/unicode.mapping +filesystem: + - mode: "0775" + directories: + - /opt/bitnami/apache/var/run + - /opt/bitnami/apache/conf + - /opt/bitnami/apache/logs + - /opt/bitnami/apache/conf/vhosts + - /opt/bitnami/apache/conf/vhosts/htaccess + - /opt/bitnami/apache/htdocs +modules: + loaded: + # Explicitly enabled in postunpack + - deflate + - negotiation + - proxy + - proxy_http + - rewrite + - slotmem_shm + - socache_shmcb + - ssl + - status + - version + # Explicitly set at compilation time + - mpm_prefork + disabled: + # Explicitly disabled in postunpack + - http2 + - proxy_hcheck + extra: + # Not enabled, but compiled + - mpm_event + - mpm_prefork + - mpm_worker + - http2 + - ldap + - authnz_ldap + - security3 +root_dir: /opt/bitnami +version: + bin_name: apachectl + flag: -v \ No newline at end of file diff --git a/.vib/apache/vib-publish.json b/.vib/apache/vib-publish.json index f58738648055..89c18922de97 100644 --- a/.vib/apache/vib-publish.json +++ b/.vib/apache/vib-publish.json @@ -3,7 +3,8 @@ "resources": { "url": "{VIB_ENV_CONTAINER_URL}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -33,6 +34,19 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "apache/goss/goss.yaml", + "vars_file": "apache/goss/vars.yaml", + "remote": { + "workload": "deploy-apache" + } + } + }, { "action_id": "trivy", "params": { diff --git a/.vib/apache/vib-verify.json b/.vib/apache/vib-verify.json index 835cd556e241..416f14febd23 100644 --- a/.vib/apache/vib-verify.json +++ b/.vib/apache/vib-verify.json @@ -3,7 +3,8 @@ "resources": { "url": "{SHA_ARCHIVE}", "path": "{VIB_ENV_PATH}" - } + }, + "runtime_parameters": "Y29tbWFuZDogWyJ0YWlsIiwgIi1mIiwgIi9kZXYvbnVsbCJd" }, "phases": { "package": { @@ -29,6 +30,19 @@ }, "verify": { "actions": [ + { + "action_id": "goss", + "params": { + "resources": { + "path": "/.vib" + }, + "tests_file": "apache/goss/goss.yaml", + "vars_file": "apache/goss/vars.yaml", + "remote": { + "workload": "deploy-apache" + } + } + }, { "action_id": "trivy", "params": {