diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 7e5e4001b..288233862 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -21,11 +21,11 @@ jobs: - name: Checkout repository uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Initialize CodeQL - uses: github/codeql-action/init@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4 + uses: github/codeql-action/init@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5 with: languages: ${{ matrix.language }} config-file: ./.github/codeql.yml - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4 + uses: github/codeql-action/analyze@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5 with: category: "/language:${{matrix.language}}" diff --git a/.github/workflows/push-packagecloud.yml b/.github/workflows/push-packagecloud.yml index 475cabd9f..05fba2235 100644 --- a/.github/workflows/push-packagecloud.yml +++ b/.github/workflows/push-packagecloud.yml @@ -42,7 +42,7 @@ jobs: - name: Check out repository code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Install ruby - uses: ruby/setup-ruby@cd48c8e22733480b66887b42bfeb6c0b88ea1a56 # v1.158.0 + uses: ruby/setup-ruby@54a18e26dbbb1eabc604f317ade9a5788dddef81 # v1.159.0 with: ruby-version: "3.0" - name: Install packagecloud diff --git a/.github/workflows/scorecards-analysis.yml b/.github/workflows/scorecards-analysis.yml index a0f2c8eac..edf02f1cf 100644 --- a/.github/workflows/scorecards-analysis.yml +++ b/.github/workflows/scorecards-analysis.yml @@ -25,6 +25,6 @@ jobs: results_format: sarif publish_results: true - name: "Upload SARIF results to code scanning" - uses: github/codeql-action/upload-sarif@49abf0ba24d0b7953cb586944e918a0b92074c80 # v2.22.4 + uses: github/codeql-action/upload-sarif@74483a38d39275f33fcff5f35b679b5ca4a26a99 # v2.22.5 with: sarif_file: results.sarif diff --git a/.github/workflows/test-core-linux.yml b/.github/workflows/test-core-linux.yml index 6057bcc61..aede07ee6 100644 --- a/.github/workflows/test-core-linux.yml +++ b/.github/workflows/test-core-linux.yml @@ -81,6 +81,7 @@ jobs: echo "HTTP_PORT=80" | sudo tee -a /etc/bunkerweb/variables.env echo "HTTPS_PORT=443" | sudo tee -a /etc/bunkerweb/variables.env echo 'DNS_RESOLVERS=9.9.9.9 8.8.8.8 8.8.4.4' | sudo tee -a /etc/bunkerweb/variables.env + echo 'API_LISTEN_IP=127.0.0.1' | sudo tee -a /etc/bunkerweb/variables.env echo "USE_BUNKERNET=no" | sudo tee -a /etc/bunkerweb/variables.env echo "USE_BLACKLIST=no" | sudo tee -a /etc/bunkerweb/variables.env echo "LOG_LEVEL=info" | sudo tee -a /etc/bunkerweb/variables.env diff --git a/.github/workflows/tests-ui-linux.yml b/.github/workflows/tests-ui-linux.yml index 67306c7ce..3dfb42d67 100644 --- a/.github/workflows/tests-ui-linux.yml +++ b/.github/workflows/tests-ui-linux.yml @@ -75,6 +75,7 @@ jobs: echo "HTTP_PORT=80" | sudo tee -a /etc/bunkerweb/variables.env echo "HTTPS_PORT=443" | sudo tee -a /etc/bunkerweb/variables.env echo 'DNS_RESOLVERS=9.9.9.9 8.8.8.8 8.8.4.4' | sudo tee -a /etc/bunkerweb/variables.env + echo 'API_LISTEN_IP=127.0.0.1' | sudo tee -a /etc/bunkerweb/variables.env echo "MULTISITE=yes" | sudo tee -a /etc/bunkerweb/variables.env echo "LOG_LEVEL=info" | sudo tee -a /etc/bunkerweb/variables.env echo "USE_BUNKERNET=no" | sudo tee -a /etc/bunkerweb/variables.env diff --git a/docs/quickstart-guide.md b/docs/quickstart-guide.md index 06b0695da..5fe1d95cf 100644 --- a/docs/quickstart-guide.md +++ b/docs/quickstart-guide.md @@ -228,6 +228,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 SERVER_NAME=www.example.com USE_REVERSE_PROXY=yes REVERSE_PROXY_URL=/ @@ -268,6 +269,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 SERVER_NAME=www.example.com USE_REVERSE_PROXY=yes REVERSE_PROXY_URL=/ @@ -323,6 +325,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 USE_REVERSE_PROXY=yes REVERSE_PROXY_URL=/ REVERSE_PROXY_HOST=http://127.0.0.1:8000 @@ -658,6 +661,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com USE_REVERSE_PROXY=yes @@ -701,6 +705,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com USE_REVERSE_PROXY=yes @@ -756,6 +761,7 @@ You will find more settings about reverse proxy in the [settings section](settin HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com USE_REVERSE_PROXY=yes @@ -2199,6 +2205,7 @@ BunkerWeb supports PHP using external or remote [PHP-FPM](https://www.php.net/ma HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com app1.example.com_LOCAL_PHP=/run/php/php-fpm.sock @@ -2240,6 +2247,7 @@ BunkerWeb supports PHP using external or remote [PHP-FPM](https://www.php.net/ma HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com app1.example.com_LOCAL_PHP=/run/php/php-fpm.sock @@ -2289,6 +2297,7 @@ BunkerWeb supports PHP using external or remote [PHP-FPM](https://www.php.net/ma HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 MULTISITE=yes SERVER_NAME=app1.example.com app2.example.com app3.example.com app1.example.com_LOCAL_PHP=/run/php/php-fpm.sock diff --git a/docs/requirements.in b/docs/requirements.in index fc7c778fb..8facc0fcb 100644 --- a/docs/requirements.in +++ b/docs/requirements.in @@ -1,5 +1,5 @@ mike==1.1.2 mkdocs==1.5.3 -mkdocs-material==9.4.6 +mkdocs-material==9.4.7 mkdocs-print-site-plugin==2.3.6 pytablewriter==1.2.0 diff --git a/docs/requirements.txt b/docs/requirements.txt index baf77600a..24d343411 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -236,9 +236,9 @@ mkdocs==1.5.3 \ # -r requirements.in # mike # mkdocs-material -mkdocs-material==9.4.6 \ - --hash=sha256:09665e60df7ee9e5ff3a54af173f6d45be718b1ee7dd962bcff3102b81fb0c14 \ - --hash=sha256:78802035d5768a78139c84ad7dce0c6493e8f7dc4861727d36ed91d1520a54da +mkdocs-material==9.4.7 \ + --hash=sha256:4d698d52bb6a6a3c452ab854481c4cdb68453a0420956a6aee2de55fe15fe610 \ + --hash=sha256:e704e001c9ef17291e1d3462c202425217601653e18f68f85d28eff4690e662b # via # -r requirements.in # mkdocs-print-site-plugin diff --git a/docs/web-ui.md b/docs/web-ui.md index c3693e1f9..22d80120c 100644 --- a/docs/web-ui.md +++ b/docs/web-ui.md @@ -823,10 +823,10 @@ Because the web UI is a web application, the recommended installation procedure Here is the `/etc/bunkerweb/variables.env` boilerplate you can use : ```conf - API_LISTEN_IP=127.0.0.1 HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 SERVER_NAME=www.example.com MULTISITE=yes www.example.com_USE_UI=yes @@ -859,6 +859,7 @@ Because the web UI is a web application, the recommended installation procedure HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 SERVER_NAME=www.example.com MULTISITE=yes www.example.com_USE_UI=yes @@ -932,6 +933,7 @@ Because the web UI is a web application, the recommended installation procedure HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 + API_LISTEN_IP=127.0.0.1 SERVER_NAME=www.example.com MULTISITE=yes www.example.com_USE_UI=yes diff --git a/examples/authelia/variables.env b/examples/authelia/variables.env index 04c39eb9c..e2d99cfa1 100644 --- a/examples/authelia/variables.env +++ b/examples/authelia/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 MULTISITE=yes # Replace with your domains SERVER_NAME=auth.example.com app1.example.com app2.example.com diff --git a/examples/behind-reverse-proxy/variables.env b/examples/behind-reverse-proxy/variables.env index a7ae9b030..a57397566 100644 --- a/examples/behind-reverse-proxy/variables.env +++ b/examples/behind-reverse-proxy/variables.env @@ -1,4 +1,5 @@ DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # replace with your domains SERVER_NAME=www.example.com # real IP settings diff --git a/examples/cors/variables.env b/examples/cors/variables.env index db25d7dce..727676fcd 100644 --- a/examples/cors/variables.env +++ b/examples/cors/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 MULTISITE=yes # Replace with your domains SERVER_NAME=app1.example.com app2.example.com app3.example.com diff --git a/examples/drupal/variables.env b/examples/drupal/variables.env index e2ad80145..cd89e8989 100644 --- a/examples/drupal/variables.env +++ b/examples/drupal/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/joomla/variables.env b/examples/joomla/variables.env index bad26da37..bc6fac93b 100644 --- a/examples/joomla/variables.env +++ b/examples/joomla/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/moodle/variables.env b/examples/moodle/variables.env index 145418bc2..dd3ee50d1 100644 --- a/examples/moodle/variables.env +++ b/examples/moodle/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/nextcloud/variables.env b/examples/nextcloud/variables.env index 8a0f79b85..1614f461c 100644 --- a/examples/nextcloud/variables.env +++ b/examples/nextcloud/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/php-cookie-flags/variables.env b/examples/php-cookie-flags/variables.env index 8b2933069..daa345761 100644 --- a/examples/php-cookie-flags/variables.env +++ b/examples/php-cookie-flags/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/php-multisite/variables.env b/examples/php-multisite/variables.env index 424c318f7..84787578f 100644 --- a/examples/php-multisite/variables.env +++ b/examples/php-multisite/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=app1.example.com app2.example.com MULTISITE=yes diff --git a/examples/php-singlesite/variables.env b/examples/php-singlesite/variables.env index 53d9f8acc..6adc19edd 100644 --- a/examples/php-singlesite/variables.env +++ b/examples/php-singlesite/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/examples/proxy-protocol/variables.env b/examples/proxy-protocol/variables.env index fb0bd805d..3cfa19c28 100644 --- a/examples/proxy-protocol/variables.env +++ b/examples/proxy-protocol/variables.env @@ -1,4 +1,5 @@ DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # replace with your domains SERVER_NAME=www.example.com # real IP settings diff --git a/examples/wordpress/variables.env b/examples/wordpress/variables.env index ebfc913e0..6fd16b612 100644 --- a/examples/wordpress/variables.env +++ b/examples/wordpress/variables.env @@ -1,6 +1,7 @@ HTTP_PORT=80 HTTPS_PORT=443 DNS_RESOLVERS=8.8.8.8 8.8.4.4 +API_LISTEN_IP=127.0.0.1 # Replace with your domain SERVER_NAME=www.example.com DISABLE_DEFAULT_SERVER=yes diff --git a/src/common/confs/api.conf b/src/common/confs/api.conf index bb7a8a881..80b60a0ef 100644 --- a/src/common/confs/api.conf +++ b/src/common/confs/api.conf @@ -2,9 +2,9 @@ server { server_name {{ API_SERVER_NAME }}; # HTTP listen - listen {{ API_LISTEN_IP }}:{{ API_HTTP_PORT }}; + listen {{ API_LISTEN_IP }}:{{ API_HTTP_PORT }} reuseport; {% if API_LISTEN_IP != "127.0.0.1" +%} - listen 127.0.0.1:{{ API_HTTP_PORT }}; + listen 127.0.0.1:{{ API_HTTP_PORT }} reuseport; {% endif %} # maximum body size for API diff --git a/src/common/core/letsencrypt/jobs/certbot-deploy.py b/src/common/core/letsencrypt/jobs/certbot-deploy.py index 2b436b08e..12ad34608 100755 --- a/src/common/core/letsencrypt/jobs/certbot-deploy.py +++ b/src/common/core/letsencrypt/jobs/certbot-deploy.py @@ -97,7 +97,7 @@ try: else: if ( run( - ["sudo", join(sep, "usr", "sbin", "nginx"), "-s", "reload"], + [join(sep, "usr", "sbin", "nginx"), "-s", "reload"], stdin=DEVNULL, stderr=STDOUT, check=False, diff --git a/src/common/db/requirements.txt b/src/common/db/requirements.txt index c82d60002..3ded44a65 100644 --- a/src/common/db/requirements.txt +++ b/src/common/db/requirements.txt @@ -170,6 +170,7 @@ psycopg2-binary==2.9.9 \ --hash=sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291 \ --hash=sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe \ --hash=sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980 \ + --hash=sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93 \ --hash=sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692 \ --hash=sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119 \ --hash=sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716 \ @@ -179,6 +180,7 @@ psycopg2-binary==2.9.9 \ --hash=sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc \ --hash=sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c \ --hash=sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5 \ + --hash=sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab \ --hash=sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984 \ --hash=sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9 \ --hash=sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf \ diff --git a/src/common/gen/main.py b/src/common/gen/main.py index 27d16f236..35d724120 100644 --- a/src/common/gen/main.py +++ b/src/common/gen/main.py @@ -194,7 +194,7 @@ if __name__ == "__main__": sleep(5) proc = run( - ["sudo", join(sep, "usr", "sbin", "nginx"), "-s", "reload"], + [join(sep, "usr", "sbin", "nginx"), "-s", "reload"], stdin=DEVNULL, stderr=STDOUT, ) diff --git a/src/common/gen/requirements.in b/src/common/gen/requirements.in index ae4cd255e..fb3bf36d4 100644 --- a/src/common/gen/requirements.in +++ b/src/common/gen/requirements.in @@ -3,4 +3,4 @@ jinja2==3.1.2 kubernetes==28.1.0 python-dotenv==1.0.0 redis==5.0.1 -urllib3==1.26.18 +urllib3<2.0.0 diff --git a/src/deps/requirements-deps.in b/src/deps/requirements-deps.in index 15e6cc47e..24e91e95d 100644 --- a/src/deps/requirements-deps.in +++ b/src/deps/requirements-deps.in @@ -4,4 +4,4 @@ pip-tools==7.3.0 pip-upgrader==1.4.15 setuptools==68.2.2 tomli==2.0.1 -wheel==0.41.2 +wheel==0.41.3 diff --git a/src/deps/requirements-deps.txt b/src/deps/requirements-deps.txt index 6fcd7745c..a4f180e65 100644 --- a/src/deps/requirements-deps.txt +++ b/src/deps/requirements-deps.txt @@ -185,9 +185,9 @@ urllib3==2.0.7 \ --hash=sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84 \ --hash=sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e # via requests -wheel==0.41.2 \ - --hash=sha256:0c5ac5ff2afb79ac23ab82bab027a0be7b5dbcf2e54dc50efe4bf507de1f7985 \ - --hash=sha256:75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8 +wheel==0.41.3 \ + --hash=sha256:488609bc63a29322326e05560731bf7bfea8e48ad646e1f5e40d366607de0942 \ + --hash=sha256:4d4987ce51a49370ea65c0bfd2234e8ce80a12780820d9dc462597a6e60d0841 # via # -r requirements-deps.in # pip-tools diff --git a/src/deps/requirements.in b/src/deps/requirements.in index 64a070cde..d0c7f5273 100644 --- a/src/deps/requirements.in +++ b/src/deps/requirements.in @@ -1,4 +1,4 @@ pip==23.3.1 pip-tools==7.3.0 setuptools==68.2.2 -wheel==0.41.2 +wheel==0.41.3 diff --git a/src/deps/requirements.txt b/src/deps/requirements.txt index 8c33f4daa..870ab833f 100644 --- a/src/deps/requirements.txt +++ b/src/deps/requirements.txt @@ -47,9 +47,9 @@ tomli==2.0.1 \ # build # pip-tools # pyproject-hooks -wheel==0.41.2 \ - --hash=sha256:0c5ac5ff2afb79ac23ab82bab027a0be7b5dbcf2e54dc50efe4bf507de1f7985 \ - --hash=sha256:75909db2664838d015e3d9139004ee16711748a52c8f336b52882266540215d8 +wheel==0.41.3 \ + --hash=sha256:488609bc63a29322326e05560731bf7bfea8e48ad646e1f5e40d366607de0942 \ + --hash=sha256:4d4987ce51a49370ea65c0bfd2234e8ce80a12780820d9dc462597a6e60d0841 # via # -r requirements.in # pip-tools diff --git a/src/linux/scripts/postinstall.sh b/src/linux/scripts/postinstall.sh index 4342dfb79..7577f9612 100644 --- a/src/linux/scripts/postinstall.sh +++ b/src/linux/scripts/postinstall.sh @@ -21,8 +21,8 @@ do_and_check_cmd chown -R nginx:nginx /usr/share/bunkerweb /var/cache/bunkerweb # Stop and disable nginx on boot echo "Stop and disable nginx on boot..." -do_and_check_cmd systemctl stop bunkerweb -do_and_check_cmd systemctl disable bunkerweb +do_and_check_cmd systemctl stop nginx +do_and_check_cmd systemctl disable nginx # Auto start BW service on boot and start it now echo "Enabling and starting bunkerweb service..." diff --git a/src/linux/scripts/start.sh b/src/linux/scripts/start.sh index da88ebbd3..a002a8107 100644 --- a/src/linux/scripts/start.sh +++ b/src/linux/scripts/start.sh @@ -96,7 +96,7 @@ function start() { # Create dummy variables.env if [ ! -f /etc/bunkerweb/variables.env ]; then - sudo -E -u nginx -g nginx /bin/bash -c "echo -ne '# remove IS_LOADING=yes when your config is ready\nIS_LOADING=yes\nUSE_BUNKERNET=no\nDNS_RESOLVERS=8.8.8.8 8.8.4.4\nHTTP_PORT=80\nHTTPS_PORT=443\nAPI_LISTEN_IP=127.0.0.1\nSERVER_NAME=\n' > /etc/bunkerweb/variables.env" + sudo -E -u nginx -g nginx /bin/bash -c "echo -ne '# remove IS_LOADING=yes when your config is ready\nIS_LOADING=yes\nDNS_RESOLVERS=8.8.8.8 8.8.4.4\nHTTP_PORT=80\nHTTPS_PORT=443\nAPI_LISTEN_IP=127.0.0.1\nSERVER_NAME=\n' > /etc/bunkerweb/variables.env" log "SYSTEMCTL" "ℹ️" "Created dummy variables.env file" fi @@ -111,6 +111,10 @@ function start() { if [ "$DNS_RESOLVERS" = "" ] ; then DNS_RESOLVERS="8.8.8.8 8.8.4.4" fi + API_LISTEN_IP="$(grep "^API_LISTEN_IP=" /etc/bunkerweb/variables.env | cut -d '=' -f 2)" + if [ "$API_LISTEN_IP" = "" ] ; then + API_LISTEN_IP="127.0.0.1" + fi API_HTTP_PORT="$(grep "^API_HTTP_PORT=" /etc/bunkerweb/variables.env | cut -d '=' -f 2)" if [ "$API_HTTP_PORT" = "" ] ; then API_HTTP_PORT="5000" @@ -147,7 +151,7 @@ function start() { if [ "$HTTPS_PORT" = "" ] ; then HTTPS_PORT="443" fi - sudo -E -u nginx -g nginx /bin/bash -c "echo -ne 'IS_LOADING=yes\nUSE_BUNKERNET=no\nSERVER_NAME=\nDNS_RESOLVERS=${DNS_RESOLVERS}\nAPI_HTTP_PORT=${API_HTTP_PORT}\nAPI_SERVER_NAME=${API_SERVER_NAME}\nAPI_WHITELIST_IP=${API_WHITELIST_IP}\nUSE_REAL_IP=${USE_REAL_IP}\nUSE_PROXY_PROTOCOL=${USE_PROXY_PROTOCOL}\nREAL_IP_FROM=${REAL_IP_FROM}\nREAL_IP_HEADER=${REAL_IP_HEADER}\nHTTP_PORT=${HTTP_PORT}\nHTTPS_PORT=${HTTPS_PORT}\n' > /var/tmp/bunkerweb/tmp.env" + sudo -E -u nginx -g nginx /bin/bash -c "echo -ne 'IS_LOADING=yes\nUSE_BUNKERNET=no\nSERVER_NAME=\nDNS_RESOLVERS=${DNS_RESOLVERS}\nAPI_HTTP_PORT=${API_HTTP_PORT}\nAPI_LISTEN_IP=${API_LISTEN_IP}\nAPI_SERVER_NAME=${API_SERVER_NAME}\nAPI_WHITELIST_IP=${API_WHITELIST_IP}\nUSE_REAL_IP=${USE_REAL_IP}\nUSE_PROXY_PROTOCOL=${USE_PROXY_PROTOCOL}\nREAL_IP_FROM=${REAL_IP_FROM}\nREAL_IP_HEADER=${REAL_IP_HEADER}\nHTTP_PORT=${HTTP_PORT}\nHTTPS_PORT=${HTTPS_PORT}\n' > /var/tmp/bunkerweb/tmp.env" sudo -E -u nginx -g nginx /bin/bash -c "PYTHONPATH=/usr/share/bunkerweb/deps/python/ /usr/share/bunkerweb/gen/main.py --variables /var/tmp/bunkerweb/tmp.env --no-linux-reload" # shellcheck disable=SC2181 if [ $? -ne 0 ] ; then diff --git a/src/scheduler/main.py b/src/scheduler/main.py index 693d1e6fa..485047bd8 100644 --- a/src/scheduler/main.py +++ b/src/scheduler/main.py @@ -21,7 +21,7 @@ from pathlib import Path from shutil import copy, rmtree from signal import SIGINT, SIGTERM, signal, SIGHUP from stat import S_IEXEC -from subprocess import run as subprocess_run, DEVNULL, STDOUT +from subprocess import run as subprocess_run, DEVNULL, STDOUT, PIPE from sys import path as sys_path from tarfile import open as tar_open from threading import Thread @@ -524,46 +524,62 @@ if __name__ == "__main__": else: logger.error("Error while reloading nginx") else: - # Stop temp nginx - logger.info("Stopping temp nginx ...") + # Reload nginx + logger.info("Reloading nginx ...") proc = subprocess_run( - [join(sep, "usr", "sbin", "nginx"), "-s", "stop"], + [join(sep, "usr", "sbin", "nginx"), "-s", "reload"], stdin=DEVNULL, stderr=STDOUT, env=env.copy(), check=False, + stdout=PIPE ) if proc.returncode == 0: - logger.info("Successfully sent stop signal to temp nginx") - i = 0 - while i < 20: - if not Path(sep, "var", "run", "bunkerweb", "nginx.pid").is_file(): - break - logger.warning("Waiting for temp nginx to stop ...") - sleep(1) - i += 1 - if i >= 20: - logger.error("Timeout error while waiting for temp nginx to stop") - else: - # Start nginx - logger.info("Starting nginx ...") - proc = subprocess_run( - [join(sep, "usr", "sbin", "nginx")], - stdin=DEVNULL, - stderr=STDOUT, - env=env.copy(), - check=False, - ) - if proc.returncode == 0: - logger.info("Successfully started nginx") - else: - logger.error( - f"Error while starting nginx - returncode: {proc.returncode} - error: {proc.stderr.decode('utf-8') if proc.stderr else 'Missing stderr'}", - ) + logger.info("Successfully sent reload signal to nginx") else: logger.error( - f"Error while sending stop signal to temp nginx - returncode: {proc.returncode} - error: {proc.stderr.decode('utf-8') if proc.stderr else 'Missing stderr'}", + f"Error while reloading nginx - returncode: {proc.returncode} - error: {proc.stdout.decode('utf-8') if proc.stdout else 'no output'}", ) + # # Stop temp nginx + # logger.info("Stopping temp nginx ...") + # proc = subprocess_run( + # [join(sep, "usr", "sbin", "nginx"), "-s", "stop"], + # stdin=DEVNULL, + # stderr=STDOUT, + # env=env.copy(), + # check=False, + # ) + # if proc.returncode == 0: + # logger.info("Successfully sent stop signal to temp nginx") + # i = 0 + # while i < 20: + # if not Path(sep, "var", "run", "bunkerweb", "nginx.pid").is_file(): + # break + # logger.warning("Waiting for temp nginx to stop ...") + # sleep(1) + # i += 1 + # if i >= 20: + # logger.error("Timeout error while waiting for temp nginx to stop") + # else: + # # Start nginx + # logger.info("Starting nginx ...") + # proc = subprocess_run( + # [join(sep, "usr", "sbin", "nginx"), "-e", "/var/log/bunkerweb/error.log"], + # stdin=DEVNULL, + # stderr=STDOUT, + # env=env.copy(), + # check=False, + # ) + # if proc.returncode == 0: + # logger.info("Successfully started nginx") + # else: + # logger.error( + # f"Error while starting nginx - returncode: {proc.returncode} - error: {proc.stderr.decode('utf-8') if proc.stderr else 'Missing stderr'}", + # ) + # else: + # logger.error( + # f"Error while sending stop signal to temp nginx - returncode: {proc.returncode} - error: {proc.stderr.decode('utf-8') if proc.stderr else 'Missing stderr'}", + # ) except: logger.error( f"Exception while reloading after running jobs once scheduling : {format_exc()}", diff --git a/src/scheduler/requirements.in b/src/scheduler/requirements.in index 6b54a75f3..572837acb 100644 --- a/src/scheduler/requirements.in +++ b/src/scheduler/requirements.in @@ -4,4 +4,4 @@ cryptography==41.0.5 maxminddb==2.4.0 python-magic==0.4.27 schedule==1.2.1 -urllib3==1.26.18 +urllib3<2.0.0 diff --git a/src/ui/requirements.in b/src/ui/requirements.in index 7359eb672..8c81cefbd 100644 --- a/src/ui/requirements.in +++ b/src/ui/requirements.in @@ -1,7 +1,7 @@ bcrypt==4.0.1 beautifulsoup4==4.12.2 Flask==3.0.0 -Flask-Login @ https://github.com/maxcountryman/flask-login/archive/7d98a49bc38d0849367b348bfe37a2b689323419.zip#sha256=62db8eeeae5170f0d9b54d401d63b1a19d0df8944db9ae5332b350bc284f108b +Flask-Login==0.6.3 Flask_WTF==1.2.1 gunicorn[gthread]==21.2.0 importlib-metadata==6.8.0 diff --git a/src/ui/requirements.txt b/src/ui/requirements.txt index 686c89963..25cbd5138 100644 --- a/src/ui/requirements.txt +++ b/src/ui/requirements.txt @@ -46,8 +46,9 @@ flask==3.0.0 \ # -r requirements.in # flask-login # flask-wtf -flask-login @ https://github.com/maxcountryman/flask-login/archive/7d98a49bc38d0849367b348bfe37a2b689323419.zip#sha256=62db8eeeae5170f0d9b54d401d63b1a19d0df8944db9ae5332b350bc284f108b \ - --hash=sha256:62db8eeeae5170f0d9b54d401d63b1a19d0df8944db9ae5332b350bc284f108b +flask-login==0.6.3 \ + --hash=sha256:5e23d14a607ef12806c699590b89d0f0e0d67baeec599d75947bf9c147330333 \ + --hash=sha256:849b25b82a436bf830a054e74214074af59097171562ab10bfa999e6b78aae5d # via -r requirements.in flask-wtf==1.2.1 \ --hash=sha256:8bb269eb9bb46b87e7c8233d7e7debdf1f8b74bf90cc1789988c29b37a97b695 \ diff --git a/src/ui/src/Instances.py b/src/ui/src/Instances.py index 3d772859a..04e3a8ecf 100644 --- a/src/ui/src/Instances.py +++ b/src/ui/src/Instances.py @@ -60,7 +60,7 @@ class Instance: if self._type == "local": return ( run( - [join(sep, "usr", "sbin", "nginx")], + [join(sep, "usr", "sbin", "nginx"), "-e", "/var/log/bunkerweb/error.log"], stdin=DEVNULL, stderr=STDOUT, check=False, @@ -96,7 +96,7 @@ class Instance: return False return ( run( - [join(sep, "usr", "sbin", "nginx")], + [join(sep, "usr", "sbin", "nginx"), "-e", "/var/log/bunkerweb/error.log"], stdin=DEVNULL, stderr=STDOUT, check=False, @@ -126,7 +126,7 @@ class Instances: # Docker instances (containers or services) if self.__docker_client is not None: for instance in self.__docker_client.containers.list(all=True, filters={"label": "bunkerweb.INSTANCE"}): - env_variables = {x[0]: x[1] for x in [env.split("=") for env in instance.attrs["Config"]["Env"]]} + env_variables = {x[0]: (x[1] if len(x) > 1 else "") for x in [env.split("=") for env in instance.attrs["Config"]["Env"]]} instances.append( Instance( diff --git a/tests/core/antibot/docker-compose.yml b/tests/core/antibot/docker-compose.yml index f228041c9..d4ccc856c 100644 --- a/tests/core/antibot/docker-compose.yml +++ b/tests/core/antibot/docker-compose.yml @@ -19,6 +19,15 @@ services: # ? ANTIBOT settings USE_ANTIBOT: "no" ANTIBOT_URI: "/challenge" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/antibot/main.py b/tests/core/antibot/main.py index 6b0504cdc..2d6e61332 100644 --- a/tests/core/antibot/main.py +++ b/tests/core/antibot/main.py @@ -14,13 +14,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text - if status_code >= 500: + if resp.status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/antibot/ready.conf b/tests/core/antibot/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/antibot/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/antibot/requirements.txt b/tests/core/antibot/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/antibot/requirements.txt +++ b/tests/core/antibot/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/antibot/test.sh b/tests/core/antibot/test.sh index 5810c4abc..dc0f75a15 100755 --- a/tests/core/antibot/test.sh +++ b/tests/core/antibot/test.sh @@ -31,6 +31,7 @@ else echo "USE_ANTIBOT=no" | sudo tee -a /etc/bunkerweb/variables.env echo "ANTIBOT_URI=/challenge" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/authbasic/docker-compose.yml b/tests/core/authbasic/docker-compose.yml index b6ac542bc..8663d205e 100644 --- a/tests/core/authbasic/docker-compose.yml +++ b/tests/core/authbasic/docker-compose.yml @@ -21,6 +21,15 @@ services: AUTH_BASIC_LOCATION: "sitewide" AUTH_BASIC_USER: "bunkerity" AUTH_BASIC_PASSWORD: "Secr3tP@ssw0rd" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/authbasic/main.py b/tests/core/authbasic/main.py index 760fbf4b5..f014d99bf 100644 --- a/tests/core/authbasic/main.py +++ b/tests/core/authbasic/main.py @@ -14,13 +14,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code <= 401 + ready = status_code <= 401 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/authbasic/ready.conf b/tests/core/authbasic/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/authbasic/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/authbasic/requirements.txt b/tests/core/authbasic/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/authbasic/requirements.txt +++ b/tests/core/authbasic/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/authbasic/test.sh b/tests/core/authbasic/test.sh index 01104a3cc..6cd4eadb0 100755 --- a/tests/core/authbasic/test.sh +++ b/tests/core/authbasic/test.sh @@ -33,6 +33,7 @@ else echo "AUTH_BASIC_USER=bunkerity" | sudo tee -a /etc/bunkerweb/variables.env echo "AUTH_BASIC_PASSWORD=Secr3tP@ssw0rd" | sudo tee -a /etc/bunkerweb/variables.env sudo wget -O /var/www/html/index.html https://github.com/nginxinc/NGINX-Demos/raw/master/nginx-hello-nonroot/html-version/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/badbehavior/docker-compose.yml b/tests/core/badbehavior/docker-compose.yml index 15d5b7053..277f38141 100644 --- a/tests/core/badbehavior/docker-compose.yml +++ b/tests/core/badbehavior/docker-compose.yml @@ -21,6 +21,15 @@ services: BAD_BEHAVIOR_BAN_TIME: "86400" BAD_BEHAVIOR_THRESHOLD: "10" BAD_BEHAVIOR_COUNT_TIME: "60" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/badbehavior/index.html b/tests/core/badbehavior/index.html index e69de29bb..ad50b5340 100644 --- a/tests/core/badbehavior/index.html +++ b/tests/core/badbehavior/index.html @@ -0,0 +1 @@ +ready \ No newline at end of file diff --git a/tests/core/badbehavior/main.py b/tests/core/badbehavior/main.py index 5c24c3648..5feac6157 100644 --- a/tests/core/badbehavior/main.py +++ b/tests/core/badbehavior/main.py @@ -13,13 +13,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/badbehavior/ready.conf b/tests/core/badbehavior/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/badbehavior/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/badbehavior/test.sh b/tests/core/badbehavior/test.sh index c0f133283..af82c382d 100755 --- a/tests/core/badbehavior/test.sh +++ b/tests/core/badbehavior/test.sh @@ -36,6 +36,7 @@ else echo "BAD_BEHAVIOR_COUNT_TIME=60" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/blacklist/api/requirements.in b/tests/core/blacklist/api/requirements.in index d7f6583eb..2ca0cca5b 100644 --- a/tests/core/blacklist/api/requirements.in +++ b/tests/core/blacklist/api/requirements.in @@ -1,2 +1,2 @@ -fastapi==0.104.0 +fastapi==0.104.1 uvicorn[standard]==0.23.2 diff --git a/tests/core/blacklist/api/requirements.txt b/tests/core/blacklist/api/requirements.txt index cab6b73ee..2e836e780 100644 --- a/tests/core/blacklist/api/requirements.txt +++ b/tests/core/blacklist/api/requirements.txt @@ -23,9 +23,9 @@ exceptiongroup==1.1.3 \ --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 # via anyio -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ diff --git a/tests/core/blacklist/docker-compose.yml b/tests/core/blacklist/docker-compose.yml index b2b3998e9..f7c928c82 100644 --- a/tests/core/blacklist/docker-compose.yml +++ b/tests/core/blacklist/docker-compose.yml @@ -37,6 +37,15 @@ services: BLACKLIST_IGNORE_USER_AGENT_URLS: "" BLACKLIST_IGNORE_URI: "" BLACKLIST_IGNORE_URI_URLS: "" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/blacklist/main.py b/tests/core/blacklist/main.py index f944ccb95..27de861de 100644 --- a/tests/core/blacklist/main.py +++ b/tests/core/blacklist/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 or status_code == 403 + ready = status_code < 400 or status_code == 403 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/blacklist/ready.conf b/tests/core/blacklist/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/blacklist/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/blacklist/test.sh b/tests/core/blacklist/test.sh index 5a80f569c..81fb004b4 100755 --- a/tests/core/blacklist/test.sh +++ b/tests/core/blacklist/test.sh @@ -65,6 +65,7 @@ else echo "BLACKLIST_IGNORE_URI_URLS=" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/brotli/docker-compose.yml b/tests/core/brotli/docker-compose.yml index b1fb649b9..2a097f0f3 100644 --- a/tests/core/brotli/docker-compose.yml +++ b/tests/core/brotli/docker-compose.yml @@ -18,6 +18,15 @@ services: # ? BROTLI settings USE_BROTLI: "no" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/brotli/main.py b/tests/core/brotli/main.py index dd44490db..a6267374e 100644 --- a/tests/core/brotli/main.py +++ b/tests/core/brotli/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/brotli/ready.conf b/tests/core/brotli/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/brotli/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/brotli/test.sh b/tests/core/brotli/test.sh index ab39b2a66..f0e2a7c42 100755 --- a/tests/core/brotli/test.sh +++ b/tests/core/brotli/test.sh @@ -30,6 +30,7 @@ else sudo systemctl stop bunkerweb echo "USE_BROTLI=no" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/bunkernet/api/requirements.in b/tests/core/bunkernet/api/requirements.in index d7f6583eb..2ca0cca5b 100644 --- a/tests/core/bunkernet/api/requirements.in +++ b/tests/core/bunkernet/api/requirements.in @@ -1,2 +1,2 @@ -fastapi==0.104.0 +fastapi==0.104.1 uvicorn[standard]==0.23.2 diff --git a/tests/core/bunkernet/api/requirements.txt b/tests/core/bunkernet/api/requirements.txt index cab6b73ee..2e836e780 100644 --- a/tests/core/bunkernet/api/requirements.txt +++ b/tests/core/bunkernet/api/requirements.txt @@ -23,9 +23,9 @@ exceptiongroup==1.1.3 \ --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 # via anyio -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ diff --git a/tests/core/bunkernet/docker-compose.yml b/tests/core/bunkernet/docker-compose.yml index ef45b4db0..c48624743 100644 --- a/tests/core/bunkernet/docker-compose.yml +++ b/tests/core/bunkernet/docker-compose.yml @@ -17,6 +17,15 @@ services: # ? BUNKERNET settings USE_BUNKERNET: "yes" BUNKERNET_SERVER: "http://bunkernet-api:8080" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/bunkernet/main.py b/tests/core/bunkernet/main.py index 745ccc050..d8f0294d2 100644 --- a/tests/core/bunkernet/main.py +++ b/tests/core/bunkernet/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/bunkernet/ready.conf b/tests/core/bunkernet/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/bunkernet/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/bunkernet/test.sh b/tests/core/bunkernet/test.sh index d5677dc72..74f490dc2 100755 --- a/tests/core/bunkernet/test.sh +++ b/tests/core/bunkernet/test.sh @@ -46,6 +46,7 @@ else export BUNKERNET_SERVER="http://127.0.0.1:8080" sudo touch /var/www/html/index.html python3 api/main.py & + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/bwcli/docker-compose.yml b/tests/core/bwcli/docker-compose.yml index 23450b40f..96ca5e392 100644 --- a/tests/core/bwcli/docker-compose.yml +++ b/tests/core/bwcli/docker-compose.yml @@ -15,6 +15,15 @@ services: LOG_LEVEL: "info" USE_REDIS: "yes" REDIS_HOST: "bw-redis" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: - bw-universe diff --git a/tests/core/bwcli/ready.conf b/tests/core/bwcli/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/bwcli/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/bwcli/test.sh b/tests/core/bwcli/test.sh index e05d2fb73..c56eef24c 100755 --- a/tests/core/bwcli/test.sh +++ b/tests/core/bwcli/test.sh @@ -45,6 +45,7 @@ else export USE_REDIS="yes" export REDIS_HOST="127.0.0.1" sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi cleanup_stack () { diff --git a/tests/core/clientcache/docker-compose.yml b/tests/core/clientcache/docker-compose.yml index 2e9baf015..49e6b62e8 100644 --- a/tests/core/clientcache/docker-compose.yml +++ b/tests/core/clientcache/docker-compose.yml @@ -20,6 +20,15 @@ services: CLIENT_CACHE_EXTENSIONS: "jpg|jpeg|png|bmp|ico|svg|tif|css|js|otf|ttf|eot|woff|woff2" CLIENT_CACHE_ETAG: "yes" CLIENT_CACHE_CONTROL: "public, max-age=15552000" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/clientcache/main.py b/tests/core/clientcache/main.py index c6bbe6764..acc34ca26 100644 --- a/tests/core/clientcache/main.py +++ b/tests/core/clientcache/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com/image.png", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/clientcache/ready.conf b/tests/core/clientcache/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/clientcache/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/clientcache/test.sh b/tests/core/clientcache/test.sh index 180fa114b..cef1e4f47 100755 --- a/tests/core/clientcache/test.sh +++ b/tests/core/clientcache/test.sh @@ -34,6 +34,7 @@ else echo "CLIENT_CACHE_CONTROL=public, max-age=15552000" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html sudo cp image.png /var/www/html/image.png + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/cors/docker-compose.yml b/tests/core/cors/docker-compose.yml index 73a78daf8..1ebbbea9e 100644 --- a/tests/core/cors/docker-compose.yml +++ b/tests/core/cors/docker-compose.yml @@ -30,6 +30,15 @@ services: CORS_ALLOW_CREDENTIALS: "no" CORS_ALLOW_METHODS: "GET, POST, OPTIONS" CORS_ALLOW_HEADERS: "DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/cors/main.py b/tests/core/cors/main.py index 8029d2607..01840107d 100644 --- a/tests/core/cors/main.py +++ b/tests/core/cors/main.py @@ -14,18 +14,20 @@ try: ready = False retries = 0 while not ready: - with suppress(RequestException): - status_code = get( - f"http{'s' if ssl else ''}://www.example.com", + with suppress(RequestException): + resp = get( + f"http{'s' if ssl else ''}://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False, - ).status_code + ) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/cors/ready.conf b/tests/core/cors/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/cors/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/cors/requirements.txt b/tests/core/cors/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/cors/requirements.txt +++ b/tests/core/cors/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/cors/test.sh b/tests/core/cors/test.sh index 4d7daef7c..cbacc0472 100755 --- a/tests/core/cors/test.sh +++ b/tests/core/cors/test.sh @@ -43,6 +43,7 @@ else echo "CORS_ALLOW_CREDENTIALS=no" | sudo tee -a /etc/bunkerweb/variables.env echo "CORS_ALLOW_METHODS=GET, POST, OPTIONS" | sudo tee -a /etc/bunkerweb/variables.env echo "CORS_ALLOW_HEADERS=DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range" | sudo tee -a /etc/bunkerweb/variables.env + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/country/docker-compose.yml b/tests/core/country/docker-compose.yml index 8e7a3a7f3..535874847 100644 --- a/tests/core/country/docker-compose.yml +++ b/tests/core/country/docker-compose.yml @@ -18,6 +18,15 @@ services: # ? COUNTRY settings BLACKLIST_COUNTRY: "" WHITELIST_COUNTRY: "" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-us-network: diff --git a/tests/core/country/main.py b/tests/core/country/main.py index 157a291b9..1e0470f54 100644 --- a/tests/core/country/main.py +++ b/tests/core/country/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 or status_code == 403 + ready = status_code < 400 or status_code == 403 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/country/ready.conf b/tests/core/country/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/country/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/country/test.sh b/tests/core/country/test.sh index 965621897..ff98ae3c8 100755 --- a/tests/core/country/test.sh +++ b/tests/core/country/test.sh @@ -36,6 +36,7 @@ else sudo touch /var/www/html/index.html export COUNTRY="" export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/customcert/docker-compose.yml b/tests/core/customcert/docker-compose.yml index 3df7fd3a2..0438fc826 100644 --- a/tests/core/customcert/docker-compose.yml +++ b/tests/core/customcert/docker-compose.yml @@ -20,6 +20,15 @@ services: USE_CUSTOM_SSL: "no" CUSTOM_SSL_CERT: "/certs/certificate.pem" CUSTOM_SSL_KEY: "/certs/privatekey.key" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/customcert/main.py b/tests/core/customcert/main.py index d3459d04b..0037eae3a 100644 --- a/tests/core/customcert/main.py +++ b/tests/core/customcert/main.py @@ -1,9 +1,38 @@ +from contextlib import suppress from os import getenv -from requests import get -from requests.exceptions import RequestException +from requests import RequestException, get from traceback import format_exc +from time import sleep try: + + ready = False + retries = 0 + while not ready: + with suppress(RequestException): + resp = get( + f"http://www.example.com/ready", + headers={"Host": "www.example.com"}, + verify=False, + allow_redirects=True + ) + status_code = resp.status_code + text = resp.text + + if status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ The service took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for the service to be ready, retrying in 5s ...", flush=True) + sleep(5) + use_custom_ssl = getenv("USE_CUSTOM_SSL", "no") == "yes" print( diff --git a/tests/core/customcert/ready.conf b/tests/core/customcert/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/customcert/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/customcert/requirements.in b/tests/core/customcert/requirements.in index 2c24336eb..e63824704 100644 --- a/tests/core/customcert/requirements.in +++ b/tests/core/customcert/requirements.in @@ -1 +1,3 @@ requests==2.31.0 +selenium==4.14.0 +urllib3[socks]==2.0.7 diff --git a/tests/core/customcert/requirements.txt b/tests/core/customcert/requirements.txt index 99a4d0cfb..5642b428d 100644 --- a/tests/core/customcert/requirements.txt +++ b/tests/core/customcert/requirements.txt @@ -4,10 +4,18 @@ # # pip-compile --allow-unsafe --generate-hashes --strip-extras requirements.in # +attrs==23.1.0 \ + --hash=sha256:1f28b4522cdc2fb4256ac1a020c78acf9cba2c6b461ccd2c126f3aa8e8335d04 \ + --hash=sha256:6279836d581513a26f1bf235f9acd333bc9115683f14f7e8fae46c98fc50e015 + # via + # outcome + # trio certifi==2023.7.22 \ --hash=sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082 \ --hash=sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9 - # via requests + # via + # requests + # selenium charset-normalizer==3.3.1 \ --hash=sha256:06cf46bdff72f58645434d467bf5228080801298fbba19fe268a01b4534467f5 \ --hash=sha256:0c8c61fb505c7dad1d251c284e712d4e0372cef3b067f7ddf82a7fa82e1e9a93 \ @@ -100,15 +108,66 @@ charset-normalizer==3.3.1 \ --hash=sha256:f6a02a3c7950cafaadcd46a226ad9e12fc9744652cc69f9e5534f98b47f3bbcf \ --hash=sha256:fe81b35c33772e56f4b6cf62cf4aedc1762ef7162a31e6ac7fe5e40d0149eb67 # via requests +exceptiongroup==1.1.3 \ + --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ + --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 + # via + # trio + # trio-websocket +h11==0.14.0 \ + --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ + --hash=sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761 + # via wsproto idna==3.4 \ --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \ --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2 - # via requests + # via + # requests + # trio +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b + # via trio +pysocks==1.7.1 \ + --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ + --hash=sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5 \ + --hash=sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0 + # via urllib3 requests==2.31.0 \ --hash=sha256:58cd2187c01e70e6e26505bca751777aa9f2ee0b7f4300988b709f44e013003f \ --hash=sha256:942c5a758f98d790eaed1a29cb6eefc7ffb0d1cf7af05c3d2791656dbd6ad1e1 # via -r requirements.in +selenium==4.14.0 \ + --hash=sha256:0d14b0d9842366f38fb5f8f842cf7c042bcfa062affc6a0a86e4d634bdd0fe54 \ + --hash=sha256:be9824a9354a7fe288e3fad9ceb6a9c65ddc7c44545d23ad0ebf4ce202b19893 + # via -r requirements.in +sniffio==1.3.0 \ + --hash=sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101 \ + --hash=sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384 + # via trio +sortedcontainers==2.4.0 \ + --hash=sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88 \ + --hash=sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0 + # via trio +trio==0.22.2 \ + --hash=sha256:3887cf18c8bcc894433420305468388dac76932e9668afa1c49aa3806b6accb3 \ + --hash=sha256:f43da357620e5872b3d940a2e3589aa251fd3f881b65a608d742e00809b1ec38 + # via + # selenium + # trio-websocket +trio-websocket==0.11.1 \ + --hash=sha256:18c11793647703c158b1f6e62de638acada927344d534e3c7628eedcb746839f \ + --hash=sha256:520d046b0d030cf970b8b2b2e00c4c2245b3807853ecd44214acd33d74581638 + # via selenium urllib3==2.0.7 \ --hash=sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84 \ --hash=sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e - # via requests + # via + # -r requirements.in + # requests + # selenium + # urllib3 +wsproto==1.2.0 \ + --hash=sha256:ad565f26ecb92588a3e43bc3d96164de84cd9902482b130d0ddbaa9664a85065 \ + --hash=sha256:b9acddd652b585d75b20477888c56642fdade28bdfd3579aa24a4d2c037dd736 + # via trio-websocket diff --git a/tests/core/customcert/test.sh b/tests/core/customcert/test.sh index a392613f0..4ebd49da6 100755 --- a/tests/core/customcert/test.sh +++ b/tests/core/customcert/test.sh @@ -32,6 +32,7 @@ else echo "CUSTOM_SSL_CERT=/tmp/certificate.pem" | sudo tee -a /etc/bunkerweb/variables.env echo "CUSTOM_SSL_KEY=/tmp/privatekey.key" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/db/docker-compose.yml b/tests/core/db/docker-compose.yml index 9931fe446..76b141616 100644 --- a/tests/core/db/docker-compose.yml +++ b/tests/core/db/docker-compose.yml @@ -18,6 +18,15 @@ services: REVERSE_PROXY_URL: "/" LOG_LEVEL: "info" CUSTOM_CONF_MODSEC_test_custom_conf: 'SecRule REQUEST_FILENAME "@rx ^/db" "id:10000,ctl:ruleRemoveByTag=attack-generic,ctl:ruleRemoveByTag=attack-protocol,nolog"' + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/db/main.py b/tests/core/db/main.py index 6d79407f5..a1eadd43d 100644 --- a/tests/core/db/main.py +++ b/tests/core/db/main.py @@ -179,6 +179,8 @@ try: global_values = session.query(Global_values).all() for global_value in global_values: + if global_value.setting_id == "API_LISTEN_IP": + continue if global_value.setting_id in global_settings: if global_value.value != global_settings[global_value.setting_id]["value"]: print( @@ -550,6 +552,8 @@ try: ) for custom_config in custom_configs: + if custom_config.name == "ready": + continue if not multisite and custom_config.name in global_custom_configs and custom_config.service_id: print( f"❌ The custom config {custom_config.name} is in the database but should not be owned by the service {custom_config.service_id} because multisite is not enabled, exiting ...", diff --git a/tests/core/db/ready.conf b/tests/core/db/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/db/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/db/requirements.txt b/tests/core/db/requirements.txt index ce3aea16f..3ded44a65 100644 --- a/tests/core/db/requirements.txt +++ b/tests/core/db/requirements.txt @@ -83,69 +83,64 @@ cryptography==41.0.5 \ --hash=sha256:ec3b055ff8f1dce8e6ef28f626e0972981475173d7973d63f271b29c8a2897da \ --hash=sha256:fba1e91467c65fe64a82c689dc6cf58151158993b13eb7a7f3f4b7f395636723 # via -r requirements.in -greenlet==3.0.0 \ - --hash=sha256:02a807b2a58d5cdebb07050efe3d7deaf915468d112dfcf5e426d0564aa3aa4a \ - --hash=sha256:0b72b802496cccbd9b31acea72b6f87e7771ccfd7f7927437d592e5c92ed703c \ - --hash=sha256:0d3f83ffb18dc57243e0151331e3c383b05e5b6c5029ac29f754745c800f8ed9 \ - --hash=sha256:10b5582744abd9858947d163843d323d0b67be9432db50f8bf83031032bc218d \ - --hash=sha256:123910c58234a8d40eaab595bc56a5ae49bdd90122dde5bdc012c20595a94c14 \ - --hash=sha256:1482fba7fbed96ea7842b5a7fc11d61727e8be75a077e603e8ab49d24e234383 \ - --hash=sha256:19834e3f91f485442adc1ee440171ec5d9a4840a1f7bd5ed97833544719ce10b \ - --hash=sha256:1d363666acc21d2c204dd8705c0e0457d7b2ee7a76cb16ffc099d6799744ac99 \ - --hash=sha256:211ef8d174601b80e01436f4e6905aca341b15a566f35a10dd8d1e93f5dbb3b7 \ - --hash=sha256:269d06fa0f9624455ce08ae0179430eea61085e3cf6457f05982b37fd2cefe17 \ - --hash=sha256:2e7dcdfad252f2ca83c685b0fa9fba00e4d8f243b73839229d56ee3d9d219314 \ - --hash=sha256:334ef6ed8337bd0b58bb0ae4f7f2dcc84c9f116e474bb4ec250a8bb9bd797a66 \ - --hash=sha256:343675e0da2f3c69d3fb1e894ba0a1acf58f481f3b9372ce1eb465ef93cf6fed \ - --hash=sha256:37f60b3a42d8b5499be910d1267b24355c495064f271cfe74bf28b17b099133c \ - --hash=sha256:38ad562a104cd41e9d4644f46ea37167b93190c6d5e4048fcc4b80d34ecb278f \ - --hash=sha256:3c0d36f5adc6e6100aedbc976d7428a9f7194ea79911aa4bf471f44ee13a9464 \ - --hash=sha256:3fd2b18432e7298fcbec3d39e1a0aa91ae9ea1c93356ec089421fabc3651572b \ - --hash=sha256:4a1a6244ff96343e9994e37e5b4839f09a0207d35ef6134dce5c20d260d0302c \ - --hash=sha256:4cd83fb8d8e17633ad534d9ac93719ef8937568d730ef07ac3a98cb520fd93e4 \ - --hash=sha256:527cd90ba3d8d7ae7dceb06fda619895768a46a1b4e423bdb24c1969823b8362 \ - --hash=sha256:56867a3b3cf26dc8a0beecdb4459c59f4c47cdd5424618c08515f682e1d46692 \ - --hash=sha256:621fcb346141ae08cb95424ebfc5b014361621b8132c48e538e34c3c93ac7365 \ - --hash=sha256:63acdc34c9cde42a6534518e32ce55c30f932b473c62c235a466469a710bfbf9 \ - --hash=sha256:6512592cc49b2c6d9b19fbaa0312124cd4c4c8a90d28473f86f92685cc5fef8e \ - --hash=sha256:6672fdde0fd1a60b44fb1751a7779c6db487e42b0cc65e7caa6aa686874e79fb \ - --hash=sha256:6a5b2d4cdaf1c71057ff823a19d850ed5c6c2d3686cb71f73ae4d6382aaa7a06 \ - --hash=sha256:6a68d670c8f89ff65c82b936275369e532772eebc027c3be68c6b87ad05ca695 \ - --hash=sha256:6bb36985f606a7c49916eff74ab99399cdfd09241c375d5a820bb855dfb4af9f \ - --hash=sha256:73b2f1922a39d5d59cc0e597987300df3396b148a9bd10b76a058a2f2772fc04 \ - --hash=sha256:7709fd7bb02b31908dc8fd35bfd0a29fc24681d5cc9ac1d64ad07f8d2b7db62f \ - --hash=sha256:8060b32d8586e912a7b7dac2d15b28dbbd63a174ab32f5bc6d107a1c4143f40b \ - --hash=sha256:80dcd3c938cbcac986c5c92779db8e8ce51a89a849c135172c88ecbdc8c056b7 \ - --hash=sha256:813720bd57e193391dfe26f4871186cf460848b83df7e23e6bef698a7624b4c9 \ - --hash=sha256:831d6f35037cf18ca5e80a737a27d822d87cd922521d18ed3dbc8a6967be50ce \ - --hash=sha256:871b0a8835f9e9d461b7fdaa1b57e3492dd45398e87324c047469ce2fc9f516c \ - --hash=sha256:952256c2bc5b4ee8df8dfc54fc4de330970bf5d79253c863fb5e6761f00dda35 \ - --hash=sha256:96d9ea57292f636ec851a9bb961a5cc0f9976900e16e5d5647f19aa36ba6366b \ - --hash=sha256:9a812224a5fb17a538207e8cf8e86f517df2080c8ee0f8c1ed2bdaccd18f38f4 \ - --hash=sha256:9adbd8ecf097e34ada8efde9b6fec4dd2a903b1e98037adf72d12993a1c80b51 \ - --hash=sha256:9de687479faec7db5b198cc365bc34addd256b0028956501f4d4d5e9ca2e240a \ - --hash=sha256:a048293392d4e058298710a54dfaefcefdf49d287cd33fb1f7d63d55426e4355 \ - --hash=sha256:aa15a2ec737cb609ed48902b45c5e4ff6044feb5dcdfcf6fa8482379190330d7 \ - --hash=sha256:abe1ef3d780de56defd0c77c5ba95e152f4e4c4e12d7e11dd8447d338b85a625 \ - --hash=sha256:ad6fb737e46b8bd63156b8f59ba6cdef46fe2b7db0c5804388a2d0519b8ddb99 \ - --hash=sha256:b1660a15a446206c8545edc292ab5c48b91ff732f91b3d3b30d9a915d5ec4779 \ - --hash=sha256:b505fcfc26f4148551826a96f7317e02c400665fa0883fe505d4fcaab1dabfdd \ - --hash=sha256:b822fab253ac0f330ee807e7485769e3ac85d5eef827ca224feaaefa462dc0d0 \ - --hash=sha256:bdd696947cd695924aecb3870660b7545a19851f93b9d327ef8236bfc49be705 \ - --hash=sha256:bdfaeecf8cc705d35d8e6de324bf58427d7eafb55f67050d8f28053a3d57118c \ - --hash=sha256:be557119bf467d37a8099d91fbf11b2de5eb1fd5fc5b91598407574848dc910f \ - --hash=sha256:c6b5ce7f40f0e2f8b88c28e6691ca6806814157ff05e794cdd161be928550f4c \ - --hash=sha256:c94e4e924d09b5a3e37b853fe5924a95eac058cb6f6fb437ebb588b7eda79870 \ - --hash=sha256:cc3e2679ea13b4de79bdc44b25a0c4fcd5e94e21b8f290791744ac42d34a0353 \ - --hash=sha256:d1e22c22f7826096ad503e9bb681b05b8c1f5a8138469b255eb91f26a76634f2 \ - --hash=sha256:d5539f6da3418c3dc002739cb2bb8d169056aa66e0c83f6bacae0cd3ac26b423 \ - --hash=sha256:d55db1db455c59b46f794346efce896e754b8942817f46a1bada2d29446e305a \ - --hash=sha256:e09dea87cc91aea5500262993cbd484b41edf8af74f976719dd83fe724644cd6 \ - --hash=sha256:e52a712c38e5fb4fd68e00dc3caf00b60cb65634d50e32281a9d6431b33b4af1 \ - --hash=sha256:e693e759e172fa1c2c90d35dea4acbdd1d609b6936115d3739148d5e4cd11947 \ - --hash=sha256:ecf94aa539e97a8411b5ea52fc6ccd8371be9550c4041011a091eb8b3ca1d810 \ - --hash=sha256:f351479a6914fd81a55c8e68963609f792d9b067fb8a60a042c585a621e0de4f \ - --hash=sha256:f47932c434a3c8d3c86d865443fadc1fbf574e9b11d6650b656e602b1797908a +greenlet==3.0.1 \ + --hash=sha256:0a02d259510b3630f330c86557331a3b0e0c79dac3d166e449a39363beaae174 \ + --hash=sha256:0b6f9f8ca7093fd4433472fd99b5650f8a26dcd8ba410e14094c1e44cd3ceddd \ + --hash=sha256:100f78a29707ca1525ea47388cec8a049405147719f47ebf3895e7509c6446aa \ + --hash=sha256:1757936efea16e3f03db20efd0cd50a1c86b06734f9f7338a90c4ba85ec2ad5a \ + --hash=sha256:19075157a10055759066854a973b3d1325d964d498a805bb68a1f9af4aaef8ec \ + --hash=sha256:19bbdf1cce0346ef7341705d71e2ecf6f41a35c311137f29b8a2dc2341374565 \ + --hash=sha256:20107edf7c2c3644c67c12205dc60b1bb11d26b2610b276f97d666110d1b511d \ + --hash=sha256:22f79120a24aeeae2b4471c711dcf4f8c736a2bb2fabad2a67ac9a55ea72523c \ + --hash=sha256:2847e5d7beedb8d614186962c3d774d40d3374d580d2cbdab7f184580a39d234 \ + --hash=sha256:28e89e232c7593d33cac35425b58950789962011cc274aa43ef8865f2e11f46d \ + --hash=sha256:329c5a2e5a0ee942f2992c5e3ff40be03e75f745f48847f118a3cfece7a28546 \ + --hash=sha256:337322096d92808f76ad26061a8f5fccb22b0809bea39212cd6c406f6a7060d2 \ + --hash=sha256:3fcc780ae8edbb1d050d920ab44790201f027d59fdbd21362340a85c79066a74 \ + --hash=sha256:41bdeeb552d814bcd7fb52172b304898a35818107cc8778b5101423c9017b3de \ + --hash=sha256:4eddd98afc726f8aee1948858aed9e6feeb1758889dfd869072d4465973f6bfd \ + --hash=sha256:52e93b28db27ae7d208748f45d2db8a7b6a380e0d703f099c949d0f0d80b70e9 \ + --hash=sha256:55d62807f1c5a1682075c62436702aaba941daa316e9161e4b6ccebbbf38bda3 \ + --hash=sha256:5805e71e5b570d490938d55552f5a9e10f477c19400c38bf1d5190d760691846 \ + --hash=sha256:599daf06ea59bfedbec564b1692b0166a0045f32b6f0933b0dd4df59a854caf2 \ + --hash=sha256:60d5772e8195f4e9ebf74046a9121bbb90090f6550f81d8956a05387ba139353 \ + --hash=sha256:696d8e7d82398e810f2b3622b24e87906763b6ebfd90e361e88eb85b0e554dc8 \ + --hash=sha256:6e6061bf1e9565c29002e3c601cf68569c450be7fc3f7336671af7ddb4657166 \ + --hash=sha256:80ac992f25d10aaebe1ee15df45ca0d7571d0f70b645c08ec68733fb7a020206 \ + --hash=sha256:816bd9488a94cba78d93e1abb58000e8266fa9cc2aa9ccdd6eb0696acb24005b \ + --hash=sha256:85d2b77e7c9382f004b41d9c72c85537fac834fb141b0296942d52bf03fe4a3d \ + --hash=sha256:87c8ceb0cf8a5a51b8008b643844b7f4a8264a2c13fcbcd8a8316161725383fe \ + --hash=sha256:89ee2e967bd7ff85d84a2de09df10e021c9b38c7d91dead95b406ed6350c6997 \ + --hash=sha256:8bef097455dea90ffe855286926ae02d8faa335ed8e4067326257cb571fc1445 \ + --hash=sha256:8d11ebbd679e927593978aa44c10fc2092bc454b7d13fdc958d3e9d508aba7d0 \ + --hash=sha256:91e6c7db42638dc45cf2e13c73be16bf83179f7859b07cfc139518941320be96 \ + --hash=sha256:97e7ac860d64e2dcba5c5944cfc8fa9ea185cd84061c623536154d5a89237884 \ + --hash=sha256:990066bff27c4fcf3b69382b86f4c99b3652bab2a7e685d968cd4d0cfc6f67c6 \ + --hash=sha256:9fbc5b8f3dfe24784cee8ce0be3da2d8a79e46a276593db6868382d9c50d97b1 \ + --hash=sha256:ac4a39d1abae48184d420aa8e5e63efd1b75c8444dd95daa3e03f6c6310e9619 \ + --hash=sha256:b2c02d2ad98116e914d4f3155ffc905fd0c025d901ead3f6ed07385e19122c94 \ + --hash=sha256:b2d3337dcfaa99698aa2377c81c9ca72fcd89c07e7eb62ece3f23a3fe89b2ce4 \ + --hash=sha256:b489c36d1327868d207002391f662a1d163bdc8daf10ab2e5f6e41b9b96de3b1 \ + --hash=sha256:b641161c302efbb860ae6b081f406839a8b7d5573f20a455539823802c655f63 \ + --hash=sha256:b8ba29306c5de7717b5761b9ea74f9c72b9e2b834e24aa984da99cbfc70157fd \ + --hash=sha256:b9934adbd0f6e476f0ecff3c94626529f344f57b38c9a541f87098710b18af0a \ + --hash=sha256:ce85c43ae54845272f6f9cd8320d034d7a946e9773c693b27d620edec825e376 \ + --hash=sha256:cf868e08690cb89360eebc73ba4be7fb461cfbc6168dd88e2fbbe6f31812cd57 \ + --hash=sha256:d2905ce1df400360463c772b55d8e2518d0e488a87cdea13dd2c71dcb2a1fa16 \ + --hash=sha256:d57e20ba591727da0c230ab2c3f200ac9d6d333860d85348816e1dca4cc4792e \ + --hash=sha256:d6a8c9d4f8692917a3dc7eb25a6fb337bff86909febe2f793ec1928cd97bedfc \ + --hash=sha256:d923ff276f1c1f9680d32832f8d6c040fe9306cbfb5d161b0911e9634be9ef0a \ + --hash=sha256:daa7197b43c707462f06d2c693ffdbb5991cbb8b80b5b984007de431493a319c \ + --hash=sha256:dbd4c177afb8a8d9ba348d925b0b67246147af806f0b104af4d24f144d461cd5 \ + --hash=sha256:dc4d815b794fd8868c4d67602692c21bf5293a75e4b607bb92a11e821e2b859a \ + --hash=sha256:e9d21aaa84557d64209af04ff48e0ad5e28c5cca67ce43444e939579d085da72 \ + --hash=sha256:ea6b8aa9e08eea388c5f7a276fabb1d4b6b9d6e4ceb12cc477c3d352001768a9 \ + --hash=sha256:eabe7090db68c981fca689299c2d116400b553f4b713266b130cfc9e2aa9c5a9 \ + --hash=sha256:f2f6d303f3dee132b322a14cd8765287b8f86cdc10d2cb6a6fae234ea488888e \ + --hash=sha256:f33f3258aae89da191c6ebaa3bc517c6c4cbc9b9f689e5d8452f7aedbb913fa8 \ + --hash=sha256:f7bfb769f7efa0eefcd039dd19d843a4fbfbac52f1878b1da2ed5793ec9b1a65 \ + --hash=sha256:f89e21afe925fcfa655965ca8ea10f24773a1791400989ff32f467badfe4a064 \ + --hash=sha256:fa24255ae3c0ab67e613556375a4341af04a084bd58764731972bcbc8baeba36 # via sqlalchemy psycopg2-binary==2.9.9 \ --hash=sha256:03ef7df18daf2c4c07e2695e8cfd5ee7f748a1d54d802330985a78d2a5a6dca9 \ @@ -175,6 +170,7 @@ psycopg2-binary==2.9.9 \ --hash=sha256:4686818798f9194d03c9129a4d9a702d9e113a89cb03bffe08c6cf799e053291 \ --hash=sha256:57fede879f08d23c85140a360c6a77709113efd1c993923c59fde17aa27599fe \ --hash=sha256:60989127da422b74a04345096c10d416c2b41bd7bf2a380eb541059e4e999980 \ + --hash=sha256:64cf30263844fa208851ebb13b0732ce674d8ec6a0c86a4e160495d299ba3c93 \ --hash=sha256:68fc1f1ba168724771e38bee37d940d2865cb0f562380a1fb1ffb428b75cb692 \ --hash=sha256:6e6f98446430fdf41bd36d4faa6cb409f5140c1c2cf58ce0bbdaf16af7d3f119 \ --hash=sha256:729177eaf0aefca0994ce4cffe96ad3c75e377c7b6f4efa59ebf003b6d398716 \ @@ -184,6 +180,7 @@ psycopg2-binary==2.9.9 \ --hash=sha256:78151aa3ec21dccd5cdef6c74c3e73386dcdfaf19bced944169697d7ac7482fc \ --hash=sha256:7f01846810177d829c7692f1f5ada8096762d9172af1b1a28d4ab5b77c923c1c \ --hash=sha256:804d99b24ad523a1fe18cc707bf741670332f7c7412e9d49cb5eab67e886b9b5 \ + --hash=sha256:81ff62668af011f9a48787564ab7eded4e9fb17a4a6a74af5ffa6a457400d2ab \ --hash=sha256:8359bf4791968c5a78c56103702000105501adb557f3cf772b2c207284273984 \ --hash=sha256:83791a65b51ad6ee6cf0845634859d69a038ea9b03d7b26e703f94c7e93dbcf9 \ --hash=sha256:8532fd6e6e2dc57bcb3bc90b079c60de896d2128c5d9d6f24a63875a95a088cf \ diff --git a/tests/core/db/test.sh b/tests/core/db/test.sh index 9fcb5ebc4..0438121b1 100755 --- a/tests/core/db/test.sh +++ b/tests/core/db/test.sh @@ -64,6 +64,7 @@ else export GLOBAL_REVERSE_PROXY_HOST="http://app1:8080" export GLOBAL_REVERSE_PROXY_URL="/" export CUSTOM_CONF_MODSEC_test_custom_conf='SecRule REQUEST_FILENAME "@rx ^/db" "id:10000,ctl:ruleRemoveByTag=attack-generic,ctl:ruleRemoveByTag=attack-protocol,nolog"' + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/dnsbl/docker-compose.yml b/tests/core/dnsbl/docker-compose.yml index 390c89a46..c4d9b38dd 100644 --- a/tests/core/dnsbl/docker-compose.yml +++ b/tests/core/dnsbl/docker-compose.yml @@ -18,6 +18,15 @@ services: # ? DNSBL settings USE_DNSBL: "yes" DNSBL_LIST: "" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/dnsbl/init/requirements.txt b/tests/core/dnsbl/init/requirements.txt index 4b1787643..82436e5eb 100644 --- a/tests/core/dnsbl/init/requirements.txt +++ b/tests/core/dnsbl/init/requirements.txt @@ -28,9 +28,9 @@ idna==3.4 \ --hash=sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4 \ --hash=sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2 # via trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/dnsbl/main.py b/tests/core/dnsbl/main.py index 4e85c69b1..82df4df1f 100644 --- a/tests/core/dnsbl/main.py +++ b/tests/core/dnsbl/main.py @@ -11,13 +11,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}, timeout=3).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 or status_code == 403 + ready = status_code < 400 or status_code == 403 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/dnsbl/ready.conf b/tests/core/dnsbl/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/dnsbl/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/dnsbl/test.sh b/tests/core/dnsbl/test.sh index 4792b3184..3a51abbbe 100755 --- a/tests/core/dnsbl/test.sh +++ b/tests/core/dnsbl/test.sh @@ -36,6 +36,7 @@ else echo "DNSBL_LIST=" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/errors/docker-compose.yml b/tests/core/errors/docker-compose.yml index 582c512c2..48070e927 100644 --- a/tests/core/errors/docker-compose.yml +++ b/tests/core/errors/docker-compose.yml @@ -19,6 +19,15 @@ services: # ? ERRORS settings ERRORS: "" INTERCEPTED_ERROR_CODES: "400 401 403 404 405 413 429 500 501 502 503 504" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/errors/main.py b/tests/core/errors/main.py index 44cfb5d34..07e087387 100644 --- a/tests/core/errors/main.py +++ b/tests/core/errors/main.py @@ -14,13 +14,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/errors/ready.conf b/tests/core/errors/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/errors/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/errors/requirements.txt b/tests/core/errors/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/errors/requirements.txt +++ b/tests/core/errors/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/errors/test.sh b/tests/core/errors/test.sh index 6e4bda88f..7254ef596 100755 --- a/tests/core/errors/test.sh +++ b/tests/core/errors/test.sh @@ -33,6 +33,7 @@ else sudo touch /var/www/html/index.html sudo mkdir -p /var/www/html/errors sudo cp "403.html" "/var/www/html/errors/403.html" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/greylist/api/requirements.in b/tests/core/greylist/api/requirements.in index d7f6583eb..2ca0cca5b 100644 --- a/tests/core/greylist/api/requirements.in +++ b/tests/core/greylist/api/requirements.in @@ -1,2 +1,2 @@ -fastapi==0.104.0 +fastapi==0.104.1 uvicorn[standard]==0.23.2 diff --git a/tests/core/greylist/api/requirements.txt b/tests/core/greylist/api/requirements.txt index cab6b73ee..2e836e780 100644 --- a/tests/core/greylist/api/requirements.txt +++ b/tests/core/greylist/api/requirements.txt @@ -23,9 +23,9 @@ exceptiongroup==1.1.3 \ --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 # via anyio -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ diff --git a/tests/core/greylist/docker-compose.yml b/tests/core/greylist/docker-compose.yml index 5f76bf0f7..1cd2d4306 100644 --- a/tests/core/greylist/docker-compose.yml +++ b/tests/core/greylist/docker-compose.yml @@ -27,6 +27,15 @@ services: GREYLIST_USER_AGENT_URLS: "" GREYLIST_URI: "" GREYLIST_URI_URLS: "" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/greylist/main.py b/tests/core/greylist/main.py index 5d0be5113..f36023bcc 100644 --- a/tests/core/greylist/main.py +++ b/tests/core/greylist/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 or status_code == 403 + ready = status_code < 400 or status_code == 403 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/greylist/ready.conf b/tests/core/greylist/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/greylist/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/greylist/test.sh b/tests/core/greylist/test.sh index 3119b1b63..62ee838d2 100755 --- a/tests/core/greylist/test.sh +++ b/tests/core/greylist/test.sh @@ -55,6 +55,7 @@ else echo "GREYLIST_URI_URLS=" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/gzip/docker-compose.yml b/tests/core/gzip/docker-compose.yml index 129a793da..1287d13c5 100644 --- a/tests/core/gzip/docker-compose.yml +++ b/tests/core/gzip/docker-compose.yml @@ -4,6 +4,8 @@ services: bw: image: bunkerity/bunkerweb:1.5.3 pull_policy: never + ports: + - 80:8080 labels: - "bunkerweb.INSTANCE=yes" environment: @@ -18,6 +20,15 @@ services: # ? GZIP settings USE_GZIP: "no" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/gzip/main.py b/tests/core/gzip/main.py index 41f118dc9..267cfb18e 100644 --- a/tests/core/gzip/main.py +++ b/tests/core/gzip/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/gzip/ready.conf b/tests/core/gzip/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/gzip/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/gzip/test.sh b/tests/core/gzip/test.sh index e5cf9008b..e67cc6e93 100755 --- a/tests/core/gzip/test.sh +++ b/tests/core/gzip/test.sh @@ -30,6 +30,7 @@ else sudo systemctl stop bunkerweb echo "USE_GZIP=no" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/headers/docker-compose.yml b/tests/core/headers/docker-compose.yml index d06478936..c81ff90ef 100644 --- a/tests/core/headers/docker-compose.yml +++ b/tests/core/headers/docker-compose.yml @@ -32,6 +32,15 @@ services: X_FRAME_OPTIONS: "SAMEORIGIN" X_CONTENT_TYPE_OPTIONS: "nosniff" X_XSS_PROTECTION: "1; mode=block" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/headers/main.py b/tests/core/headers/main.py index 7648f2e3a..c4368a395 100644 --- a/tests/core/headers/main.py +++ b/tests/core/headers/main.py @@ -12,17 +12,19 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get( - f"http{'s' if ssl else ''}://www.example.com", + resp = get( + f"http{'s' if ssl else ''}://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False, - ).status_code + ) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/headers/ready.conf b/tests/core/headers/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/headers/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/headers/test.sh b/tests/core/headers/test.sh index 698ee4769..9e88706b0 100755 --- a/tests/core/headers/test.sh +++ b/tests/core/headers/test.sh @@ -48,6 +48,7 @@ else echo "X_FRAME_OPTIONS=SAMEORIGIN" | sudo tee -a /etc/bunkerweb/variables.env echo "X_CONTENT_TYPE_OPTIONS=nosniff" | sudo tee -a /etc/bunkerweb/variables.env echo "X_XSS_PROTECTION=1; mode=block" | sudo tee -a /etc/bunkerweb/variables.env + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/inject/docker-compose.yml b/tests/core/inject/docker-compose.yml index c226ee4ce..e45fb9661 100644 --- a/tests/core/inject/docker-compose.yml +++ b/tests/core/inject/docker-compose.yml @@ -17,6 +17,15 @@ services: # ? INJECT settings INJECT_BODY: "TEST" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/inject/main.py b/tests/core/inject/main.py index f13f8fdaf..e21b804f7 100644 --- a/tests/core/inject/main.py +++ b/tests/core/inject/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/inject/ready.conf b/tests/core/inject/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/inject/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/inject/test.sh b/tests/core/inject/test.sh index 381826ff9..de95fb3df 100755 --- a/tests/core/inject/test.sh +++ b/tests/core/inject/test.sh @@ -30,6 +30,7 @@ else sudo systemctl stop bunkerweb echo "INJECT_BODY=TEST" | sudo tee -a /etc/bunkerweb/variables.env sudo cp index.html /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi cleanup_stack () { diff --git a/tests/core/limit/docker-compose.yml b/tests/core/limit/docker-compose.yml index 710f5c38f..3f3e7c09e 100644 --- a/tests/core/limit/docker-compose.yml +++ b/tests/core/limit/docker-compose.yml @@ -22,6 +22,15 @@ services: LIMIT_REQ_RATE: "2r/s" USE_LIMIT_CONN: "yes" LIMIT_CONN_MAX_HTTP1: "1" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/limit/ready.conf b/tests/core/limit/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/limit/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/limit/test.sh b/tests/core/limit/test.sh index 12f33cabf..06eea97fb 100755 --- a/tests/core/limit/test.sh +++ b/tests/core/limit/test.sh @@ -35,6 +35,7 @@ else echo "USE_LIMIT_CONN=yes" | sudo tee -a /etc/bunkerweb/variables.env echo "LIMIT_CONN_MAX_HTTP1=1" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/misc/docker-compose.yml b/tests/core/misc/docker-compose.yml index d3b9aaedd..8522af235 100644 --- a/tests/core/misc/docker-compose.yml +++ b/tests/core/misc/docker-compose.yml @@ -29,6 +29,15 @@ services: HTTP2: "yes" LISTEN_HTTP: "yes" DENY_HTTP_STATUS: "403" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/misc/main.py b/tests/core/misc/main.py index c7ee48251..7177852d1 100644 --- a/tests/core/misc/main.py +++ b/tests/core/misc/main.py @@ -1,6 +1,7 @@ from os import getenv +from contextlib import suppress from subprocess import run -from requests import ConnectionError, get, head, post +from requests import RequestException, ConnectionError, get, head, post from socket import create_connection from ssl import CERT_NONE, create_default_context from time import sleep @@ -12,6 +13,28 @@ try: deny_http_status = getenv("DENY_HTTP_STATUS", "403") listen_http = getenv("LISTEN_HTTP", "yes") == "yes" + ready = False + retries = 0 + while not ready: + with suppress(RequestException): + resp = get(f"http{'s' if ssl_generated else ''}://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text + + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ The service took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for the service to be ready, retrying in 5s ...", flush=True) + sleep(5) + error = False print( diff --git a/tests/core/misc/ready.conf b/tests/core/misc/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/misc/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/misc/test.sh b/tests/core/misc/test.sh index d10a6d0f8..82c39e083 100755 --- a/tests/core/misc/test.sh +++ b/tests/core/misc/test.sh @@ -43,6 +43,7 @@ else echo "DENY_HTTP_STATUS=403" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/modsecurity/docker-compose.yml b/tests/core/modsecurity/docker-compose.yml index a69700208..32f38a069 100644 --- a/tests/core/modsecurity/docker-compose.yml +++ b/tests/core/modsecurity/docker-compose.yml @@ -21,6 +21,15 @@ services: MODSECURITY_SEC_AUDIT_ENGINE: "RelevantOnly" MODSECURITY_SEC_RULE_ENGINE: "On" MODSECURITY_SEC_AUDIT_LOG_PARTS: "ABCFHZ" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/modsecurity/main.py b/tests/core/modsecurity/main.py index daa8de416..6c183e4f3 100644 --- a/tests/core/modsecurity/main.py +++ b/tests/core/modsecurity/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/modsecurity/ready.conf b/tests/core/modsecurity/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/modsecurity/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/modsecurity/test.sh b/tests/core/modsecurity/test.sh index 86f26a6b6..23d9f8a84 100755 --- a/tests/core/modsecurity/test.sh +++ b/tests/core/modsecurity/test.sh @@ -34,6 +34,7 @@ else echo "MODSECURITY_SEC_RULE_ENGINE=On" | sudo tee -a /etc/bunkerweb/variables.env echo "MODSECURITY_SEC_AUDIT_LOG_PARTS=ABCFHZ" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/redirect/docker-compose.yml b/tests/core/redirect/docker-compose.yml index 4a7dac290..53a433c40 100644 --- a/tests/core/redirect/docker-compose.yml +++ b/tests/core/redirect/docker-compose.yml @@ -18,6 +18,15 @@ services: # ? REDIRECT settings REDIRECT_TO: "" REDIRECT_TO_REQUEST_URI: "no" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/redirect/main.py b/tests/core/redirect/main.py index 376f72293..3c96bcf64 100644 --- a/tests/core/redirect/main.py +++ b/tests/core/redirect/main.py @@ -12,13 +12,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/redirect/ready.conf b/tests/core/redirect/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/redirect/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/redirect/requirements.txt b/tests/core/redirect/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/redirect/requirements.txt +++ b/tests/core/redirect/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/redirect/test.sh b/tests/core/redirect/test.sh index 14770f07d..a92db2957 100755 --- a/tests/core/redirect/test.sh +++ b/tests/core/redirect/test.sh @@ -31,6 +31,7 @@ else echo "REDIRECT_TO=" | sudo tee -a /etc/bunkerweb/variables.env echo "REDIRECT_TO_REQUEST_URI=no" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/redis/docker-compose.yml b/tests/core/redis/docker-compose.yml index 19110582d..349873ce2 100644 --- a/tests/core/redis/docker-compose.yml +++ b/tests/core/redis/docker-compose.yml @@ -29,6 +29,15 @@ services: REDIS_PORT: "6379" REDIS_DATABASE: "0" REDIS_SSL: "no" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/redis/ready.conf b/tests/core/redis/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/redis/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/redis/requirements.in b/tests/core/redis/requirements.in index 256857c3f..6a8581f70 100644 --- a/tests/core/redis/requirements.in +++ b/tests/core/redis/requirements.in @@ -1,4 +1,4 @@ -fastapi==0.104.0 +fastapi==0.104.1 redis==5.0.1 requests==2.31.0 selenium==4.14.0 diff --git a/tests/core/redis/requirements.txt b/tests/core/redis/requirements.txt index e9a0d00d1..75abe229d 100644 --- a/tests/core/redis/requirements.txt +++ b/tests/core/redis/requirements.txt @@ -134,9 +134,9 @@ exceptiongroup==1.1.3 \ # anyio # trio # trio-websocket -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ @@ -189,9 +189,9 @@ idna==3.4 \ # anyio # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pydantic==2.4.2 \ --hash=sha256:94f336138093a5d7f426aac732dcfe7ab4eb4da243c88f891d65deb4a2556ee7 \ diff --git a/tests/core/redis/test.sh b/tests/core/redis/test.sh index 12d2abd7c..4d3695f72 100755 --- a/tests/core/redis/test.sh +++ b/tests/core/redis/test.sh @@ -83,6 +83,7 @@ else echo "REDIS_SSL=no" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/reversescan/docker-compose.yml b/tests/core/reversescan/docker-compose.yml index d9d095c8e..53cb8ae20 100644 --- a/tests/core/reversescan/docker-compose.yml +++ b/tests/core/reversescan/docker-compose.yml @@ -19,6 +19,15 @@ services: USE_REVERSE_SCAN: "yes" REVERSE_SCAN_PORTS: "80" REVERSE_SCAN_TIMEOUT: "500" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/reversescan/main.py b/tests/core/reversescan/main.py index 07ae72486..22f1b974a 100644 --- a/tests/core/reversescan/main.py +++ b/tests/core/reversescan/main.py @@ -6,6 +6,8 @@ from requests import get from multiprocessing import Process from traceback import format_exc from uvicorn import run +from contextlib import suppress +from requests.exceptions import RequestException fastapi_proc = None @@ -17,6 +19,28 @@ if getenv("TEST_TYPE", "docker") == "docker": sleep(1) try: + ready = False + retries = 0 + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text + + if status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 or status_code == 403 and text == "ready" + + if retries > 10: + print("❌ The service took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for the service to be ready, retrying in 5s ...", flush=True) + sleep(5) + use_reverse_scan = getenv("USE_REVERSE_SCAN", "yes") == "yes" reverse_scan_ports = getenv("REVERSE_SCAN_PORTS", "80") diff --git a/tests/core/reversescan/ready.conf b/tests/core/reversescan/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/reversescan/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/reversescan/requirements.in b/tests/core/reversescan/requirements.in index 85e290a27..97641feb9 100644 --- a/tests/core/reversescan/requirements.in +++ b/tests/core/reversescan/requirements.in @@ -1,3 +1,3 @@ -fastapi==0.104.0 +fastapi==0.104.1 requests==2.31.0 uvicorn[standard]==0.23.2 diff --git a/tests/core/reversescan/requirements.txt b/tests/core/reversescan/requirements.txt index 0ad634349..914ba9386 100644 --- a/tests/core/reversescan/requirements.txt +++ b/tests/core/reversescan/requirements.txt @@ -119,9 +119,9 @@ exceptiongroup==1.1.3 \ --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 # via anyio -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ diff --git a/tests/core/reversescan/test.sh b/tests/core/reversescan/test.sh index d06ec1769..cca6369ce 100755 --- a/tests/core/reversescan/test.sh +++ b/tests/core/reversescan/test.sh @@ -33,6 +33,7 @@ else echo "REVERSE_SCAN_TIMEOUT=500" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/selfsigned/docker-compose.yml b/tests/core/selfsigned/docker-compose.yml index ce94a16c5..ec5846ec2 100644 --- a/tests/core/selfsigned/docker-compose.yml +++ b/tests/core/selfsigned/docker-compose.yml @@ -20,6 +20,15 @@ services: GENERATE_SELF_SIGNED_SSL: "no" SELF_SIGNED_SSL_EXPIRY: "365" SELF_SIGNED_SSL_SUBJ: "/CN=www.example.com/" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/selfsigned/ready.conf b/tests/core/selfsigned/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/selfsigned/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/selfsigned/test.sh b/tests/core/selfsigned/test.sh index 3d341d662..8192ad86c 100755 --- a/tests/core/selfsigned/test.sh +++ b/tests/core/selfsigned/test.sh @@ -32,6 +32,7 @@ else echo "SELF_SIGNED_SSL_EXPIRY=365" | sudo tee -a /etc/bunkerweb/variables.env echo "SELF_SIGNED_SSL_SUBJ=/CN=www.example.com/" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/sessions/docker-compose.yml b/tests/core/sessions/docker-compose.yml index 5a778cbbe..45c728b47 100644 --- a/tests/core/sessions/docker-compose.yml +++ b/tests/core/sessions/docker-compose.yml @@ -19,6 +19,15 @@ services: # ? SESSIONS settings SESSIONS_SECRET: "random" SESSIONS_NAME: "random" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/sessions/main.py b/tests/core/sessions/main.py index 7acca5e05..1190594ca 100644 --- a/tests/core/sessions/main.py +++ b/tests/core/sessions/main.py @@ -13,13 +13,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 + ready = status_code < 400 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) @@ -76,22 +78,27 @@ try: print("❌ An error occurred when restarting BunkerWeb, exiting ...", flush=True) exit(1) + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("ℹ️ Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) print("ℹ️ Starting Firefox again ...", flush=True) with webdriver.Firefox(options=firefox_options) as driver: diff --git a/tests/core/sessions/ready.conf b/tests/core/sessions/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/sessions/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/sessions/requirements.txt b/tests/core/sessions/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/core/sessions/requirements.txt +++ b/tests/core/sessions/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/core/sessions/test.sh b/tests/core/sessions/test.sh index 453716167..590dd6785 100755 --- a/tests/core/sessions/test.sh +++ b/tests/core/sessions/test.sh @@ -33,6 +33,7 @@ else echo "SESSIONS_NAME=random" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/core/whitelist/api/requirements.in b/tests/core/whitelist/api/requirements.in index d7f6583eb..2ca0cca5b 100644 --- a/tests/core/whitelist/api/requirements.in +++ b/tests/core/whitelist/api/requirements.in @@ -1,2 +1,2 @@ -fastapi==0.104.0 +fastapi==0.104.1 uvicorn[standard]==0.23.2 diff --git a/tests/core/whitelist/api/requirements.txt b/tests/core/whitelist/api/requirements.txt index cab6b73ee..2e836e780 100644 --- a/tests/core/whitelist/api/requirements.txt +++ b/tests/core/whitelist/api/requirements.txt @@ -23,9 +23,9 @@ exceptiongroup==1.1.3 \ --hash=sha256:097acd85d473d75af5bb98e41b61ff7fe35efe6675e4f9370ec6ec5126d160e9 \ --hash=sha256:343280667a4585d195ca1cf9cef84a4e178c4b6cf2274caef9859782b567d5e3 # via anyio -fastapi==0.104.0 \ - --hash=sha256:456482c1178fb7beb2814b88e1885bc49f9a81f079665016feffe3e1c6a7663e \ - --hash=sha256:9c44de45693ae037b0c6914727a29c49a40668432b67c859a87851fc6a7b74c6 +fastapi==0.104.1 \ + --hash=sha256:752dc31160cdbd0436bb93bad51560b57e525cbb1d4bbf6f4904ceee75548241 \ + --hash=sha256:e5e4540a7c5e1dcfbbcf5b903c234feddcdcd881f191977a1c5dfd917487e7ae # via -r requirements.in h11==0.14.0 \ --hash=sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d \ diff --git a/tests/core/whitelist/docker-compose.yml b/tests/core/whitelist/docker-compose.yml index 81539fd55..ffad549c5 100644 --- a/tests/core/whitelist/docker-compose.yml +++ b/tests/core/whitelist/docker-compose.yml @@ -30,6 +30,15 @@ services: WHITELIST_USER_AGENT_URLS: "" WHITELIST_URI: "" WHITELIST_URI_URLS: "" + CUSTOM_CONF_SERVER_HTTP_ready: | + location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } + } networks: bw-universe: bw-services: diff --git a/tests/core/whitelist/main.py b/tests/core/whitelist/main.py index 7cf1de662..2aa0c7b00 100644 --- a/tests/core/whitelist/main.py +++ b/tests/core/whitelist/main.py @@ -10,13 +10,15 @@ try: retries = 0 while not ready: with suppress(RequestException): - status_code = get("http://www.example.com", headers={"Host": "www.example.com"}).status_code + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}) + status_code = resp.status_code + text = resp.text if status_code >= 500: print("❌ An error occurred with the server, exiting ...", flush=True) exit(1) - ready = status_code < 400 or status_code == 403 + ready = status_code < 400 or status_code == 403 and text == "ready" if retries > 10: print("❌ The service took too long to be ready, exiting ...", flush=True) diff --git a/tests/core/whitelist/ready.conf b/tests/core/whitelist/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/core/whitelist/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/core/whitelist/test.sh b/tests/core/whitelist/test.sh index 9997eead2..34f6b4cca 100755 --- a/tests/core/whitelist/test.sh +++ b/tests/core/whitelist/test.sh @@ -58,6 +58,7 @@ else echo "WHITELIST_URI_URLS=" | sudo tee -a /etc/bunkerweb/variables.env sudo touch /var/www/html/index.html export TEST_TYPE="linux" + sudo cp ready.conf /etc/bunkerweb/configs/server-http fi manual=0 diff --git a/tests/terraform/k8s.tf b/tests/terraform/k8s.tf index 129afffa0..30ba56ad0 100644 --- a/tests/terraform/k8s.tf +++ b/tests/terraform/k8s.tf @@ -15,7 +15,7 @@ resource "scaleway_k8s_cluster" "cluster" { version = "1.24.7" cni = "cilium" private_network_id = scaleway_vpc_private_network.pn.id - delete_additional_resources = false + delete_additional_resources = true } # Create k8s pool resource "scaleway_k8s_pool" "pool" { diff --git a/tests/terraform/providers.tf b/tests/terraform/providers.tf index be225a126..7f95ab487 100644 --- a/tests/terraform/providers.tf +++ b/tests/terraform/providers.tf @@ -2,7 +2,7 @@ terraform { required_providers { scaleway = { source = "scaleway/scaleway" - version = "2.30.0" + version = "2.31.0" } kubectl = { source = "gavinbunney/kubectl" diff --git a/tests/ui/main.py b/tests/ui/main.py index f788a69a6..53ece50f5 100644 --- a/tests/ui/main.py +++ b/tests/ui/main.py @@ -47,6 +47,7 @@ TEST_TYPE = getenv("TEST_TYPE", "docker") firefox_options = Options() if "geckodriver" not in listdir(Path.cwd()): firefox_options.add_argument("--headless") +firefox_options.log.level = "trace" print("Starting Firefox ...", flush=True) @@ -73,7 +74,7 @@ def assert_button_click(driver, button: Union[str, WebElement]): button.click() clicked = True - + return clicked def assert_alert_message(driver, message: str): safe_get_element(driver, By.XPATH, "//button[@data-flash-sidebar-open='']") @@ -126,20 +127,25 @@ def access_page( message: bool = True, *, retries: int = 0, + clicked: bool = False, ): - if retries == 0: - assert_button_click(driver, button) + if retries > 5: + print("Too many retries...", flush=True) + exit(1) try: + if not clicked: + clicked = assert_button_click(driver, button) + title = driver_wait.until(EC.presence_of_element_located((By.XPATH, "/html/body/div/header/div/nav/h6"))) if title.text != name.replace(" ", "_").title(): print(f"Didn't get redirected to {name} page, exiting ...", flush=True) exit(1) except TimeoutException: - if retries < 3 and "/loading" in driver.current_url: + if "/loading" in driver.current_url: sleep(2) - access_page(driver, driver_wait, button, name, message, retries=retries + 1) + return access_page(driver, driver_wait, button, name, message, retries=retries + 1, clicked=clicked) print(f"{name.title()} page didn't load in time, exiting ...", flush=True) exit(1) @@ -148,7 +154,7 @@ def access_page( print("Connection failure, retrying in 5s ...", flush=True) driver.refresh() sleep(5) - return access_page(driver, driver_wait, button, name, message, retries=1) + return access_page(driver, driver_wait, button, name, message, retries=retries + 1, clicked=clicked) raise we if message: @@ -158,15 +164,19 @@ def access_page( ) -driver_func = partial(webdriver.Firefox, options=firefox_options) +driver_func = partial( + webdriver.Firefox, + service=Service(log_output="./geckodriver.log"), + options=firefox_options + ) if TEST_TYPE == "dev": driver_func = partial( webdriver.Firefox, - service=Service(Service(executable_path="./geckodriver" if "geckodriver" in listdir(Path.cwd()) else "/usr/local/bin/geckodriver")), + service=Service(executable_path="./geckodriver" if "geckodriver" in listdir(Path.cwd()) else "/usr/local/bin/geckodriver", log_output="./geckodriver.log"), options=firefox_options, ) -with webdriver.Firefox(options=firefox_options) as driver: +with driver_func() as driver: try: driver.delete_all_cookies() driver.maximize_window() @@ -297,22 +307,27 @@ with webdriver.Firefox(options=firefox_options) as driver: print("WARNING: message list doesn't contain the expected message or is empty, retrying...") if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) print("Trying global config page ...") @@ -413,22 +428,27 @@ with webdriver.Firefox(options=firefox_options) as driver: ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) input_worker = safe_get_element(driver, By.ID, "WORKER_RLIMIT_NOFILE") @@ -577,22 +597,27 @@ with webdriver.Firefox(options=firefox_options) as driver: ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) print( "The page reloaded successfully, checking if the setting has been updated ...", @@ -656,22 +681,27 @@ with webdriver.Firefox(options=firefox_options) as driver: ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) try: services = safe_get_element( @@ -773,22 +803,27 @@ with webdriver.Firefox(options=firefox_options) as driver: ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) assert_alert_message(driver, "has been deleted.") @@ -856,22 +891,27 @@ location /hello { ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) assert_alert_message(driver, "was successfully created") @@ -916,22 +956,27 @@ location /hello { ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) assert_alert_message(driver, "was successfully deleted") @@ -996,22 +1041,27 @@ location /hello { ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) external_plugins = safe_get_element( driver, @@ -1040,22 +1090,27 @@ location /hello { ) if TEST_TYPE == "linux": + ready = False retries = 0 - while ( - b"BunkerWeb is ready" - not in run( - ["sudo", "tail", "-n", "1", "/var/log/bunkerweb/error.log"], - stdout=PIPE, - check=True, - ).stdout - ) and retries < 10: - retries += 1 - print("Waiting for BunkerWeb to be ready, retrying in 5s ...") - sleep(5) + while not ready: + with suppress(RequestException): + resp = get("http://www.example.com/ready", headers={"Host": "www.example.com"}, verify=False) + status_code = resp.status_code + text = resp.text - if retries >= 10: - print("BunkerWeb took too long to be ready, exiting ...", flush=True) - exit(1) + if resp.status_code >= 500: + print("❌ An error occurred with the server, exiting ...", flush=True) + exit(1) + + ready = status_code < 400 and text == "ready" + + if retries > 10: + print("❌ BunkerWeb took too long to be ready, exiting ...", flush=True) + exit(1) + elif not ready: + retries += 1 + print("⚠️ Waiting for BunkerWeb to be ready, retrying in 5s ...", flush=True) + sleep(5) with suppress(TimeoutException): title = WebDriverWait(driver, 2).until( diff --git a/tests/ui/ready.conf b/tests/ui/ready.conf new file mode 100644 index 000000000..c2f800ac6 --- /dev/null +++ b/tests/ui/ready.conf @@ -0,0 +1,8 @@ +location /ready { + default_type 'text/plain'; + rewrite_by_lua_block { + ngx.print('ready') + ngx.flush(true) + ngx.exit(ngx.HTTP_OK) + } +} \ No newline at end of file diff --git a/tests/ui/requirements.txt b/tests/ui/requirements.txt index dd857f945..5642b428d 100644 --- a/tests/ui/requirements.txt +++ b/tests/ui/requirements.txt @@ -124,9 +124,9 @@ idna==3.4 \ # via # requests # trio -outcome==1.3.0 \ - --hash=sha256:588ef4dc10b64e8df160d8d1310c44e1927129a66d6d2ef86845cef512c5f24c \ - --hash=sha256:7b688fd82db72f4b0bc9e883a00359d4d4179cd97d27f09c9644d0c842ba7786 +outcome==1.3.0.post0 \ + --hash=sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8 \ + --hash=sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b # via trio pysocks==1.7.1 \ --hash=sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299 \ diff --git a/tests/ui/tests.sh b/tests/ui/tests.sh index 30640c561..9d4ba536e 100755 --- a/tests/ui/tests.sh +++ b/tests/ui/tests.sh @@ -66,6 +66,8 @@ else sudo sed -i "/--bind \"127.0.0.1:7000\" &/c\ --bind \"127.0.0.1:7000\" --log-level debug &" /usr/share/bunkerweb/scripts/bunkerweb-ui.sh sudo mkdir /var/www/html/app1.example.com sudo touch /var/www/html/app1.example.com/index.html + sudo find /etc/bunkerweb/configs/ -type f -exec rm -f {} \; + sudo cp ready.conf /etc/bunkerweb/configs/server-http export TEST_TYPE="linux" fi @@ -160,6 +162,10 @@ if [ $? -ne 0 ] ; then sudo journalctl -u bunkerweb --no-pager echo "🛡️ Showing BunkerWeb UI journal logs ..." sudo journalctl -u bunkerweb-ui --no-pager + echo "🛡️ Showing BunkerWeb UI logs ..." + sudo cat /var/log/bunkerweb/ui.log + echo "🛡️ Showing BunkerWeb UI access logs ..." + sudo cat /var/log/bunkerweb/ui-access.log echo "🛡️ Showing BunkerWeb error logs ..." sudo cat /var/log/bunkerweb/error.log echo "🛡️ Showing BunkerWeb access logs ..."