diff --git a/PHP8.5/DEV/tests.sh b/PHP8.5/DEV/tests.sh new file mode 100644 index 0000000..12264f6 --- /dev/null +++ b/PHP8.5/DEV/tests.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Import shared utilities. +source "$(pwd)/PHP8.5/utils.sh" + +startTests + +# Import shared tests. +source "$(pwd)/PHP8.5/common.sh" + +section "PHP extensions" +run "gd" "php -m | grep -qx 'gd'" +run "exif" "php -m | grep -qx 'exif'" +run "gettext" "php -m | grep -qx 'gettext'" +run "intl" "php -m | grep -qx 'intl'" +run "mysqli" "php -m | grep -qx 'mysqli'" +run "pdo_mysql" "php -m | grep -qx 'pdo_mysql'" +run "xsl" "php -m | grep -qx 'xsl'" +run "zip" "php -m | grep -qx 'zip'" +run "bcmath" "php -m | grep -qx 'bcmath'" +run "ldap" "php -m | grep -qx 'ldap'" +run "gmp" "php -m | grep -qx 'gmp'" +run "mbstring" "php -m | grep -qx 'mbstring'" +run "imagick" "php -m | grep -qx 'imagick'" +run "redis" "php -m | grep -qx 'redis'" +run "xdebug" "php -m | grep -qx 'xdebug'" +run "pcov" "php -m | grep -qx 'pcov'" + +section "Compiled extensions" +run "gd: imagecreate" "php -r '\$i = imagecreate(10,10); echo \$i ? \"ok\" : \"fail\";'" +run "imagick: instanciation" "php -r 'new Imagick(); echo \"ok\";'" +run "xdebug: mode configurable" "php -d xdebug.mode=off -m | grep -q xdebug" +run "pcov: driver disponible" "php -m | grep -q pcov" + +section "Apache & PHP-FPM" +run "httpd binaire present" "which httpd" +run "php-fpm binaire present" "which php-fpm" +run "httpd -v" "httpd -v" +run "php-fpm -v" "php-fpm -v" +run "module proxy_fcgi enabled" "grep -r 'proxy_fcgi' /etc/apache2/" +run "module rewrite enabled" "grep -r 'rewrite_module' /etc/apache2/" +run "module remoteip enabled" "grep -r 'remoteip_module' /etc/apache2/" +run "module headers active" "grep -r 'headers_module' /etc/apache2/" +run "vhost.conf present" "test -f /etc/apache2/conf.d/vhost.conf" +run "php-fpm.conf present" "test -f /usr/local/etc/php-fpm.d/www.conf" +run "xdebug.ini present" "test -f /usr/local/etc/php/conf.d/xdebug.ini" + +section "QA tools" +run_output "composer version" "composer --version 2>/dev/null | awk '{print \$1,\$2,\$3}'" +run_output "bun version" "bun --version" +run_output "node version" "node --version" +run_output "npm version" "npm --version" + +section "Utilities" +run "git disponible" "git --version" +run "curl disponible" "curl --version" +run "unzip disponible" "unzip -v" +run "mariadb disponible" "mysql --version" + +section "Shell" +run "zsh disponible" "which zsh" +run "oh-my-zsh installed" "test -d /root/.oh-my-zsh" +run "zsh-autosuggestions" "test -d /root/.oh-my-zsh/custom/plugins/zsh-autosuggestions" +run "SHELL=zsh" "[ \"\$SHELL\" = '/bin/zsh' ]" + +section "Paths" +run "WORKDIR = /app/srcs" "[ \"\$(pwd)\" = '/app/srcs' ]" +run "docker-entrypoint present" "test -x /usr/local/bin/docker-entrypoint.sh" + +endTests \ No newline at end of file diff --git a/PHP8.5/PROD/tests.sh b/PHP8.5/PROD/tests.sh new file mode 100644 index 0000000..3def0b1 --- /dev/null +++ b/PHP8.5/PROD/tests.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# Import shared utilities. +source "$(pwd)/PHP8.5/utils.sh" + +startTests + +# Import shared tests. +source "$(pwd)/PHP8.5/common.sh" + +section "PHP extensions" +run "bcmath" "php -m | grep -qx 'bcmath'" +run "exif" "php -m | grep -qx 'exif'" +run "gd" "php -m | grep -qx 'gd'" +run "gettext" "php -m | grep -qx 'gettext'" +run "gmp" "php -m | grep -qx 'gmp'" +run "imagick" "php -m | grep -qx 'imagick'" +run "ldap" "php -m | grep -qx 'ldap'" +run "mbstring" "php -m | grep -qx 'mbstring'" +run "memcached" "php -m | grep -qx 'memcached'" +run "mysqli" "php -m | grep -qx 'mysqli'" +run "pdo_mysql" "php -m | grep -qx 'pdo_mysql'" +run "redis" "php -m | grep -qx 'redis'" +run "xsl" "php -m | grep -qx 'xsl'" +run "zip" "php -m | grep -qx 'zip'" + +section "Compiled extensions" +run "gd: imagecreate" "php -r '\$i = imagecreate(10,10); echo \$i ? \"ok\" : \"fail\";'" +run "imagick: instanciation" "php -r 'new Imagick(); echo \"ok\";'" + +section "Check: no development tools" +run "pcov absent" "php -m | grep -qx 'pcov' && exit 1 || exit 0" +run "zsh absent" "which zsh 2>/dev/null && exit 1 || exit 0" +run "bun absent" "which bun 2>/dev/null && exit 1 || exit 0" +run "xdebug absent" "php -m | grep -qx 'xdebug' && exit 1 || exit 0" +run "xdebug.ini absent" "test ! -f /usr/local/etc/php/conf.d/xdebug.ini" + +section "Apache & PHP-FPM" +run "httpd binaire present" "which httpd" +run "php-fpm binaire present" "which php-fpm" +run "httpd -v" "httpd -v" +run "php-fpm -v" "php-fpm -v" +run "module proxy_fcgi enabled" "grep -r 'proxy_fcgi' /etc/apache2/" +run "module rewrite enabled" "grep -r 'rewrite_module' /etc/apache2/" +run "module remoteip enabled" "grep -r 'remoteip_module' /etc/apache2/" +run "module headers enabled" "grep -r 'headers_module' /etc/apache2/" +run "vhost.conf present" "test -f /etc/apache2/conf.d/vhost.conf" +run "php-fpm.conf present" "test -f /usr/local/etc/php-fpm.d/www.conf" +run "ssl.conf absent" "test ! -f /etc/apache2/conf.d/ssl.conf" + +section "QA tools" +run_output "composer version" "composer --version 2>/dev/null | awk '{print \$1,\$2,\$3}'" + +section "Utilities" +run "git disponible" "git --version" +run "curl disponible" "curl --version" +run "unzip disponible" "unzip -v" +run "mariadb disponible" "mysql --version" + +section "Paths" +run "WORKDIR = /app/srcs" "[ \"\$(pwd)\" = '/app/srcs' ]" +run "docker-entrypoint present" "test -x /usr/local/bin/docker-entrypoint.sh" + +endTests \ No newline at end of file diff --git a/PHP8.5/QA/tests.sh b/PHP8.5/QA/tests.sh new file mode 100644 index 0000000..ab8c51f --- /dev/null +++ b/PHP8.5/QA/tests.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash + +# Import shared utilities. +source "$(pwd)/PHP8.5/utils.sh" + +startTests + +# Import shared tests. +source "$(pwd)/PHP8.5/common.sh" + +section "PHP extensions" +run "bcmath" "php -m | grep -qx 'bcmath'" +run "exif" "php -m | grep -qx 'exif'" +run "gd" "php -m | grep -qx 'gd'" +run "gettext" "php -m | grep -qx 'gettext'" +run "gmp" "php -m | grep -qx 'gmp'" +run "imagick" "php -m | grep -qx 'imagick'" +run "intl" "php -m | grep -qx 'intl'" +run "ldap" "php -m | grep -qx 'ldap'" +run "mbstring" "php -m | grep -qx 'mbstring'" +run "memcached" "php -m | grep -qx 'memcached'" +run "mysqli" "php -m | grep -qx 'mysqli'" +run "pcov" "php -m | grep -qx 'pcov'" +run "pdo_mysql" "php -m | grep -qx 'pdo_mysql'" +run "xsl" "php -m | grep -qx 'xsl'" +run "zip" "php -m | grep -qx 'zip'" + +section "Compiled extensions" +run "gd: imagecreate" "php -r '\$i = imagecreate(10,10); echo \$i ? \"ok\" : \"fail\";'" +run "imagick: instanciation" "php -r 'new Imagick(); echo \"ok\";'" +run "pcov: driver" "php -d pcov.enabled=1 -r 'echo pcov\\\\Collector::start() ? \"ok\" : \"ok\";' 2>/dev/null || true; php -m | grep -q pcov" + +section "QA tools" +run "local-php-security-checker present" "local-php-security-checker -help 2>&1 | grep -qi 'version'" +run_output "composer version" "composer --version 2>/dev/null | awk '{print \$1,\$2,\$3}'" +run_output "audit-ci version" "audit-ci --version 2>/dev/null || npx audit-ci --version 2>/dev/null" +run_output "node version" "node --version" +run_output "npm version" "npm --version" + +section "Utilities" +run "git disponible" "git --version" +run "curl disponible" "curl --version" +run "unzip disponible" "unzip -v" + +section "Paths" +run "WORKDIR = /project" "[ \"\$(pwd)\" = '/project' ]" +run "/tools dans le PATH" "echo \$PATH | grep -q '/tools'" +run "composer dans le PATH" "which composer" +run "audit-ci dans le PATH" "which audit-ci" +run "security-checker dans PATH" "which local-php-security-checker" + +endTests \ No newline at end of file diff --git a/PHP8.5/common.sh b/PHP8.5/common.sh new file mode 100644 index 0000000..d6272d9 --- /dev/null +++ b/PHP8.5/common.sh @@ -0,0 +1,10 @@ +section "PHP version" +run_output "php -v" "php -r 'echo PHP_VERSION;'" +run "php -l (lint)" "php -r 'echo 42;'" +run "php.ini loaded" "php -i | grep -q 'Loaded Configuration'" +run "app.ini loaded" "php -i | grep -q 'app.ini\|/usr/local/etc/php/conf.d/app.ini'" + +section "Locales" +run "LC_ALL=fr_FR.UTF-8" "[ \"\$LC_ALL\" = 'fr_FR.UTF-8' ]" +run "LANG=fr_FR.UTF-8" "[ \"\$LANG\" = 'fr_FR.UTF-8' ]" +run "locale fr_FR disponible" "locale -a 2>/dev/null | grep -qi 'fr_FR'" \ No newline at end of file diff --git a/PHP8.5/utils.sh b/PHP8.5/utils.sh new file mode 100644 index 0000000..f4a0868 --- /dev/null +++ b/PHP8.5/utils.sh @@ -0,0 +1,83 @@ +# Variables +IMAGE="${1:-image-name:latest}" +PASS=0 +FAIL=0 +ERRORS=() +GREEN='\033[0;32m' +RED='\033[0;31m' +YELLOW='\033[1;33m' +CYAN='\033[0;36m' +NC='\033[0m' + +# Functions to test element in target image. + +## run