diff options
419 files changed, 6282 insertions, 3473 deletions
diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index a85c2e8..706238d 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml | |||
| @@ -11,26 +11,26 @@ jobs: | |||
| 11 | strategy: | 11 | strategy: |
| 12 | matrix: | 12 | matrix: |
| 13 | container: | 13 | container: |
| 14 | - php:7.0 | 14 | - php:8.1 |
| 15 | - php:7.1 | ||
| 16 | - php:7.2 | ||
| 17 | - php:7.3 | ||
| 18 | - php:7.4 | ||
| 19 | - php:8.0 | 15 | - php:8.0 |
| 16 | - php:7.4 | ||
| 17 | - php:7.3 | ||
| 20 | container: ${{ matrix.container }} | 18 | container: ${{ matrix.container }} |
| 21 | steps: | 19 | steps: |
| 22 | - name: Checkout code | 20 | - name: Checkout code |
| 23 | uses: actions/checkout@v2 | 21 | uses: actions/checkout@v2 |
| 24 | - name: Install pecl | 22 | - name: PHP 7 env setup |
| 25 | if: startsWith(matrix.container, 'php:7') | 23 | if: startsWith(matrix.container, 'php:7') |
| 26 | run: pecl install vld-beta | 24 | run: | |
| 27 | - name: Remove php8 tests on php7 | 25 | pecl install vld-beta |
| 28 | if: startsWith(matrix.container, 'php:7') | 26 | rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt |
| 29 | run: rm -rf src/tests/*php8*/ | ||
| 30 | - name: Build and run the testsuite | 27 | - name: Build and run the testsuite |
| 31 | run: make tests | 28 | run: | |
| 29 | make release | ||
| 30 | ln -s $(php -r 'echo ini_get("extension_dir");')/* src/modules/ | ||
| 31 | rm -f src/tests/disable_function/*_signal.phpt | ||
| 32 | make tests | ||
| 32 | - name: Show logs in case of failure | 33 | - name: Show logs in case of failure |
| 33 | if: ${{ failure() }} | 34 | if: ${{ failure() }} |
| 34 | run: | | 35 | run: | |
| 35 | grep -r . ./src/tests/*/*.out | 36 | grep -r . --include='*.log' src/tests |
| 36 | grep -r . ./src/tests/*/*.diff | ||
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..7b3b6fd --- /dev/null +++ b/.github/workflows/codeql-analysis.yml | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | name: "CodeQL" | ||
| 2 | |||
| 3 | on: | ||
| 4 | push: | ||
| 5 | branches: [ master ] | ||
| 6 | pull_request: | ||
| 7 | # The branches below must be a subset of the branches above | ||
| 8 | branches: [ master ] | ||
| 9 | schedule: | ||
| 10 | - cron: '37 5 * * 3' | ||
| 11 | |||
| 12 | jobs: | ||
| 13 | analyze: | ||
| 14 | name: Analyze | ||
| 15 | runs-on: ubuntu-latest | ||
| 16 | container: php:latest | ||
| 17 | permissions: | ||
| 18 | actions: read | ||
| 19 | contents: read | ||
| 20 | security-events: write | ||
| 21 | |||
| 22 | strategy: | ||
| 23 | fail-fast: false | ||
| 24 | matrix: | ||
| 25 | language: [ 'cpp' ] | ||
| 26 | |||
| 27 | steps: | ||
| 28 | - name: Checkout repository | ||
| 29 | uses: actions/checkout@v2 | ||
| 30 | |||
| 31 | # Initializes the CodeQL tools for scanning. | ||
| 32 | - name: Initialize CodeQL | ||
| 33 | uses: github/codeql-action/init@v1 | ||
| 34 | with: | ||
| 35 | languages: ${{ matrix.language }} | ||
| 36 | # If you wish to specify custom queries, you can do so here or in a config file. | ||
| 37 | # By default, queries listed here will override any specified in a config file. | ||
| 38 | # Prefix the list here with "+" to use these queries and those in the config file. | ||
| 39 | # queries: ./path/to/local/query, your-org/your-repo/queries@main | ||
| 40 | |||
| 41 | - run: | | ||
| 42 | make release | ||
| 43 | |||
| 44 | - name: Perform CodeQL Analysis | ||
| 45 | uses: github/codeql-action/analyze@v1 | ||
diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml deleted file mode 100644 index d83aa9f..0000000 --- a/.github/workflows/coverity.yml +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | name: Coverity scan | ||
| 2 | on: | ||
| 3 | schedule: | ||
| 4 | - cron: '0 18 * * 1' # Weekly at 18:00 UTC on Mondays | ||
| 5 | |||
| 6 | jobs: | ||
| 7 | latest: | ||
| 8 | runs-on: ubuntu-latest | ||
| 9 | container: debian:stable | ||
| 10 | steps: | ||
| 11 | - name: Checkout code | ||
| 12 | uses: actions/checkout@v2 | ||
| 13 | - name: Install dependencies | ||
| 14 | run: | | ||
| 15 | apt update | ||
| 16 | DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends php-dev curl ca-certificates make gcc | ||
| 17 | - name: Remove php8 tests on php7 | ||
| 18 | run: rm -rf src/tests/*php8*/ | ||
| 19 | - name: Download Coverity Build Tool | ||
| 20 | run: | | ||
| 21 | curl https://scan.coverity.com/download/linux64 --form token=$TOKEN --form project=jvoisin/snuffleupagus -o cov-analysis-linux64.tar.gz | ||
| 22 | mkdir cov-analysis-linux64 | ||
| 23 | tar xzf cov-analysis-linux64.tar.gz --strip-components=1 -C cov-analysis-linux64 | ||
| 24 | env: | ||
| 25 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} | ||
| 26 | - name: Configure | ||
| 27 | run: cd src; phpize; ./configure --enable-snuffleupagus; cd - | ||
| 28 | - name: Build with cov-build | ||
| 29 | run: ./cov-analysis-linux64/bin/cov-build --dir cov-int make compile_debug | ||
| 30 | - name: Submit the result to Coverity Scan | ||
| 31 | run: | | ||
| 32 | tar czf snuffleupagus.tgz cov-int | ||
| 33 | curl \ | ||
| 34 | --form project=jvoisin/snuffleupagus \ | ||
| 35 | --form token=$TOKEN \ | ||
| 36 | --form file=@snuffleupagus.tgz \ | ||
| 37 | --form version=master \ | ||
| 38 | --form email=julien.voisin+coverity@dustri.org \ | ||
| 39 | --form description=master \ | ||
| 40 | https://scan.coverity.com/builds?project=jvoisin/snuffleupagus | ||
| 41 | env: | ||
| 42 | TOKEN: ${{ secrets.COVERITY_SCAN_TOKEN }} | ||
| 43 | |||
diff --git a/.github/workflows/distributions.yml b/.github/workflows/distributions.yml index bbfc8fc..18a8cce 100644 --- a/.github/workflows/distributions.yml +++ b/.github/workflows/distributions.yml | |||
| @@ -14,7 +14,7 @@ jobs: | |||
| 14 | - name: Checkout code | 14 | - name: Checkout code |
| 15 | uses: actions/checkout@v2 | 15 | uses: actions/checkout@v2 |
| 16 | - name: Remove php8 tests for php7 | 16 | - name: Remove php8 tests for php7 |
| 17 | run: rm -rf src/tests/*php8*/ | 17 | run: rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt src/tests/disable_function/*_signal.phpt |
| 18 | - name: Install dependencies | 18 | - name: Install dependencies |
| 19 | run: | | 19 | run: | |
| 20 | apt update | 20 | apt update |
| @@ -22,12 +22,11 @@ jobs: | |||
| 22 | - name: Install pecl | 22 | - name: Install pecl |
| 23 | run: pecl install vld-beta | 23 | run: pecl install vld-beta |
| 24 | - name: Build and run the testsuite | 24 | - name: Build and run the testsuite |
| 25 | run: make tests | 25 | run: make release tests |
| 26 | - name: Show logs in case of failure | 26 | - name: Show logs in case of failure |
| 27 | if: ${{ failure() }} | 27 | if: ${{ failure() }} |
| 28 | run: | | 28 | run: | |
| 29 | grep -r . ./src/tests/*/*.out | 29 | grep -r . --include='*.log' src/tests |
| 30 | grep -r . ./src/tests/*/*.diff | ||
| 31 | 30 | ||
| 32 | fedora: | 31 | fedora: |
| 33 | runs-on: ubuntu-latest | 32 | runs-on: ubuntu-latest |
| @@ -36,19 +35,18 @@ jobs: | |||
| 36 | - name: Checkout code | 35 | - name: Checkout code |
| 37 | uses: actions/checkout@v2 | 36 | uses: actions/checkout@v2 |
| 38 | - name: Remove php8 tests for php7 | 37 | - name: Remove php8 tests for php7 |
| 39 | run: rm -rf src/tests/*php8*/ | 38 | run: rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt src/tests/disable_function/*_signal.phpt |
| 40 | - name: Install dependencies | 39 | - name: Install dependencies |
| 41 | run: | | 40 | run: | |
| 42 | dnf install -y php-devel php-pear make | 41 | dnf install -y php-devel php-pear make |
| 43 | - name: Install pecl | 42 | - name: Install pecl |
| 44 | run: pecl install vld-beta | 43 | run: pecl install vld-beta |
| 45 | - name: Build and run the testsuite | 44 | - name: Build and run the testsuite |
| 46 | run: make tests | 45 | run: make release tests |
| 47 | - name: Show logs in case of failure | 46 | - name: Show logs in case of failure |
| 48 | if: ${{ failure() }} | 47 | if: ${{ failure() }} |
| 49 | run: | | 48 | run: | |
| 50 | grep -r . ./src/tests/*/*.out | 49 | grep -r . --include='*.log' src/tests |
| 51 | grep -r . ./src/tests/*/*.diff | ||
| 52 | 50 | ||
| 53 | ubuntu: | 51 | ubuntu: |
| 54 | runs-on: ubuntu-latest | 52 | runs-on: ubuntu-latest |
| @@ -57,7 +55,7 @@ jobs: | |||
| 57 | - name: Checkout code | 55 | - name: Checkout code |
| 58 | uses: actions/checkout@v2 | 56 | uses: actions/checkout@v2 |
| 59 | - name: Remove php8 tests for php7 | 57 | - name: Remove php8 tests for php7 |
| 60 | run: rm -rf src/tests/*php8*/ | 58 | run: rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt |
| 61 | - name: Install dependencies | 59 | - name: Install dependencies |
| 62 | run: | | 60 | run: | |
| 63 | apt update | 61 | apt update |
| @@ -69,8 +67,7 @@ jobs: | |||
| 69 | - name: Show logs in case of failure | 67 | - name: Show logs in case of failure |
| 70 | if: ${{ failure() }} | 68 | if: ${{ failure() }} |
| 71 | run: | | 69 | run: | |
| 72 | grep -r . ./src/tests/*/*.out | 70 | grep -r . --include='*.log' src/tests |
| 73 | grep -r . ./src/tests/*/*.diff | ||
| 74 | 71 | ||
| 75 | archlinux: | 72 | archlinux: |
| 76 | runs-on: ubuntu-latest | 73 | runs-on: ubuntu-latest |
| @@ -79,7 +76,7 @@ jobs: | |||
| 79 | - name: Checkout code | 76 | - name: Checkout code |
| 80 | uses: actions/checkout@v2 | 77 | uses: actions/checkout@v2 |
| 81 | - name: Remove php8 tests for php7 | 78 | - name: Remove php8 tests for php7 |
| 82 | run: rm -rf src/tests/*php8*/ | 79 | run: rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt |
| 83 | - name: Install dependencies | 80 | - name: Install dependencies |
| 84 | continue-on-error: true | 81 | continue-on-error: true |
| 85 | run: | | 82 | run: | |
| @@ -89,37 +86,60 @@ jobs: | |||
| 89 | - name: Install pecl | 86 | - name: Install pecl |
| 90 | continue-on-error: true | 87 | continue-on-error: true |
| 91 | run: pecl install vld-beta | 88 | run: pecl install vld-beta |
| 92 | - name: Build and run the testsuite | 89 | - name: Build SP and run the testsuite |
| 93 | continue-on-error: true | 90 | continue-on-error: true |
| 94 | run: make tests | 91 | run: make tests |
| 95 | - name: Show logs in case of failure | 92 | - name: Show logs in case of failure |
| 96 | continue-on-error: true | 93 | continue-on-error: true |
| 97 | if: ${{ failure() }} | 94 | if: ${{ failure() }} |
| 98 | run: | | 95 | run: | |
| 99 | grep -r . ./src/tests/*/*.out | 96 | grep -r . --include='*.log' src/tests |
| 100 | grep -r . ./src/tests/*/*.diff | ||
| 101 | 97 | ||
| 102 | alpine: | 98 | alpine: |
| 103 | runs-on: ubuntu-latest | 99 | runs-on: ubuntu-latest |
| 104 | container: alpine:edge | 100 | container: alpine:latest |
| 105 | steps: | 101 | steps: |
| 106 | - name: Checkout code | 102 | - name: Checkout code |
| 107 | uses: actions/checkout@v2 | 103 | uses: actions/checkout@v2 |
| 108 | - name: Remove php8 tests for php7 | 104 | - name: Remove php8 tests for php7 |
| 109 | run: rm -rf src/tests/*php8*/ | 105 | run: rm -rf src/tests/*php8*/ src/tests/*/*_php8.phpt |
| 110 | - name: Remove tests failing on alpine for wathever reason | 106 | - name: Remove tests failing on alpine for wathever reason |
| 111 | run: rm -rf src/tests/*session*/ src/tests/broken_configuration/ src/tests/*cookie* src/tests/upload_validation/ | 107 | run: rm -rf src/tests/cookies_encryption_warning src/tests/upload_validation/upload_validation.phpt /tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt |
| 112 | - name: Install dependencies | 108 | - name: Install dependencies |
| 113 | run: apk add php7-dev php7-cgi php7-simplexml php7-xml pcre-dev build-base php7-pear php7-openssl | 109 | run: apk add php7-dev php7-cgi php7-simplexml php7-xml pcre-dev build-base php7-pear php7-openssl php7-session bash grep |
| 114 | - name: Install pecl | 110 | - name: Install pecl |
| 115 | continue-on-error: true | 111 | continue-on-error: true |
| 116 | run: pecl install vld-beta | 112 | run: pecl install vld-beta |
| 117 | - name: Build and run the testsuite | 113 | - name: Build SP and run the testsuite |
| 118 | continue-on-error: true | 114 | run: | |
| 119 | run: make tests | 115 | make release |
| 116 | ln -s $(php -r 'echo ini_get("extension_dir");')/* src/modules/ | ||
| 117 | make tests | ||
| 120 | - name: Show logs in case of failure | 118 | - name: Show logs in case of failure |
| 121 | if: ${{ failure() }} | 119 | if: ${{ failure() }} |
| 120 | run: | | ||
| 121 | grep -r . --include='*.log' src/tests | ||
| 122 | |||
| 123 | ## PHP 8 | ||
| 124 | alpine_php8: | ||
| 125 | runs-on: ubuntu-latest | ||
| 126 | container: alpine:edge | ||
| 127 | steps: | ||
| 128 | - name: Checkout code | ||
| 129 | uses: actions/checkout@v2 | ||
| 130 | - name: Remove tests failing on alpine for wathever reason | ||
| 131 | run: rm -rf src/tests/cookies_encryption_warning src/tests/upload_validation/upload_validation.phpt | ||
| 132 | - name: Install dependencies | ||
| 133 | run: apk add php8-dev php8-cgi php8-simplexml php8-xml pcre-dev build-base php8-pear php8-openssl php8-session php8-curl bash grep | ||
| 134 | - name: Install pecl | ||
| 122 | continue-on-error: true | 135 | continue-on-error: true |
| 136 | run: pecl install vld-beta | ||
| 137 | - name: Build SP and run the testsuite | ||
| 138 | run: | | ||
| 139 | make release | ||
| 140 | ln -s $(php -r 'echo ini_get("extension_dir");')/* src/modules/ | ||
| 141 | make tests | ||
| 142 | - name: Show logs in case of failure | ||
| 143 | if: ${{ failure() }} | ||
| 123 | run: | | 144 | run: | |
| 124 | grep -r . ./src/tests/*/*.out | 145 | grep -r . --include='*.log' src/tests |
| 125 | grep -r . ./src/tests/*/*.diff | ||
| @@ -19,6 +19,12 @@ src/tests/*/*.log | |||
| 19 | src/tests/*/*.out | 19 | src/tests/*/*.out |
| 20 | src/tests/*/*.sh | 20 | src/tests/*/*.sh |
| 21 | src/tests/*/*.php | 21 | src/tests/*/*.php |
| 22 | src/tests/*/phpt.* | ||
| 23 | |||
| 24 | .vscode/ | ||
| 25 | |||
| 26 | # generated by re2c or copied from cached version | ||
| 27 | src/sp_config_scanner.c | ||
| 22 | # Files generated by phpize, configure and make | 28 | # Files generated by phpize, configure and make |
| 23 | src/autom4te.cache | 29 | src/autom4te.cache |
| 24 | src/build | 30 | src/build |
| @@ -45,4 +51,5 @@ src/Makefile.objects | |||
| 45 | src/missing | 51 | src/missing |
| 46 | src/mkinstalldirs | 52 | src/mkinstalldirs |
| 47 | src/run-tests.php | 53 | src/run-tests.php |
| 54 | src/*.dep | ||
| 48 | doc/build/ | 55 | doc/build/ |
| @@ -1,44 +1,61 @@ | |||
| 1 | .DEFAULT_GOAL=help | 1 | .DEFAULT_GOAL=help |
| 2 | .PHONY=help | 2 | .PHONY=help |
| 3 | SHELL = /bin/bash | ||
| 4 | |||
| 5 | SRC := src | ||
| 3 | 6 | ||
| 4 | clean: ## clean everything | 7 | clean: ## clean everything |
| 5 | make -C src clean | 8 | make -C $(SRC) clean |
| 6 | cd src; phpize --clean | 9 | cd $(SRC); phpize --clean |
| 7 | 10 | ||
| 8 | release: ## compile with releases flags | 11 | release: ## compile with releases flags |
| 9 | cd src; phpize | 12 | cd $(SRC); phpize |
| 10 | cd src; ./configure --enable-snuffleupagus | 13 | cd $(SRC); ./configure --enable-snuffleupagus |
| 11 | make -C src | 14 | make -C $(SRC) |
| 12 | 15 | ||
| 13 | install: release ## compile and install snuffleupagus | 16 | install: release ## compile and install snuffleupagus |
| 14 | make -C src install | 17 | make -C $(SRC) install |
| 15 | 18 | ||
| 16 | compile_debug: ## compile a debug build | 19 | compile_debug: ## compile a debug build |
| 17 | cd src; phpize | 20 | cd $(SRC); if [[ ! -f configure ]]; then phpize; fi; \ |
| 18 | export CFLAGS="-g3 -ggdb -O1 -g"; cd src; ./configure --enable-snuffleupagus --enable-debug | 21 | ./configure --enable-snuffleupagus --enable-debug --enable-debug-stderr && \ |
| 19 | make -C src | 22 | make clean ; make -j4 |
| 23 | |||
| 24 | DOCKER_IMAGE := php:latest | ||
| 25 | docker: ## start docker container with current PHP | ||
| 26 | @echo "Starting new docker container with snuffleupagus bind-mounted to /sp" | ||
| 27 | docker run -it -v "$$(pwd)":/sp $(DOCKER_IMAGE) /bin/bash | ||
| 28 | |||
| 29 | linked-clone: | ||
| 30 | @if [[ "$(CLONE)" == "" ]]; then echo -e "==> Please provide clone name, e.g.\n make linked-clone CLONE=php8.1\n"; exit 1; fi | ||
| 31 | @if [[ -d "src-$(CLONE)" ]]; then echo -e "==> Clone '$(CLONE)' already exists.\n"; exit 1; fi | ||
| 32 | @echo "==> CREATING LINKED CLONE IN 'src-$(CLONE)' <==" | ||
| 33 | mkdir "src-$(CLONE)"; cd "src-$(CLONE)"; \ | ||
| 34 | SRCDIR=../src; ln -s $$SRCDIR/*.[hc] $$SRCDIR/config.m4 $$SRCDIR/snuffleupagus.php $$SRCDIR/Makefile.frag $$SRCDIR/*.re .; \ | ||
| 35 | cp -r $$SRCDIR/tests . | ||
| 36 | @echo -e "==> DONE. <==\nCompile a debug build with\n make compile_debug SRC=src-$(CLONE)" | ||
| 20 | 37 | ||
| 21 | tests: release ## compile a release build and run the testsuite | 38 | tests: release ## compile a release build and run the testsuite |
| 22 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test | 39 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 SP_SKIP_OLD_PHP_CHECK=1 make -C $(SRC) test |
| 23 | 40 | ||
| 24 | coverage: ## compile snuffleugpaus, and run the testsuite with coverage | 41 | coverage: ## compile snuffleugpaus, and run the testsuite with coverage |
| 25 | cd src; phpize | 42 | cd $(SRC); phpize |
| 26 | ifeq ($(CC),clang) | 43 | ifeq ($(CC),clang) |
| 27 | cd src; CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus | 44 | cd $(SRC); CFLAGS="-fprofile-instr-generate -fcoverage-mapping" ./configure --enable-snuffleupagus |
| 28 | make -C src | 45 | make -C $(SRC) |
| 29 | sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" src/run-tests.php | 46 | sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" $(SRC)/run-tests.php |
| 30 | LLVM_PROFILE_FILE="sp_%p_%m.profraw" TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test | 47 | LLVM_PROFILE_FILE="sp_%p_%m.profraw" TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C $(SRC) test |
| 31 | llvm-profdata-4.0 merge ./src/*.profraw -o ./src/sp.profdata | 48 | llvm-profdata-4.0 merge ./$(SRC)/*.profraw -o ./$(SRC)/sp.profdata |
| 32 | llvm-cov report -instr-profile=./src/sp.profdata ./src/modules/snuffleupagus.so | 49 | llvm-cov report -instr-profile=./$(SRC)/sp.profdata ./$(SRC)/modules/snuffleupagus.so |
| 33 | else | 50 | else |
| 34 | cd src; ./configure --enable-snuffleupagus --enable-coverage | 51 | cd $(SRC); ./configure --enable-snuffleupagus --enable-coverage |
| 35 | make -C src | 52 | make -C $(SRC) |
| 36 | rm -Rf src/COV.html | 53 | rm -Rf $(SRC)/COV.html |
| 37 | sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" src/run-tests.php | 54 | sed -i "s/\$$ext_params -d display_errors=0 -r/-d display_errors=0 -r/" $(SRC)/run-tests.php |
| 38 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C src test | 55 | TEST_PHP_ARGS='-q' REPORT_EXIT_STATUS=1 make -C $(SRC) test |
| 39 | lcov --base-directory ./src --directory ./src -c -o ./src/COV.info --rc lcov_branch_coverage=1 | 56 | lcov --base-directory ./$(SRC) --directory ./$(SRC) -c -o ./$(SRC)/COV.info --rc lcov_branch_coverage=1 |
| 40 | lcov --remove src/COV.info '/usr/*' --remove src/COV.info '*tweetnacl.c' -o src/COV.info --rc lcov_branch_coverage=1 | 57 | lcov --remove $(SRC)/COV.info '/usr/*' --remove $(SRC)/COV.info '*tweetnacl.c' -o $(SRC)/COV.info --rc lcov_branch_coverage=1 |
| 41 | genhtml --show-details -o src/COV.html ./src/COV.info --branch-coverage | 58 | genhtml --show-details -o $(SRC)/COV.html ./$(SRC)/COV.info --branch-coverage |
| 42 | endif | 59 | endif |
| 43 | 60 | ||
| 44 | bench: joomla ## run the benchmark | 61 | bench: joomla ## run the benchmark |
| @@ -49,7 +66,7 @@ joomla: | |||
| 49 | fi | 66 | fi |
| 50 | cd joomla-cms; composer install >/dev/null 2>/dev/null | 67 | cd joomla-cms; composer install >/dev/null 2>/dev/null |
| 51 | echo "\nWith snuffleupagus:" | 68 | echo "\nWith snuffleupagus:" |
| 52 | cd joomla-cms; time php -d "extension=../src/modules/snuffleupagus.so" -d "sp.configuration_file=../config/default.rules" libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null | 69 | cd joomla-cms; time php -d "extension=../$(SRC)/modules/snuffleupagus.so" -d "sp.configuration_file=../config/default.rules" libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null |
| 53 | echo "\nWithout snuffleupagus:" | 70 | echo "\nWithout snuffleupagus:" |
| 54 | cd joomla-cms; time php libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null | 71 | cd joomla-cms; time php libraries/vendor/phpunit/phpunit/phpunit --no-coverage >/dev/null |
| 55 | 72 | ||
diff --git a/PHP_LICENSE b/PHP_LICENSE new file mode 100644 index 0000000..4076fe9 --- /dev/null +++ b/PHP_LICENSE | |||
| @@ -0,0 +1,68 @@ | |||
| 1 | -------------------------------------------------------------------- | ||
| 2 | The PHP License, version 3.01 | ||
| 3 | Copyright (c) 1999 - 2019 The PHP Group. All rights reserved. | ||
| 4 | -------------------------------------------------------------------- | ||
| 5 | |||
| 6 | Redistribution and use in source and binary forms, with or without | ||
| 7 | modification, is permitted provided that the following conditions | ||
| 8 | are met: | ||
| 9 | |||
| 10 | 1. Redistributions of source code must retain the above copyright | ||
| 11 | notice, this list of conditions and the following disclaimer. | ||
| 12 | |||
| 13 | 2. Redistributions in binary form must reproduce the above copyright | ||
| 14 | notice, this list of conditions and the following disclaimer in | ||
| 15 | the documentation and/or other materials provided with the | ||
| 16 | distribution. | ||
| 17 | |||
| 18 | 3. The name "PHP" must not be used to endorse or promote products | ||
| 19 | derived from this software without prior written permission. For | ||
| 20 | written permission, please contact group@php.net. | ||
| 21 | |||
| 22 | 4. Products derived from this software may not be called "PHP", nor | ||
| 23 | may "PHP" appear in their name, without prior written permission | ||
| 24 | from group@php.net. You may indicate that your software works in | ||
| 25 | conjunction with PHP by saying "Foo for PHP" instead of calling | ||
| 26 | it "PHP Foo" or "phpfoo" | ||
| 27 | |||
| 28 | 5. The PHP Group may publish revised and/or new versions of the | ||
| 29 | license from time to time. Each version will be given a | ||
| 30 | distinguishing version number. | ||
| 31 | Once covered code has been published under a particular version | ||
| 32 | of the license, you may always continue to use it under the terms | ||
| 33 | of that version. You may also choose to use such covered code | ||
| 34 | under the terms of any subsequent version of the license | ||
| 35 | published by the PHP Group. No one other than the PHP Group has | ||
| 36 | the right to modify the terms applicable to covered code created | ||
| 37 | under this License. | ||
| 38 | |||
| 39 | 6. Redistributions of any form whatsoever must retain the following | ||
| 40 | acknowledgment: | ||
| 41 | "This product includes PHP software, freely available from | ||
| 42 | <http://www.php.net/software/>". | ||
| 43 | |||
| 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND | ||
| 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
| 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
| 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP | ||
| 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
| 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
| 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
| 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
| 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
| 55 | OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| 56 | |||
| 57 | -------------------------------------------------------------------- | ||
| 58 | |||
| 59 | This software consists of voluntary contributions made by many | ||
| 60 | individuals on behalf of the PHP Group. | ||
| 61 | |||
| 62 | The PHP Group can be contacted via Email at group@php.net. | ||
| 63 | |||
| 64 | For more information on the PHP Group and the PHP project, | ||
| 65 | please see <http://www.php.net>. | ||
| 66 | |||
| 67 | PHP includes the Zend Engine, freely available at | ||
| 68 | <http://www.zend.com>. | ||
| @@ -1,125 +1,21 @@ | |||
| 1 | <h1 align="center"> | 1 |  |
| 2 | <br> | 2 |  |
| 3 | <a href="https://snuffleupagus.readthedocs.io/"> | 3 |  |
| 4 | <img src="https://github.com/jvoisin/snuffleupagus/raw/master/doc/source/_static/sp.png" alt="Snuffleupagus' logo" width="200"></a> | ||
| 5 | <br> | ||
| 6 | Snuffleupagus | ||
| 7 | <br> | ||
| 8 | </h1> | ||
| 9 | |||
| 10 | <h4 align="center">Security module for php7 and php8 - Killing bugclasses and virtual-patching the rest!</h4> | ||
| 11 | 4 | ||
| 12 | <p align="center"> | 5 | <p align="center"> |
| 13 | <a href="https://github.com/jvoisin/snuffleupagus/actions?query=workflow%3A%22CI+for+linux+distributions%22"> | 6 | <img src="https://github.com/sektioneins/snuffleupagus/blob/master/doc/source/_static/sp.png" alt="Snuffleupagus logo" width="200"> |
| 14 | <img src="https://github.com/jvoisin/snuffleupagus/workflows/CI%20for%20linux%20distributions/badge.svg" | ||
| 15 | alt="github actions testing _all_ distributions" /> | ||
| 16 | </a> | ||
| 17 | <a href="https://github.com/jvoisin/snuffleupagus/actions?query=workflow%3A%22CI+for+php+versions%22"> | ||
| 18 | <img src="https://github.com/jvoisin/snuffleupagus/workflows/CI%20for%20php%20versions/badge.svg" | ||
| 19 | alt="github actions testing _all_ php versions" /> | ||
| 20 | </a> | ||
| 21 | <a href="https://scan.coverity.com/projects/jvoisin-snuffleupagus"> | ||
| 22 | <img src="https://scan.coverity.com/projects/13821/badge.svg?flat=1" | ||
| 23 | alt="Coverity"> | ||
| 24 | </a> | ||
| 25 | <a href="https://bestpractices.coreinfrastructure.org/projects/1267"> | ||
| 26 | <img src="https://bestpractices.coreinfrastructure.org/projects/1267/badge" | ||
| 27 | alt="CII Best Practises"> | ||
| 28 | </a> | ||
| 29 | <a href="http://snuffleupagus.readthedocs.io/?badge=latest"> | ||
| 30 | <img src="https://readthedocs.org/projects/snuffleupagus/badge/?version=latest" | ||
| 31 | alt="readthedocs.org"> | ||
| 32 | </a> | ||
| 33 | <a href="https://coveralls.io/github/jvoisin/snuffleupagus?branch=master"> | ||
| 34 | <img src="https://coveralls.io/repos/github/jvoisin/snuffleupagus/badge.svg?branch=master" | ||
| 35 | alt="coveralls"> | ||
| 36 | </a> | ||
| 37 | <a href="https://twitter.com/sp_php"> | ||
| 38 | <img src="https://img.shields.io/badge/twitter-follow-blue.svg" | ||
| 39 | alt="twitter"> | ||
| 40 | </a> | ||
| 41 | <a href="https://repology.org/project/php:snuffleupagus/versions"> | ||
| 42 | <img src="https://repology.org/badge/tiny-repos/php:snuffleupagus.svg" | ||
| 43 | alt="Packaging status"> | ||
| 44 | </a> | ||
| 45 | </p> | ||
| 46 | 7 | ||
| 47 | <p align="center"> | 8 | # Snuffleupagus fork with Suhosin-NG patches |
| 48 | <a href="#key-features">Key Features</a> • | 9 | |
| 49 | <a href="#download">Download</a> • | ||
| 50 | <a href="#examples">Examples</a> • | ||
| 51 | <a href="https://snuffleupagus.readthedocs.io/">Documentation</a> • | ||
| 52 | <a href="https://github.com/jvoisin/snuffleupagus/blob/master/LICENSE">License</a> • | ||
| 53 | <a href="#thanks">Thanks</a> | ||
| 54 | </p> | 10 | </p> |
| 55 | 11 | ||
| 56 | Snuffleupagus is a [PHP 7+ and 8+](https://secure.php.net/) module designed to | ||
| 57 | drastically raise the cost of attacks against websites, by killing entire bug | ||
| 58 | classes. It also provides a powerful virtual-patching system, allowing | ||
| 59 | administrator to fix specific vulnerabilities and audit suspicious behaviours | ||
| 60 | without having to touch the PHP code. | ||
| 61 | |||
| 62 | ## Key Features | ||
| 63 | |||
| 64 | * No [noticeable performance impact](https://dustri.org/b/snuffleupagus-030-dentalium-elephantinum.html) | ||
| 65 | * Powerful yet simple to write virtual-patching rules | ||
| 66 | * Killing several classes of vulnerabilities | ||
| 67 | * [Unserialize-based](https://www.owasp.org/images/9/9e/Utilizing-Code-Reuse-Or-Return-Oriented-Programming-In-PHP-Application-Exploits.pdf) code execution | ||
| 68 | * [`mail`-based]( https://blog.ripstech.com/2016/roundcube-command-execution-via-email/ ) code execution | ||
| 69 | * Cookie-stealing [XSS]( https://en.wikipedia.org/wiki/Cross-site_scripting ) | ||
| 70 | * File-upload based code execution | ||
| 71 | * Weak PRNG | ||
| 72 | * [XXE]( https://en.wikipedia.org/wiki/XML_external_entity_attack ) | ||
| 73 | * Several hardening features | ||
| 74 | * Automatic `secure` and `samesite` flag for cookies | ||
| 75 | * Bundled set of rules to detect post-compromissions behaviours | ||
| 76 | * Global [strict mode]( https://secure.php.net/manual/en/migration70.new-features.php#migration70.new-features.scalar-type-declarations) and type-juggling prevention | ||
| 77 | * Whitelisting of [stream wrappers](https://secure.php.net/manual/en/intro.stream.php) | ||
| 78 | * Preventing writeable files execution | ||
| 79 | * Whitelist/blacklist for `eval` | ||
| 80 | * Enforcing TLS certificate validation when using [curl](https://secure.php.net/manual/en/book.curl.php) | ||
| 81 | * Request dumping capability | ||
| 82 | * A relatively sane code base: | ||
| 83 | * A [comprehensive](https://coveralls.io/github/jvoisin/snuffleupagus?branch=master) test suite close to 100% coverage | ||
| 84 | * Every commit is tested on [several distributions](https://gitlab.com/jvoisin/snuffleupagus/pipelines) | ||
| 85 | * An `clang-format`-enforced code style | ||
| 86 | * A [comprehensive documentation](https://snuffleupagus.rtfd.io) | ||
| 87 | * Usage of [coverity](https://scan.coverity.com/projects/jvoisin-snuffleupagus) | ||
| 88 | |||
| 89 | ## Download | ||
| 90 | |||
| 91 | We've got a [download | ||
| 92 | page](https://snuffleupagus.readthedocs.io/download.html), where you can find | ||
| 93 | packages for your distribution, but you can of course just `git clone` this | ||
| 94 | repo, or check the releases on [github](https://github.com/jvoisin/snuffleupagus/releases). | ||
| 95 | |||
| 96 | ## Examples | ||
| 97 | |||
| 98 | We're providing [various example rules](https://github.com/jvoisin/snuffleupagus/tree/master/config), | ||
| 99 | that are looking like this: | ||
| 100 | |||
| 101 | ```python | ||
| 102 | # Harden the `chmod` function | ||
| 103 | sp.disable_function.function("chmod").param("mode").value_r("^[0-9]{2}[67]$").drop(); | ||
| 104 | |||
| 105 | # Mitigate command injection in `system` | ||
| 106 | sp.disable_function.function("system").param("command").value_r("[$|;&`\\n]").drop(); | ||
| 107 | ``` | ||
| 108 | |||
| 109 | Upon violation of a rule, you should see lines like this in your logs: | ||
| 110 | 12 | ||
| 111 | ```python | 13 | ## About Snuffleupagus |
| 112 | [snuffleupagus][0.0.0.0][disabled_function][drop] The execution has been aborted in /var/www/index.php:2, because the return value (0) of the function 'strpos' matched a rule. | ||
| 113 | ``` | ||
| 114 | 14 | ||
| 115 | ## Documentation | 15 | Snuffleupagus is a marvellous security module for PHP 7 and PHP 8. This repository is a fork of the [original Snuffleupagus repository](https://github.com/jvoisin/snuffleupagus) used for **development and testing** of **new and experimental features**. It can be seen as the **beta version** of the Snuffleupagus PHP extension, showcasing new ideas, with the aim to eventually be ported back upstream to the original repository. |
| 116 | 16 | ||
| 117 | We've got a [comprehensive website](https://snuffleupagus.readthedocs.io/) with | 17 | ## About Suhosin-NG |
| 118 | all the documentation that you could possibly wish for. You can of course | ||
| 119 | [build it yourself](https://github.com/jvoisin/snuffleupagus/tree/master/doc). | ||
| 120 | 18 | ||
| 121 | ## Thanks | 19 |  |
| 122 | 20 | ||
| 123 | Many thanks to the [Suhosin project](https://suhosin.org) for being a __huge__ | 21 | The [Suhosin-NG project](https://github.com/sektioneins/suhosin-ng) is an effort to advance PHP hardening by providing patches to Snuffleupagus, documentation and its own [set of tools](https://github.com/sektioneins/sng-tools). |
| 124 | source of inspiration, and to all [our | ||
| 125 | contributors](https://github.com/jvoisin/snuffleupagus/graphs/contributors). | ||
diff --git a/config/default.rules b/config/default.rules index caa14c0..f6d8893 100644 --- a/config/default.rules +++ b/config/default.rules | |||
| @@ -6,8 +6,10 @@ | |||
| 6 | # Harden the PRNG | 6 | # Harden the PRNG |
| 7 | sp.harden_random.enable(); | 7 | sp.harden_random.enable(); |
| 8 | 8 | ||
| 9 | # Disabled XXE | 9 | # Enable XXE protection |
| 10 | sp.disable_xxe.enable(); | 10 | @condition extension_loaded("xml"); |
| 11 | sp.xxe_protection.enable(); | ||
| 12 | @end_condition; | ||
| 11 | 13 | ||
| 12 | # Global configuration variables | 14 | # Global configuration variables |
| 13 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); | 15 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); |
diff --git a/config/default_php8.rules b/config/default_php8.rules index 2251f2f..6d6b88e 100644 --- a/config/default_php8.rules +++ b/config/default_php8.rules | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | sp.harden_random.enable(); | 8 | sp.harden_random.enable(); |
| 9 | 9 | ||
| 10 | # Disabled XXE | 10 | # Disabled XXE |
| 11 | sp.disable_xxe.enable(); | 11 | sp.xxe_protection.enable(); |
| 12 | 12 | ||
| 13 | # Global configuration variables | 13 | # Global configuration variables |
| 14 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); | 14 | # sp.global.secret_key("YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS."); |
diff --git a/config/detect_dangerous_extensions.rules b/config/detect_dangerous_extensions.rules new file mode 100644 index 0000000..8f10532 --- /dev/null +++ b/config/detect_dangerous_extensions.rules | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | ## This example rules file shows how to detect and disable certain potentially | ||
| 2 | ## dangerous or unwanted extensions. | ||
| 3 | |||
| 4 | @condition extension_loaded("runkit7"); | ||
| 5 | @error "The runkit7 extension can be used to rename classes and functions, thereby circumventing any filters set by Snuffleupagus. Please disable runkit7."; | ||
| 6 | |||
| 7 | @condition extension_loaded("FFI"); | ||
| 8 | @warning "FFI extension is loaded. Disabling via 'ffi.enable=false'"; | ||
| 9 | sp.ini_protection.enable(); | ||
| 10 | sp.ini.key("ffi.enable").set("false").ro(); | ||
| 11 | @end_condition; | ||
| 12 | |||
diff --git a/config/ini_protection.rules b/config/ini_protection.rules new file mode 100644 index 0000000..9b42a18 --- /dev/null +++ b/config/ini_protection.rules | |||
| @@ -0,0 +1,291 @@ | |||
| 1 | ## INI protection - prevent unwanted runtime ini changes made by ini_set() or other functions or by .htaccess | ||
| 2 | sp.ini_protection.enable(); | ||
| 3 | |||
| 4 | ## simulation mode: only log violations | ||
| 5 | #sp.ini_protection.simulation(); | ||
| 6 | |||
| 7 | ## drop policy: drop request on rule violation | ||
| 8 | #sp.ini_protection.policy_drop(); | ||
| 9 | |||
| 10 | ## do not log violations. | ||
| 11 | ## this setting has no effect in simulation or drop mode | ||
| 12 | #sp.ini_protection.policy_silent_fail(); | ||
| 13 | |||
| 14 | ## do not log read-only violations | ||
| 15 | ## this setting has no effect in simulation or drop mode | ||
| 16 | sp.ini_protection.policy_silent_ro(); | ||
| 17 | |||
| 18 | ## access policy can be one of | ||
| 19 | ## .policy_readonly(): All entries are read-only by default. | ||
| 20 | ## Individual entries can be set read-write using .readwrite() or .rw() | ||
| 21 | ## .policy_readwrite(): This is the default and can be omitted. | ||
| 22 | ## Individual entries can be set read-only using .readonly() or .ro() | ||
| 23 | #sp.ini_protection.policy_readonly(); | ||
| 24 | |||
| 25 | ## sp.ini entries can have the following attributes | ||
| 26 | ## .key("..."): mandatory ini name. | ||
| 27 | ## .set("..."): set the initial value. This overrides php.ini. | ||
| 28 | ## checks are not performed for this initial value. | ||
| 29 | ## .min("...") / .max("..."): value must be an integer between .min and .max. | ||
| 30 | ## shorthand notation (e.g. 1k = 1024) is allowed | ||
| 31 | ## .regexp("..."): value must match the regular expression | ||
| 32 | ## .allow_null(): allow setting a NULL-value | ||
| 33 | ## .msg("..."): message is shown in logs on rule violation instead of default message | ||
| 34 | ## .readonly() / .ro() / .readwrite() / .rw(): set entry to read-only or read-write respectively | ||
| 35 | ## If no access keyword is provided, the entry inherits the default policy set by sp.ini_protection.policy_*-rules. | ||
| 36 | ## .drop(): drop request on rule violation for this entry | ||
| 37 | ## .simulation(): only log rule violation for this entry | ||
| 38 | |||
| 39 | ## FOR PRODUCTION SYSTEMS: disable error messages and version numbers | ||
| 40 | sp.ini.key("display_errors").set("0").ro(); | ||
| 41 | sp.ini.key("display_startup_errors").set("0").ro(); | ||
| 42 | sp.ini.key("expose_php").set("0").ro(); | ||
| 43 | ## FOR DEVELOPMENT/TESTING: allow enabling error messages and version numbers | ||
| 44 | #sp.ini.key("display_errors").rw(); | ||
| 45 | #sp.ini.key("display_startup_errors").rw(); | ||
| 46 | #sp.ini.key("expose_php").rw(); | ||
| 47 | |||
| 48 | ## error logging options should not be set during runtime -> read-only. | ||
| 49 | sp.ini.key("error_log").ro(); | ||
| 50 | sp.ini.key("error_reporting").ro(); | ||
| 51 | sp.ini.key("log_errors").ro(); | ||
| 52 | @condition PHP_VERSION_ID < 80000; | ||
| 53 | sp.ini.key("log_errors_max_len").set("2048").ro(); | ||
| 54 | @end_condition; | ||
| 55 | sp.ini.key("ignore_repeated_errors").ro(); | ||
| 56 | sp.ini.key("ignore_repeated_source").ro(); | ||
| 57 | sp.ini.key("syslog.filter").ro(); | ||
| 58 | |||
| 59 | ## disable assert. assert() in PHP can evaluate arbitrary code just like eval() | ||
| 60 | sp.ini.key("assert.active").set("0").ro(); | ||
| 61 | sp.ini.key("assert.bail").ro(); | ||
| 62 | sp.ini.key("assert.callback").ro(); | ||
| 63 | sp.ini.key("assert.exception").ro(); | ||
| 64 | sp.ini.key("assert.warning").ro(); | ||
| 65 | |||
| 66 | ## enforce color codes. prevents potential XSS | ||
| 67 | sp.ini.key("highlight.comment").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 68 | sp.ini.key("highlight.default").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 69 | sp.ini.key("highlight.html").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 70 | sp.ini.key("highlight.keyword").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 71 | sp.ini.key("highlight.string").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 72 | |||
| 73 | ## prevent remote access via fopen/include | ||
| 74 | sp.ini.key("allow_url_fopen").set("0").ro(); | ||
| 75 | sp.ini.key("allow_url_include").set("0").ro(); | ||
| 76 | |||
| 77 | ## prevent code execution from auto-included files | ||
| 78 | sp.ini.key("auto_append_file").ro(); | ||
| 79 | sp.ini.key("auto_prepend_file").ro(); | ||
| 80 | |||
| 81 | ## make rarely used features read-only. you can always set the value in php.ini | ||
| 82 | sp.ini.key("arg_separator.input").ro(); | ||
| 83 | sp.ini.key("arg_separator.output").ro(); | ||
| 84 | sp.ini.key("auto_detect_line_endings").ro(); | ||
| 85 | sp.ini.key("auto_globals_jit").ro(); | ||
| 86 | sp.ini.key("browscap").ro(); | ||
| 87 | sp.ini.key("default_charset").ro(); | ||
| 88 | sp.ini.key("register_argc_argv").ro(); | ||
| 89 | sp.ini.key("report_memleaks").ro(); | ||
| 90 | sp.ini.key("report_zend_debug").ro(); | ||
| 91 | sp.ini.key("request_order").ro(); | ||
| 92 | sp.ini.key("url_rewriter.hosts").ro(); | ||
| 93 | sp.ini.key("url_rewriter.tags").ro(); | ||
| 94 | sp.ini.key("variables_order").ro(); | ||
| 95 | sp.ini.key("from").ro(); | ||
| 96 | sp.ini.key("short_open_tag").ro(); | ||
| 97 | sp.ini.key("unserialize_callback_func").ro(); | ||
| 98 | sp.ini.key("zend.detect_unicode").ro(); | ||
| 99 | sp.ini.key("zend.enable_gc").ro(); | ||
| 100 | sp.ini.key("zend.exception_ignore_args").ro(); | ||
| 101 | sp.ini.key("zend.exception_string_param_max_len").ro(); | ||
| 102 | sp.ini.key("zend.multibyte").ro(); | ||
| 103 | sp.ini.key("zend.script_encoding").ro(); | ||
| 104 | |||
| 105 | ## date and timezone settings | ||
| 106 | #sp.ini.key("date.default_latitude").set("31.7667").ro(); | ||
| 107 | #sp.ini.key("date.default_longitude").set("35.2333").ro(); | ||
| 108 | #sp.ini.key("date.sunrise_zenith").set("90.833333").ro(); | ||
| 109 | #sp.ini.key("date.sunset_zenith").set("90.833333").ro(); | ||
| 110 | #sp.ini.key("date.timezone").set("").ro(); | ||
| 111 | |||
| 112 | ## setting a default mime type other than text/html can be a way to prevent XSS, so this will be set to read-write by default | ||
| 113 | sp.ini.key("default_mimetype").rw(); | ||
| 114 | |||
| 115 | ## allow reasonable socket timeouts | ||
| 116 | sp.ini.key("default_socket_timeout").min("1").max("300").rw(); | ||
| 117 | |||
| 118 | ## disable dynamic loading of PHP extensions in an apache/mod_php environment as it is a security risk. | ||
| 119 | sp.ini.key("enable_dl").set("0").ro(); | ||
| 120 | |||
| 121 | ## links to manual pages in error pages should not be set during runtime. | ||
| 122 | sp.ini.key("docref_ext").ro(); | ||
| 123 | sp.ini.key("docref_root").ro(); | ||
| 124 | sp.ini.key("html_errors").set("0").ro(); | ||
| 125 | |||
| 126 | ## preventing $_POST and $_FILES to be populated can be a security feature, so read-write is ok. | ||
| 127 | sp.ini.key("enable_post_data_reading").rw(); | ||
| 128 | |||
| 129 | ## disable error append/prepend which may lead to log forging. | ||
| 130 | sp.ini.key("error_append_string").ro(); | ||
| 131 | sp.ini.key("error_prepend_string").set("").ro(); | ||
| 132 | |||
| 133 | ## restrict limit settings to prevent Denial-of-Service | ||
| 134 | sp.ini.key("max_execution_time").min("30").max("600").rw(); | ||
| 135 | sp.ini.key("max_file_uploads").min("0").max("25").rw(); | ||
| 136 | sp.ini.key("max_input_nesting_level").min("16").max("64").rw(); | ||
| 137 | sp.ini.key("max_input_time").set("-1").ro(); | ||
| 138 | sp.ini.key("max_input_vars").min("0").max("1024").rw(); | ||
| 139 | sp.ini.key("memory_limit").min("4M").max("256M").rw(); | ||
| 140 | sp.ini.key("post_max_size").max("256M").rw(); | ||
| 141 | sp.ini.key("upload_max_filesize").max("256M").rw(); | ||
| 142 | sp.ini.key("precision").max("14").rw(); | ||
| 143 | sp.ini.key("unserialize_max_depth").min("128").max("4096").rw(); | ||
| 144 | sp.ini.key("serialize_precision").ro(); | ||
| 145 | |||
| 146 | ## some applications rely on these filters for security | ||
| 147 | ## even though they should implement proper input validation for each input field separately. | ||
| 148 | @condition extension_loaded("filter"); | ||
| 149 | sp.ini.key("filter.default").rw(); | ||
| 150 | sp.ini.key("filter.default_flags").rw(); | ||
| 151 | @end_condition; | ||
| 152 | |||
| 153 | ## scripts will not be terminated after a client has aborted their connection. | ||
| 154 | ## this feature may be needed for some time consuming server-side calculation | ||
| 155 | sp.ini.key("ignore_user_abort").rw(); | ||
| 156 | |||
| 157 | ## flushing may be needed | ||
| 158 | sp.ini.key("implicit_flush").rw(); | ||
| 159 | |||
| 160 | ## this feature may be required for some frameworks to work properly, | ||
| 161 | ## but setting the include path to a fixed value is always more secure. | ||
| 162 | sp.ini.key("include_path").ro(); | ||
| 163 | |||
| 164 | ## input/output and encoding options | ||
| 165 | sp.ini.key("input_encoding").ro(); | ||
| 166 | sp.ini.key("internal_encoding").ro(); | ||
| 167 | sp.ini.key("output_encoding").ro(); | ||
| 168 | sp.ini.key("output_buffering").min("0").max("4096").rw(); | ||
| 169 | sp.ini.key("output_handler").ro(); | ||
| 170 | |||
| 171 | ## mail options | ||
| 172 | #sp.ini.key("mail.add_x_header").set("0").ro(); | ||
| 173 | #sp.ini.key("mail.force_extra_parameters").set("").ro(); | ||
| 174 | #sp.ini.key("mail.log").set("").ro(); | ||
| 175 | ## windows smtp options | ||
| 176 | #sp.ini.key("SMTP").set("localhost").ro(); | ||
| 177 | #sp.ini.key("smtp_port").set("25").ro(); | ||
| 178 | #sp.ini.key("sendmail_from").ro(); | ||
| 179 | |||
| 180 | ## mysqli/mysqlnd options | ||
| 181 | @condition extension_loaded("mysqli"); | ||
| 182 | sp.ini.key("mysqli.allow_local_infile").ro(); | ||
| 183 | sp.ini.key("mysqli.allow_persistent").ro(); | ||
| 184 | sp.ini.key("mysqli.default_host").ro(); | ||
| 185 | sp.ini.key("mysqli.default_port").ro(); | ||
| 186 | sp.ini.key("mysqli.default_pw").ro(); | ||
| 187 | sp.ini.key("mysqli.default_socket").ro(); | ||
| 188 | sp.ini.key("mysqli.default_user").ro(); | ||
| 189 | sp.ini.key("mysqli.max_links").set("-1").ro(); | ||
| 190 | sp.ini.key("mysqli.max_persistent").set("-1").ro(); | ||
| 191 | sp.ini.key("mysqli.reconnect").set("0").ro(); | ||
| 192 | sp.ini.key("mysqli.rollback_on_cached_plink").set("0").ro(); | ||
| 193 | @condition extension_loaded("mysqlnd"); | ||
| 194 | sp.ini.key("mysqlnd.collect_memory_statistics").set("0").ro(); | ||
| 195 | sp.ini.key("mysqlnd.collect_statistics").set("1").ro(); | ||
| 196 | sp.ini.key("mysqlnd.debug").set("").ro(); | ||
| 197 | sp.ini.key("mysqlnd.log_mask").set("0").ro(); | ||
| 198 | sp.ini.key("mysqlnd.mempool_default_size").set("16000").ro(); | ||
| 199 | sp.ini.key("mysqlnd.net_cmd_buffer_size").set("4096").ro(); | ||
| 200 | sp.ini.key("mysqlnd.net_read_buffer_size").set("32768").ro(); | ||
| 201 | sp.ini.key("mysqlnd.net_read_timeout").set("86400").ro(); | ||
| 202 | sp.ini.key("mysqlnd.sha256_server_public_key").set("").ro(); | ||
| 203 | sp.ini.key("mysqlnd.trace_alloc").set("").ro(); | ||
| 204 | @condition extension_loaded("mysqlnd") && PHP_VERSION_ID < 80100; | ||
| 205 | sp.ini.key("mysqlnd.fetch_data_copy").set("0").ro(); | ||
| 206 | @end_condition; | ||
| 207 | |||
| 208 | ## open basedir is a security feature similar to chroot. | ||
| 209 | ## why should it be allowed to disable this feature during runtime? | ||
| 210 | sp.ini.key("open_basedir").ro(); | ||
| 211 | |||
| 212 | ## pcre options | ||
| 213 | @condition extension_loaded("pcre"); | ||
| 214 | sp.ini.key("pcre.backtrack_limit").min("1000").max("1000000").rw(); | ||
| 215 | sp.ini.key("pcre.jit").rw(); | ||
| 216 | sp.ini.key("pcre.recursion_limit").min("1000").max("100000").ro(); | ||
| 217 | @end_condition; | ||
| 218 | |||
| 219 | ## phar options | ||
| 220 | @condition extension_loaded("phar"); | ||
| 221 | sp.ini.key("phar.cache_list").ro(); | ||
| 222 | sp.ini.key("phar.readonly").ro(); | ||
| 223 | sp.ini.key("phar.require_hash").ro(); | ||
| 224 | @end_condition; | ||
| 225 | |||
| 226 | ## session options | ||
| 227 | @condition extension_loaded("session"); | ||
| 228 | #sp.ini.key("session.auto_start").set("0").ro(); | ||
| 229 | #sp.ini.key("session.cache_expire").set("180").ro(); | ||
| 230 | #sp.ini.key("session.cache_limiter").set("nocache").ro(); | ||
| 231 | #sp.ini.key("session.cookie_domain").set("").ro(); | ||
| 232 | #sp.ini.key("session.cookie_httponly").set("0").ro(); | ||
| 233 | #sp.ini.key("session.cookie_lifetime").set("0").ro(); | ||
| 234 | #sp.ini.key("session.cookie_path").set("/").ro(); | ||
| 235 | #sp.ini.key("session.cookie_samesite").set("").ro(); | ||
| 236 | #sp.ini.key("session.cookie_secure").set("0").ro(); | ||
| 237 | #sp.ini.key("session.gc_divisor").set("100").ro(); | ||
| 238 | #sp.ini.key("session.gc_maxlifetime").set("1440").ro(); | ||
| 239 | #sp.ini.key("session.gc_probability").set("1").ro(); | ||
| 240 | #sp.ini.key("session.lazy_write").set("1").ro(); | ||
| 241 | #sp.ini.key("session.name").set("PHPSESSID").ro(); | ||
| 242 | #sp.ini.key("session.referer_check").set("").ro(); | ||
| 243 | #sp.ini.key("session.save_handler").set("files").ro(); | ||
| 244 | #sp.ini.key("session.save_path").set("").ro(); | ||
| 245 | #sp.ini.key("session.serialize_handler").set("php").ro(); | ||
| 246 | #sp.ini.key("session.sid_bits_per_character").set("4").ro(); | ||
| 247 | sp.ini.key("session.sid_length").min("32").max("128").rw(); | ||
| 248 | #sp.ini.key("session.trans_sid_hosts").set("").ro(); | ||
| 249 | #sp.ini.key("session.trans_sid_tags").set("a=href,area=href,frame=src,form=").ro(); | ||
| 250 | #sp.ini.key("session.upload_progress.cleanup").set("1").ro(); | ||
| 251 | #sp.ini.key("session.upload_progress.enabled").set("1").ro(); | ||
| 252 | #sp.ini.key("session.upload_progress.freq").set("1%").ro(); | ||
| 253 | #sp.ini.key("session.upload_progress.min_freq").set("1").ro(); | ||
| 254 | #sp.ini.key("session.upload_progress.name").set("PHP_SESSION_UPLOAD_PROGRESS").ro(); | ||
| 255 | #sp.ini.key("session.upload_progress.prefix").set("upload_progress_").ro(); | ||
| 256 | #sp.ini.key("session.use_cookies").set("1").ro(); | ||
| 257 | #sp.ini.key("session.use_only_cookies").set("1").ro(); | ||
| 258 | sp.ini.key("session.use_strict_mode").set("1").ro(); | ||
| 259 | #sp.ini.key("session.use_trans_sid").set("0").ro(); | ||
| 260 | @end_condition; | ||
| 261 | |||
| 262 | ## allow setting the user agent | ||
| 263 | sp.ini.key("user_agent").rw(); | ||
| 264 | |||
| 265 | ## allow setting the xmlrpc fault code | ||
| 266 | sp.ini.key("xmlrpc_error_number").rw(); | ||
| 267 | |||
| 268 | ## these ini entries can only be set by php.ini anyway, | ||
| 269 | ## but better set them to read-only anyway, just to be sure. | ||
| 270 | sp.ini.key("disable_classes").ro(); | ||
| 271 | sp.ini.key("disable_functions").ro(); | ||
| 272 | sp.ini.key("doc_root").ro(); | ||
| 273 | sp.ini.key("extension_dir").ro(); | ||
| 274 | sp.ini.key("file_uploads").ro(); | ||
| 275 | sp.ini.key("hard_timeout").ro(); | ||
| 276 | sp.ini.key("realpath_cache_size").ro(); | ||
| 277 | sp.ini.key("realpath_cache_ttl").ro(); | ||
| 278 | sp.ini.key("sendmail_path").ro(); | ||
| 279 | @condition extension_loaded("sqlite3"); | ||
| 280 | sp.ini.key("sqlite3.defensive").ro(); | ||
| 281 | sp.ini.key("sqlite3.extension_dir").ro(); | ||
| 282 | @end_condition; | ||
| 283 | sp.ini.key("sys_temp_dir").ro(); | ||
| 284 | sp.ini.key("syslog.facility").ro(); | ||
| 285 | sp.ini.key("syslog.ident").ro(); | ||
| 286 | sp.ini.key("upload_tmp_dir").ro(); | ||
| 287 | sp.ini.key("user_dir").ro(); | ||
| 288 | sp.ini.key("user_ini.cache_ttl").ro(); | ||
| 289 | sp.ini.key("user_ini.filename").ro(); | ||
| 290 | sp.ini.key("zend.assertions").ro(); | ||
| 291 | sp.ini.key("zend.signal_check").set("0").ro(); | ||
diff --git a/config/suhosin.rules b/config/suhosin.rules new file mode 100644 index 0000000..0bdc453 --- /dev/null +++ b/config/suhosin.rules | |||
| @@ -0,0 +1,281 @@ | |||
| 1 | ## This file is part of the Suhosin-NG (SNG) PHP Hardening project | ||
| 2 | ## - see https://suhosin.org/ for more information. | ||
| 3 | ## | ||
| 4 | ## Snuffleupagus compatibility: Version 0.7.0 with SNG patches and above | ||
| 5 | ## https://github.com/sektioneins/snuffleupagus | ||
| 6 | ## | ||
| 7 | ############################# ### # --------- | ||
| 8 | ## | ||
| 9 | ## This file documents the effort to port as many Suhosin features as possible to Snuffleupagus rules. | ||
| 10 | ## It is meant as a proof of concept and it will serve multiple purposes: | ||
| 11 | ## * Create a reasonably secure configuration for Snuffleupagus. | ||
| 12 | ## * Make it apparent which Suhosin features cannot be easily implemented in SP by just using configuration | ||
| 13 | ## rules. These will be collected and some features will be implemented as part of the Suhosin-NG project. | ||
| 14 | ## * Create a base set of Snuffleupagus rules to make the expert task of configuring a PHP hardening | ||
| 15 | ## extension accessible to a broader audience. This base set of rules will be integrated into a Tool - | ||
| 16 | ## see Milestone 6 (MS6) here: https://github.com/sektioneins/suhosin-ng/projects/1 | ||
| 17 | ## * Provide more configuration examples. | ||
| 18 | ## | ||
| 19 | ############################# ### # --------- | ||
| 20 | |||
| 21 | ## Let's enable relevant features first. | ||
| 22 | sp.ini_protection.enable(); | ||
| 23 | |||
| 24 | ## ===================== | ||
| 25 | ## Logging Configuration | ||
| 26 | ## ===================== | ||
| 27 | |||
| 28 | ## suhosin.log.syslog | ||
| 29 | ## suhosin.log.syslog.facility | ||
| 30 | ## suhosin.log.syslog.priority | ||
| 31 | ## suhosin.log.sapi | ||
| 32 | ## suhosin.log.stdout | ||
| 33 | ## suhosin.log.file | ||
| 34 | ## suhosin.log.file.name | ||
| 35 | ## suhosin.log.file.time | ||
| 36 | ## suhosin.log.script | ||
| 37 | ## suhosin.log.script.name | ||
| 38 | ## suhosin.log.phpscript | ||
| 39 | ## suhosin.log.phpscript.name | ||
| 40 | ## suhosin.log.phpscript.is_safe | ||
| 41 | ## suhosin.log.use-x-forwarded-for | ||
| 42 | |||
| 43 | ## SP will always use either REMOTE_ADDR or HTTP_X_FORWARDED_FOR. | ||
| 44 | |||
| 45 | ## Logging output can be one of | ||
| 46 | sp.log_media("php"); | ||
| 47 | #sp.log_media("syslog"); | ||
| 48 | |||
| 49 | ## More logging options are not implemented in SP. | ||
| 50 | |||
| 51 | ## ================ | ||
| 52 | ## Executor Options | ||
| 53 | ## ================ | ||
| 54 | |||
| 55 | ## suhosin.executor.max_depth | ||
| 56 | ## Not implemented in SP. | ||
| 57 | |||
| 58 | ## suhosin.executor.include.max_traversal | ||
| 59 | ## SP example for max_traversal = 3 | ||
| 60 | sp.disable_function.function_r("^(require|include)(_once)?$").value_r("\\.\\./+\\.\\./+\\.\\./+").drop(); | ||
| 61 | |||
| 62 | ## suhosin.executor.include.whitelist | ||
| 63 | ## suhosin.executor.include.blacklist | ||
| 64 | ## SP version with wrapper whitelist and regex matching include/require: | ||
| 65 | sp.wrappers_whitelist.list("file,php,phar"); | ||
| 66 | sp.disable_function.function_r("^(require|include)(_once)?$").value_r("^php://(stdin|stdout|stderr|input|output|memory|temp)").drop(); | ||
| 67 | |||
| 68 | ## suhosin.executor.include.allow_writable_files | ||
| 69 | ## SP can enable readonly protection | ||
| 70 | #sp.readonly_exec.enable(); | ||
| 71 | |||
| 72 | ## suhosin.executor.func.whitelist | ||
| 73 | ## suhosin.executor.func.blacklist | ||
| 74 | #sp.disable_function.function("...").drop(); | ||
| 75 | |||
| 76 | ## suhosin.executor.eval.whitelist | ||
| 77 | ## suhosin.executor.eval.blacklist | ||
| 78 | #sp.eval_blacklist.list("system,exec,shell_exec"); | ||
| 79 | |||
| 80 | ## suhosin.executor.disable_eval | ||
| 81 | #sp.disable_function.function("eval").drop(); | ||
| 82 | |||
| 83 | |||
| 84 | ## suhosin.executor.disable_emodifier | ||
| 85 | ## This is actually not needed anymore in PHP 7 and above | ||
| 86 | |||
| 87 | ## suhosin.executor.allow_symlink | ||
| 88 | ## SP can simply disable the symlink function. | ||
| 89 | ## Other ways to create symlinks should be disabled as well, e.g. system("ln -s ...") | ||
| 90 | #sp.disable_function.function("symlink").drop(); | ||
| 91 | #sp.disable_function.function("system").drop(); | ||
| 92 | #sp.disable_function.function("shell_exec").drop(); | ||
| 93 | #sp.disable_function.function("exec").drop(); | ||
| 94 | #sp.disable_function.function("proc_open").drop(); | ||
| 95 | |||
| 96 | |||
| 97 | ## | ||
| 98 | ## ============ | ||
| 99 | ## Misc Options | ||
| 100 | ## ============ | ||
| 101 | ## | ||
| 102 | |||
| 103 | ## suhosin.simulation | ||
| 104 | ## SP provides individual .simulation() switches for most features. | ||
| 105 | |||
| 106 | ## suhosin.perdir | ||
| 107 | ## Not implemented in SP. | ||
| 108 | |||
| 109 | |||
| 110 | ## suhosin.protectkey | ||
| 111 | ## SP does not actually need to protect its secret key this way, as it is not a native PHP ini directive shown in phpinfo() | ||
| 112 | |||
| 113 | ## suhosin.coredump | ||
| 114 | ## SP can be started in gdb/lldb, so this feature may not be needed. | ||
| 115 | |||
| 116 | ## suhosin.stealth | ||
| 117 | ## Not implemented in SP. | ||
| 118 | ## If ionCube support or similar extensions should ever be requested to run with SP, this feature may be implemented some day. | ||
| 119 | |||
| 120 | ## suhosin.apc_bug_workaround | ||
| 121 | ## This is not a thing anymore with PHP7+ | ||
| 122 | |||
| 123 | ## suhosin.disable.display_errors | ||
| 124 | #sp.ini.key("display_errors").set("0").ro(); | ||
| 125 | #sp.ini.key("display_startup_errors").set("0").ro(); | ||
| 126 | #sp.ini.key("expose_php").set("0").ro(); | ||
| 127 | |||
| 128 | ## suhosin.multiheader | ||
| 129 | ## There is a PHP filter in place to prevent multiple headers in one header() call - let's hope it works. | ||
| 130 | |||
| 131 | ## suhosin.mail.protect | ||
| 132 | sp.disable_function.function("mail").param("to").value_r("\\n").alias("newline in mail() To:").drop(); | ||
| 133 | sp.disable_function.function("mail").param("subject").value_r("\\n").alias("newline in mail() Subject:").drop(); | ||
| 134 | sp.disable_function.function("mail").param("additional_headers").param_type("STRING").drop(); | ||
| 135 | sp.disable_function.function("mail").param("additional_headers").param_type("NULL").allow(); | ||
| 136 | sp.disable_function.function("mail").param("additional_headers").key_r("^(to|b?cc)$").drop(); | ||
| 137 | |||
| 138 | |||
| 139 | ## suhosin.memory_limit | ||
| 140 | ## SP can either disable or limit the memory_limit setting | ||
| 141 | #sp.ini.key("memory_limit").ro(); | ||
| 142 | sp.ini.key("memory_limit").min("4M").max("256M").rw(); | ||
| 143 | |||
| 144 | |||
| 145 | ## ======================== | ||
| 146 | ## SQL Injection Protection | ||
| 147 | ## ======================== | ||
| 148 | |||
| 149 | ## suhosin.sql.bailout_on_error | ||
| 150 | ## SP example for mysqli and PDO | ||
| 151 | #sp.disable_function.function("mysqli_query").ret("FALSE").drop(); | ||
| 152 | #sp.disable_function.function("mysqli::query").ret("FALSE").drop(); | ||
| 153 | #sp.disable_function.function("mysqli_real_query").ret("FALSE").drop(); | ||
| 154 | #sp.disable_function.function("mysqli::real_query").ret("FALSE").drop(); | ||
| 155 | #sp.disable_function.function("mysqli_prepare").ret("FALSE").drop(); | ||
| 156 | #sp.disable_function.function("mysqli::prepare").ret("FALSE").drop(); | ||
| 157 | #sp.disable_function.function("mysqli_stmt_execute").ret("FALSE").drop(); | ||
| 158 | #sp.disable_function.function("mysqli_stmt::execute").ret("FALSE").drop(); | ||
| 159 | #sp.disable_function.function("mysqli_execute").ret("FALSE").drop(); | ||
| 160 | #sp.disable_function.function("PDO::query").ret("FALSE").drop(); | ||
| 161 | #sp.disable_function.function("PDO::prepare").ret("FALSE").drop(); | ||
| 162 | #sp.disable_function.function("PDO::exec").ret("FALSE").drop(); | ||
| 163 | #sp.disable_function.function("PDOStatement::execute").ret("FALSE").drop(); | ||
| 164 | |||
| 165 | |||
| 166 | ## suhosin.sql.user_match | ||
| 167 | ## suhosin.sql.user_prefix | ||
| 168 | ## suhosin.sql.user_postfix | ||
| 169 | ## SP example for mysqli | ||
| 170 | set SQL_USER "^public_"; | ||
| 171 | sp.disable_function.function("mysqli::__construct").param("username").value_r(SQL_USER).allow(); | ||
| 172 | sp.disable_function.function("mysqli::__construct").drop(); | ||
| 173 | sp.disable_function.function("mysqli_connect").param("username").value_r(SQL_USER).allow(); | ||
| 174 | sp.disable_function.function("mysqli_connect").drop(); | ||
| 175 | sp.disable_function.function("mysqli::change_user").param("username").value_r(SQL_USER).allow(); | ||
| 176 | sp.disable_function.function("mysqli::change_user").drop(); | ||
| 177 | sp.disable_function.function("mysqli_change_user").param("username").value_r(SQL_USER).allow(); | ||
| 178 | sp.disable_function.function("mysqli_change_user").drop(); | ||
| 179 | |||
| 180 | ## suhosin.sql.comment | ||
| 181 | ## suhosin.sql.opencomment | ||
| 182 | ## Not implemented in SP. | ||
| 183 | ## It is possible to try and find common injection patterns such as ' or 1=1 -- via regex, | ||
| 184 | ## but that would likely trigger valid SQL strings containing these patterns as well. The same argument | ||
| 185 | ## applies to multiselect and union: | ||
| 186 | |||
| 187 | ## suhosin.sql.multiselect | ||
| 188 | ## suhosin.sql.union | ||
| 189 | ## Not implemented in SP. | ||
| 190 | |||
| 191 | |||
| 192 | ## ============================== | ||
| 193 | ## Transparent Encryption Options | ||
| 194 | ## ============================== | ||
| 195 | |||
| 196 | ## suhosin.session.cryptkey | ||
| 197 | ## suhosin.session.cryptua | ||
| 198 | ## suhosin.cookie.cryptkey | ||
| 199 | ## suhosin.cookie.cryptua | ||
| 200 | |||
| 201 | ## SP's session encryption and cookie encryption features rely on a secret key that is derived from | ||
| 202 | ## * the user agent string from the environment variable HTTP_USER_AGENT | ||
| 203 | ## * the value of the environment variable specified using sp.global.cookie_env_var(), | ||
| 204 | ## usually either REMOTE_ADDR or SSL_SESSION_ID | ||
| 205 | ## * a very secret key as specified using sp.global.secret_key() | ||
| 206 | sp.global.secret_key("c6a0e02b3b818f7559d5f85303d8fe44"); ## this key should be unique to your installation. | ||
| 207 | sp.global.cookie_env_var("REMOTE_ADDR"); | ||
| 208 | #sp.global.cookie_env_var("SSL_SESSION_ID"); | ||
| 209 | |||
| 210 | ## suhosin.session.encrypt | ||
| 211 | sp.session.encrypt(); | ||
| 212 | |||
| 213 | ## suhosin.cookie.encrypt | ||
| 214 | ## suhosin.cookie.cryptlist | ||
| 215 | ## suhosin.cookie.plainlist | ||
| 216 | #sp.cookie.name("my_cookie_name").encrypt(); | ||
| 217 | #sp.cookie.name_r("^enc_[a-z]+$").encrypt(); | ||
| 218 | |||
| 219 | ## suhosin.session.cryptdocroot | ||
| 220 | ## suhosin.session.cryptraddr | ||
| 221 | ## suhosin.session.checkraddr | ||
| 222 | ## suhosin.cookie.cryptdocroot | ||
| 223 | ## suhosin.cookie.cryptraddr | ||
| 224 | ## suhosin.cookie.checkraddr | ||
| 225 | ## For SP to include the document root or part of the IP address in the encryption key, the .cookie_env_var() | ||
| 226 | ## can be constructed by the web server to include these values. | ||
| 227 | |||
| 228 | |||
| 229 | ## ================= | ||
| 230 | ## Filtering Options | ||
| 231 | ## ================= | ||
| 232 | |||
| 233 | ## suhosin.filter.action | ||
| 234 | ## suhosin.cookie|get|post|request.max_array_depth | ||
| 235 | ## suhosin.cookie|get|post|request.max_array_index_length | ||
| 236 | ## suhosin.cookie|get|post.max_name_length | ||
| 237 | ## suhosin.request.max_varname_length | ||
| 238 | ## suhosin.cookie|get|post|request.max_totalname_length | ||
| 239 | ## suhosin.cookie|get|post|request.max_value_length | ||
| 240 | ## suhosin.cookie|get|post|request.max_vars | ||
| 241 | ## suhosin.cookie|get|post|request.disallow_nul | ||
| 242 | ## suhosin.cookie|get|post|request.disallow_ws | ||
| 243 | ## suhosin.request.array_index_blacklist | ||
| 244 | ## suhosin.request.array_index_whitelist | ||
| 245 | ## suhosin.upload.max_uploads | ||
| 246 | ## suhosin.upload.max_newlines | ||
| 247 | ## suhosin.upload.disallow_elf | ||
| 248 | ## suhosin.upload.disallow_binary | ||
| 249 | ## suhosin.upload.remove_binary | ||
| 250 | ## suhosin.upload.allow_utf8 | ||
| 251 | ## Not implemented in SP. | ||
| 252 | |||
| 253 | ## suhosin.upload.verification_script | ||
| 254 | #sp.upload_validation.script("/var/www/is_valid_php.py").enable(); | ||
| 255 | |||
| 256 | |||
| 257 | ## suhosin.session.max_id_length | ||
| 258 | ## suhosin.server.encode | ||
| 259 | ## suhosin.server.strip | ||
| 260 | ## Not implemented in SP. | ||
| 261 | |||
| 262 | ## suhosin.rand.seedingkey | ||
| 263 | ## suhosin.rand.reseed_every_request | ||
| 264 | ## suhosin.srand.ignore | ||
| 265 | ## suhosin.mt_srand.ignore | ||
| 266 | ## Instead of removing srand()/mt_srand(), SP basically replaces rand()/mt_rand() with the more secure random_int() | ||
| 267 | sp.harden_random.enable(); | ||
| 268 | |||
| 269 | ############################# ### # --------- | ||
| 270 | ## | ||
| 271 | ## features included in SP that are not covered by Suhosin rule equivalents | ||
| 272 | ## - see https://snuffleupagus.readthedocs.io/ for more information | ||
| 273 | |||
| 274 | # sp.unserialize_hmac.enable(); | ||
| 275 | # sp.global_strict.enable(); | ||
| 276 | sp.auto_cookie_secure.enable(); | ||
| 277 | #sp.cookie.name("cookie1").samesite("lax"); | ||
| 278 | #sp.cookie.name("cookie2").samesite("strict");; | ||
| 279 | sp.xxe_protection.enable(); | ||
| 280 | #sp.sloppy_comparison.enable(); | ||
| 281 | |||
diff --git a/doc/source/config.rst b/doc/source/config.rst index c01377c..0b7b7fd 100644 --- a/doc/source/config.rst +++ b/doc/source/config.rst | |||
| @@ -1,16 +1,6 @@ | |||
| 1 | Configuration | 1 | Configuration |
| 2 | ============= | 2 | ============= |
| 3 | 3 | ||
| 4 | Options are chainable by using dots (``.``) and string parameters | ||
| 5 | **must** be quoted, while booleans and integers aren't. | ||
| 6 | |||
| 7 | Comments are prefixed either with ``#``, or ``;``. | ||
| 8 | |||
| 9 | Some rules apply in a specific ``function`` (context) on a specific ``variable`` | ||
| 10 | (data), like ``disable_function``. Others can only be enabled/disabled, like | ||
| 11 | ``harden_random``. | ||
| 12 | |||
| 13 | |||
| 14 | .. warning:: | 4 | .. warning:: |
| 15 | 5 | ||
| 16 | If you configure Snuffleupagus incorrectly, your website *might* not work | 6 | If you configure Snuffleupagus incorrectly, your website *might* not work |
| @@ -21,17 +11,6 @@ Some rules apply in a specific ``function`` (context) on a specific ``variable`` | |||
| 21 | read the present documentation about how to configure them, | 11 | read the present documentation about how to configure them, |
| 22 | evaluate your threat model and write your configuration file accordingly. | 12 | evaluate your threat model and write your configuration file accordingly. |
| 23 | 13 | ||
| 24 | Most of the features can be used in ``simulation`` mode by appending the | ||
| 25 | ``.simulation()`` option to them (eg. ``sp.readonly_exec.simulation().enable();``) to see | ||
| 26 | whether or not they could break your website. The simulation mode won't block the request, | ||
| 27 | but will write a warning in the log. | ||
| 28 | |||
| 29 | The rules are evaluated in the order that they are written, the **first** one | ||
| 30 | to match will terminate the evaluation (except for rules in simulation mode). | ||
| 31 | |||
| 32 | Configuration file format | ||
| 33 | ------------------------- | ||
| 34 | |||
| 35 | Since PHP *ini-like* configuration model isn't flexible enough, | 14 | Since PHP *ini-like* configuration model isn't flexible enough, |
| 36 | Snuffleupagus is using its own format in the file specified by | 15 | Snuffleupagus is using its own format in the file specified by |
| 37 | the directive ``sp.configuration_file`` **in** your ``php.ini`` file, | 16 | the directive ``sp.configuration_file`` **in** your ``php.ini`` file, |
| @@ -61,6 +40,38 @@ your logs of course. We do **not** recommend to use it of course, but sometimes | |||
| 61 | it might be useful to be able to "debug in production" without breaking your | 40 | it might be useful to be able to "debug in production" without breaking your |
| 62 | website. | 41 | website. |
| 63 | 42 | ||
| 43 | Configuration file format | ||
| 44 | ------------------------- | ||
| 45 | |||
| 46 | Options are chainable by using dots (``.``). | ||
| 47 | |||
| 48 | Some options have a string parameter, that **must** be quoted with double quotes, e.g. ``"string"``. | ||
| 49 | |||
| 50 | Comments are prefixed either with ``#``, or ``;``. | ||
| 51 | |||
| 52 | Some rules apply in a specific ``function`` (context) on a specific ``variable`` | ||
| 53 | (data), like ``disable_function``. Others can only be enabled/disabled, like | ||
| 54 | ``harden_random``. | ||
| 55 | |||
| 56 | Most of the features can be used in ``simulation`` mode by appending the | ||
| 57 | ``.simulation()`` or ``.sim()`` option to them (eg. ``sp.readonly_exec.simulation().enable();``) to see | ||
| 58 | whether or not they could break your website. The simulation mode won't block the request, | ||
| 59 | but will write a warning in the log. | ||
| 60 | |||
| 61 | The rules are evaluated in the order that they are written, the **first** one | ||
| 62 | to match will terminate the evaluation (except for rules in simulation mode). | ||
| 63 | |||
| 64 | Rules can be split into lines and contain whitespace for easier readability and maintenance: (This feature is available since version 0.8.0.) | ||
| 65 | |||
| 66 | :: | ||
| 67 | |||
| 68 | sp.disable_function.function("mail") | ||
| 69 | .param("to").value_r("\\n") | ||
| 70 | .alias("newline in mail() To:") | ||
| 71 | .drop(); | ||
| 72 | |||
| 73 | The terminating ``;`` is optional for now, but it should be used for future compatibility. | ||
| 74 | |||
| 64 | Miscellaneous | 75 | Miscellaneous |
| 65 | ------------- | 76 | ------------- |
| 66 | 77 | ||
| @@ -178,6 +189,70 @@ Cookies-related mitigations | |||
| 178 | Since snuffleupagus is providing several hardening features for cookies, | 189 | Since snuffleupagus is providing several hardening features for cookies, |
| 179 | there is a dedicated web page :ref:`here <cookie-encryption-page>` about them. | 190 | there is a dedicated web page :ref:`here <cookie-encryption-page>` about them. |
| 180 | 191 | ||
| 192 | INI Settings Protection | ||
| 193 | ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| 194 | INI settings can be forced to a value, limited by min/max value or regular expression and set read-only mode. | ||
| 195 | |||
| 196 | First, this feature can be enabled or disabled: | ||
| 197 | |||
| 198 | :: | ||
| 199 | |||
| 200 | sp.ini_protection.enable(); | ||
| 201 | sp.ini_protection.disable(); | ||
| 202 | |||
| 203 | The INI protection feature can be set to simulation mode, where violations are only reported, but rules are not enforced: | ||
| 204 | |||
| 205 | :: | ||
| 206 | |||
| 207 | sp.ini_protection.simulation(); | ||
| 208 | |||
| 209 | Rule violations can be set to drop as a global policy, or alternatively be set on individual rules using ``.drop()``. | ||
| 210 | |||
| 211 | :: | ||
| 212 | |||
| 213 | sp.ini_protection.policy_drop(); | ||
| 214 | |||
| 215 | Rules can be set to fail silently without logging anything: | ||
| 216 | |||
| 217 | :: | ||
| 218 | |||
| 219 | sp.ini_protection.policy_silent_fail(); | ||
| 220 | ## or write sp.ini_protection.policy_no_log(); as an alias | ||
| 221 | |||
| 222 | Read-only settings are implemented in a way that the PHP system itself can block the setting, which is very efficient. If you do not need to log read-only violations, these can be set to silent separately: | ||
| 223 | |||
| 224 | :: | ||
| 225 | |||
| 226 | sp.ini_protection.policy_silent_ro(); | ||
| 227 | |||
| 228 | A global access policy can be set to either read-only or read-write. Individual entries can be set to read-only/read-write as well using ``.ro()``/``.rw()``. | ||
| 229 | |||
| 230 | :: | ||
| 231 | |||
| 232 | sp.ini_protection.policy_readonly(); | ||
| 233 | sp.ini_protection.policy_readwrite(); | ||
| 234 | |||
| 235 | Individual rules are specified using ``sp.ini``. These entries can have the following attributes: | ||
| 236 | |||
| 237 | - ``.key("...")``: mandatory ini name. | ||
| 238 | - ``.set("...")``: set the initial value. This overrides php.ini. checks are not performed for this initial value. | ||
| 239 | - ``.min("...")`` / ``.max("...")``: value must be an integer between .min and .max. shorthand notation (e.g. 1k = 1024) is allowed | ||
| 240 | - ``.regexp("...")``: value must match the regular expression | ||
| 241 | - ``.allow_null()``: allow setting a NULL-value | ||
| 242 | - ``.msg("...")``: message is shown in logs on rule violation instead of default message | ||
| 243 | - ``.readonly()`` / ``.ro()`` / .readwrite() / .rw(): set entry to read-only or read-write respectively. If no access keyword is provided, the entry inherits the default policy set by ``sp.ini_protection.policy_*``-rules. | ||
| 244 | - ``.drop()``: drop request on rule violation for this entry | ||
| 245 | - ``.simulation()``: only log rule violation for this entry | ||
| 246 | |||
| 247 | Examples: | ||
| 248 | |||
| 249 | :: | ||
| 250 | |||
| 251 | sp.ini.key("display_errors").set("0").ro(); | ||
| 252 | sp.ini.key("default_socket_timeout").min("1").max("300").rw(); | ||
| 253 | sp.ini.key("highlight.comment").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 254 | |||
| 255 | For more examples, check out the ``config`` directory. | ||
| 181 | 256 | ||
| 182 | readonly_exec | 257 | readonly_exec |
| 183 | ^^^^^^^^^^^^^ | 258 | ^^^^^^^^^^^^^ |
| @@ -218,14 +293,15 @@ It can either be ``enabled`` or ``disabled`` and can be used in ``simulation`` m | |||
| 218 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); | 293 | sp.upload_validation.script("/var/www/is_valid_php.py").enable(); |
| 219 | 294 | ||
| 220 | 295 | ||
| 221 | disable_xxe | 296 | xxe_protection |
| 222 | ^^^^^^^^^^^ | 297 | ^^^^^^^^^^^ |
| 223 | 298 | ||
| 224 | :ref:`disable_xxe <xxe-feature>`, enabled by default, will prevent XXE attacks by disabling the loading of external entities (``libxml_disable_entity_loader``) in the XML parser. | 299 | :ref:`xxe_protection <xxe-feature>`, disabled by default, will prevent XXE attacks by disabling the loading of external entities (``libxml_disable_entity_loader``) in the XML parser. |
| 225 | 300 | ||
| 226 | :: | 301 | :: |
| 227 | 302 | ||
| 228 | sp.disable_xxe.enable(); | 303 | sp.xxe_protection.enable(); |
| 304 | sp.xxe_protection.disable(); | ||
| 229 | 305 | ||
| 230 | 306 | ||
| 231 | Whitelist of stream-wrappers | 307 | Whitelist of stream-wrappers |
| @@ -380,7 +456,7 @@ It's currently not possible to: | |||
| 380 | `for now <https://github.com/jvoisin/snuffleupagus/issues/190>`__). | 456 | `for now <https://github.com/jvoisin/snuffleupagus/issues/190>`__). |
| 381 | This is why hooked ``print`` will be displayed as ``echo`` in the logs. | 457 | This is why hooked ``print`` will be displayed as ``echo`` in the logs. |
| 382 | - Hook `strlen`, since in latest PHP versions, this function is usually | 458 | - Hook `strlen`, since in latest PHP versions, this function is usually |
| 383 | optimized away by the compiled. | 459 | optimized away by the compiler. |
| 384 | 460 | ||
| 385 | 461 | ||
| 386 | Examples | 462 | Examples |
diff --git a/doc/source/faq.rst b/doc/source/faq.rst index bdfc7c1..0695089 100644 --- a/doc/source/faq.rst +++ b/doc/source/faq.rst | |||
| @@ -79,6 +79,12 @@ We chose the LGPL because we don't care that much how you're using Snuffleupagus | |||
| 79 | but we'd like to force people to make their improvements/contributions | 79 | but we'd like to force people to make their improvements/contributions |
| 80 | available to everyone. | 80 | available to everyone. |
| 81 | 81 | ||
| 82 | The complete license text is shipped with the sources and can be found under ``LICENSE``. | ||
| 83 | |||
| 84 | For compatibility with older PHP versions, some original PHP source code was copied or ported back to older versions. | ||
| 85 | This source code resides in ``src/sp_php_compat.c`` and ``src/sp_php_compat.h`` and retains its original license | ||
| 86 | `The PHP License, version 3.01 <https://www.php.net/license/3_01.txt>`_, also included with the sources as ``PHP_LICENSE``. | ||
| 87 | |||
| 82 | 88 | ||
| 83 | What is the different between SNuffleupaugs and a (WAF) like ModSecurity? | 89 | What is the different between SNuffleupaugs and a (WAF) like ModSecurity? |
| 84 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | 90 | """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
diff --git a/slides/44con_2018.pdf b/slides/44con_2018.pdf deleted file mode 100644 index 085e952..0000000 --- a/slides/44con_2018.pdf +++ /dev/null | |||
| Binary files differ | |||
diff --git a/slides/berlinsides_2017.pdf b/slides/berlinsides_2017.pdf deleted file mode 100644 index 3358b76..0000000 --- a/slides/berlinsides_2017.pdf +++ /dev/null | |||
| Binary files differ | |||
diff --git a/slides/blackalps_2017.pdf b/slides/blackalps_2017.pdf deleted file mode 100644 index a87e9ca..0000000 --- a/slides/blackalps_2017.pdf +++ /dev/null | |||
| Binary files differ | |||
diff --git a/slides/hacklu_2017.pdf b/slides/hacklu_2017.pdf deleted file mode 100644 index b8976e5..0000000 --- a/slides/hacklu_2017.pdf +++ /dev/null | |||
| Binary files differ | |||
diff --git a/slides/passthesalt_2018.pdf b/slides/passthesalt_2018.pdf deleted file mode 100644 index 4620ad2..0000000 --- a/slides/passthesalt_2018.pdf +++ /dev/null | |||
| Binary files differ | |||
diff --git a/src/Makefile.frag b/src/Makefile.frag new file mode 100644 index 0000000..e110544 --- /dev/null +++ b/src/Makefile.frag | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | $(srcdir)/sp_config_scanner.c: $(srcdir)/sp_config_scanner.re | ||
| 2 | if re2c -v |grep ' 2\.' 2>/dev/null; then \ | ||
| 3 | re2c -bc -o $@ $<; \ | ||
| 4 | re2c --no-generation-date --no-version -bci -o $(srcdir)/sp_config_scanner.cached.c $<; \ | ||
| 5 | else \ | ||
| 6 | cp $(srcdir)/sp_config_scanner.cached.c $@; \ | ||
| 7 | fi; | ||
| 8 | |||
| 9 | .PHONY: tests | ||
| 10 | tests: | ||
| 11 | $(MAKE) test NO_INTERACTION=1 SP_NODEBUG=1 SP_SKIP_OLD_PHP_CHECK=1 $(TESTS) | ||
diff --git a/src/config.m4 b/src/config.m4 index e4cc1f5..a421c0c 100644 --- a/src/config.m4 +++ b/src/config.m4 | |||
| @@ -7,6 +7,7 @@ sources="$sources sp_disabled_functions.c sp_execute.c sp_upload_validation.c" | |||
| 7 | sources="$sources sp_cookie_encryption.c sp_network_utils.c tweetnacl.c" | 7 | sources="$sources sp_cookie_encryption.c sp_network_utils.c tweetnacl.c" |
| 8 | sources="$sources sp_config_keywords.c sp_var_parser.c sp_var_value.c sp_tree.c" | 8 | sources="$sources sp_config_keywords.c sp_var_parser.c sp_var_value.c sp_tree.c" |
| 9 | sources="$sources sp_pcre_compat.c sp_crypt.c sp_session.c sp_sloppy.c sp_wrapper.c" | 9 | sources="$sources sp_pcre_compat.c sp_crypt.c sp_session.c sp_sloppy.c sp_wrapper.c" |
| 10 | sources="$sources sp_ini.c sp_php_compat.c sp_config_scanner.c sp_ifilter.c" | ||
| 10 | 11 | ||
| 11 | PHP_ARG_ENABLE(snuffleupagus, whether to enable snuffleupagus support, | 12 | PHP_ARG_ENABLE(snuffleupagus, whether to enable snuffleupagus support, |
| 12 | [ --enable-snuffleupagus Enable snuffleupagus support]) | 13 | [ --enable-snuffleupagus Enable snuffleupagus support]) |
| @@ -17,18 +18,24 @@ PHP_ARG_ENABLE(coverage, whether to enable coverage support, | |||
| 17 | PHP_ARG_ENABLE(debug, whether to enable debug messages, | 18 | PHP_ARG_ENABLE(debug, whether to enable debug messages, |
| 18 | [ --enable-debug Enable debug messages], no, no) | 19 | [ --enable-debug Enable debug messages], no, no) |
| 19 | 20 | ||
| 21 | PHP_ARG_ENABLE(debug-stderr, whether to enable debug messages, | ||
| 22 | [ --enable-debug-stderr Enable debug messages], no, no) | ||
| 23 | |||
| 20 | AC_PROG_CC_STDC() | 24 | AC_PROG_CC_STDC() |
| 21 | 25 | ||
| 22 | CFLAGS="$CFLAGS" | 26 | CFLAGS="$CFLAGS" |
| 23 | CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter" | 27 | CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter" |
| 24 | CFLAGS="$CFLAGS -Wformat=2 -Wformat-security -D_FORTIFY_SOURCE=2" | 28 | CFLAGS="$CFLAGS -Wformat=2 -Wformat-security -D_FORTIFY_SOURCE=2" |
| 25 | CFLAGS="$CFLAGS -fstack-protector" | 29 | CFLAGS="$CFLAGS -fstack-protector-strong" |
| 26 | 30 | ||
| 27 | LDFLAGS="$LDFLAGS `pcre2-config --libs8`" | 31 | LDFLAGS="$LDFLAGS `pcre2-config --libs8`" |
| 28 | 32 | ||
| 29 | if test "$PHP_DEBUG" = "yes"; then | 33 | if test "$PHP_DEBUG" = "yes"; then |
| 30 | AC_DEFINE(SP_DEBUG, 1, [Wether you want to enable debug messages]) | 34 | AC_DEFINE(SP_DEBUG, 1, [Enable SP debug messages]) |
| 31 | CFLAGS="$CFLAGS -g -ggdb -O0" | 35 | CFLAGS="$CFLAGS -g -ggdb -O0" |
| 36 | if test "$PHP_DEBUG_STDERR" = "yes"; then | ||
| 37 | AC_DEFINE(SP_DEBUG_STDERR, 1, [Print SP debug messages to stderr]) | ||
| 38 | fi | ||
| 32 | fi | 39 | fi |
| 33 | 40 | ||
| 34 | AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) | 41 | AC_CHECK_LIB(pcre, pcre_compile, AC_DEFINE(HAVE_PCRE, 1, [have pcre])) |
| @@ -39,3 +46,6 @@ if test "$PHP_SNUFFLEUPAGUS" = "yes"; then | |||
| 39 | fi | 46 | fi |
| 40 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) | 47 | PHP_NEW_EXTENSION(snuffleupagus, $sources, $ext_shared,-DZEND_ENABLE_STATIC_TSRMLS_CACHE=1) |
| 41 | fi | 48 | fi |
| 49 | |||
| 50 | # PHP_PROG_RE2C([2.0]) | ||
| 51 | PHP_ADD_MAKEFILE_FRAGMENT() | ||
diff --git a/src/php_snuffleupagus.h b/src/php_snuffleupagus.h index 9ed67e6..8dc7ccb 100644 --- a/src/php_snuffleupagus.h +++ b/src/php_snuffleupagus.h | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | #ifndef PHP_SNUFFLEUPAGUS_H | 1 | #ifndef PHP_SNUFFLEUPAGUS_H |
| 2 | #define PHP_SNUFFLEUPAGUS_H | 2 | #define PHP_SNUFFLEUPAGUS_H |
| 3 | 3 | ||
| 4 | #define PHP_SNUFFLEUPAGUS_VERSION "0.7.1" | 4 | #define PHP_SNUFFLEUPAGUS_VERSION "0.8.0" |
| 5 | #define PHP_SNUFFLEUPAGUS_EXTNAME "snuffleupagus" | 5 | #define PHP_SNUFFLEUPAGUS_EXTNAME "snuffleupagus" |
| 6 | #define PHP_SNUFFLEUPAGUS_AUTHOR "NBS System & Julien (jvoisin) Voisin" | 6 | #define PHP_SNUFFLEUPAGUS_AUTHOR "NBS System & Julien (jvoisin) Voisin & SektionEins GmbH" |
| 7 | #define PHP_SNUFFLEUPAGUS_URL "https://github.com/jvoisin/snuffleupagus" | 7 | #define PHP_SNUFFLEUPAGUS_URL "https://github.com/jvoisin/snuffleupagus" |
| 8 | #define PHP_SNUFFLEUPAGUS_COPYRIGHT "LGPLv2" | 8 | #define PHP_SNUFFLEUPAGUS_COPYRIGHT "LGPLv2" |
| 9 | 9 | ||
| @@ -65,10 +65,12 @@ typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); | |||
| 65 | #define SP_CONFIG_INVALID 0 | 65 | #define SP_CONFIG_INVALID 0 |
| 66 | #define SP_CONFIG_NONE -1 | 66 | #define SP_CONFIG_NONE -1 |
| 67 | 67 | ||
| 68 | #include "sp_php_compat.h" | ||
| 68 | #include "sp_pcre_compat.h" | 69 | #include "sp_pcre_compat.h" |
| 69 | #include "sp_list.h" | 70 | #include "sp_list.h" |
| 70 | #include "sp_tree.h" | 71 | #include "sp_tree.h" |
| 71 | #include "sp_var_parser.h" | 72 | #include "sp_var_parser.h" |
| 73 | #include "sp_config_scanner.h" | ||
| 72 | #include "sp_config.h" | 74 | #include "sp_config.h" |
| 73 | #include "sp_config_utils.h" | 75 | #include "sp_config_utils.h" |
| 74 | #include "sp_config_keywords.h" | 76 | #include "sp_config_keywords.h" |
| @@ -85,6 +87,8 @@ typedef void (*zif_handler)(INTERNAL_FUNCTION_PARAMETERS); | |||
| 85 | #include "sp_session.h" | 87 | #include "sp_session.h" |
| 86 | #include "sp_sloppy.h" | 88 | #include "sp_sloppy.h" |
| 87 | #include "sp_wrapper.h" | 89 | #include "sp_wrapper.h" |
| 90 | #include "sp_ini.h" | ||
| 91 | #include "sp_ifilter.h" | ||
| 88 | 92 | ||
| 89 | extern zend_module_entry snuffleupagus_module_entry; | 93 | extern zend_module_entry snuffleupagus_module_entry; |
| 90 | #define phpext_snuffleupagus_ptr &snuffleupagus_module_entry | 94 | #define phpext_snuffleupagus_ptr &snuffleupagus_module_entry |
| @@ -102,10 +106,45 @@ extern zend_module_entry snuffleupagus_module_entry; | |||
| 102 | #endif | 106 | #endif |
| 103 | 107 | ||
| 104 | ZEND_BEGIN_MODULE_GLOBALS(snuffleupagus) | 108 | ZEND_BEGIN_MODULE_GLOBALS(snuffleupagus) |
| 105 | size_t in_eval; | 109 | // sp_config config; |
| 106 | sp_config config; | 110 | // --- snuffleupagus config |
| 107 | int is_config_valid; // 1 = valid, 0 = invalid, -1 = none | 111 | sp_config_random config_random; |
| 112 | sp_config_sloppy config_sloppy; | ||
| 113 | sp_config_unserialize config_unserialize; | ||
| 114 | sp_config_readonly_exec config_readonly_exec; | ||
| 115 | sp_config_upload_validation config_upload_validation; | ||
| 116 | sp_config_cookie config_cookie; | ||
| 117 | sp_config_auto_cookie_secure config_auto_cookie_secure; | ||
| 118 | sp_config_global_strict config_global_strict; | ||
| 119 | sp_config_xxe_protection config_xxe_protection; | ||
| 120 | sp_config_eval config_eval; | ||
| 121 | sp_config_wrapper config_wrapper; | ||
| 122 | sp_config_session config_session; | ||
| 123 | sp_config_ini config_ini; | ||
| 124 | char config_log_media; | ||
| 125 | u_long config_max_execution_depth; | ||
| 126 | bool config_server_encode; | ||
| 127 | bool config_server_strip; | ||
| 128 | zend_string *config_encryption_key; | ||
| 129 | zend_string *config_cookies_env_var; | ||
| 130 | bool config_show_old_php_warning; | ||
| 131 | |||
| 132 | HashTable *config_disabled_functions; | ||
| 133 | HashTable *config_disabled_functions_hooked; | ||
| 134 | HashTable *config_disabled_functions_ret; | ||
| 135 | HashTable *config_disabled_functions_ret_hooked; | ||
| 136 | sp_config_disabled_functions config_disabled_functions_reg; | ||
| 137 | sp_config_disabled_functions config_disabled_functions_reg_ret; | ||
| 138 | |||
| 139 | bool hook_execute; | ||
| 140 | |||
| 141 | // --- ini options | ||
| 108 | bool allow_broken_configuration; | 142 | bool allow_broken_configuration; |
| 143 | |||
| 144 | // --- runtime/state variables | ||
| 145 | int is_config_valid; // 1 = valid, 0 = invalid, -1 = none | ||
| 146 | size_t in_eval; | ||
| 147 | u_long execution_depth; | ||
| 109 | HashTable *disabled_functions_hook; | 148 | HashTable *disabled_functions_hook; |
| 110 | HashTable *sp_internal_functions_hook; | 149 | HashTable *sp_internal_functions_hook; |
| 111 | HashTable *sp_eval_blacklist_functions_hook; | 150 | HashTable *sp_eval_blacklist_functions_hook; |
| @@ -113,6 +152,8 @@ ZEND_END_MODULE_GLOBALS(snuffleupagus) | |||
| 113 | 152 | ||
| 114 | ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus) | 153 | ZEND_EXTERN_MODULE_GLOBALS(snuffleupagus) |
| 115 | #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v) | 154 | #define SNUFFLEUPAGUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(snuffleupagus, v) |
| 155 | #define SPG(v) SNUFFLEUPAGUS_G(v) | ||
| 156 | #define SPCFG(v) SPG(config_##v) | ||
| 116 | 157 | ||
| 117 | #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS) | 158 | #if defined(ZTS) && defined(COMPILE_DL_SNUFFLEUPAGUS) |
| 118 | ZEND_TSRMLS_CACHE_EXTERN() | 159 | ZEND_TSRMLS_CACHE_EXTERN() |
diff --git a/src/snuffleupagus.c b/src/snuffleupagus.c index 1ac04d0..ebb7f9c 100644 --- a/src/snuffleupagus.c +++ b/src/snuffleupagus.c | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | #include <glob.h> | 4 | #include <glob.h> |
| 5 | #endif | 5 | #endif |
| 6 | 6 | ||
| 7 | #include "zend_smart_str.h" | ||
| 8 | |||
| 7 | #include "php_snuffleupagus.h" | 9 | #include "php_snuffleupagus.h" |
| 8 | 10 | ||
| 9 | #ifndef ZEND_EXT_API | 11 | #ifndef ZEND_EXT_API |
| @@ -30,7 +32,7 @@ static inline void sp_op_array_handler(zend_op_array *const op) { | |||
| 30 | if (NULL == op->filename || op->fn_flags & ZEND_ACC_STRICT_TYPES) { | 32 | if (NULL == op->filename || op->fn_flags & ZEND_ACC_STRICT_TYPES) { |
| 31 | return; | 33 | return; |
| 32 | } else { | 34 | } else { |
| 33 | if (true == SNUFFLEUPAGUS_G(config).config_global_strict->enable) { | 35 | if (SPCFG(global_strict).enable) { |
| 34 | op->fn_flags |= ZEND_ACC_STRICT_TYPES; | 36 | op->fn_flags |= ZEND_ACC_STRICT_TYPES; |
| 35 | } | 37 | } |
| 36 | } | 38 | } |
| @@ -38,20 +40,10 @@ static inline void sp_op_array_handler(zend_op_array *const op) { | |||
| 38 | 40 | ||
| 39 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) | 41 | ZEND_DECLARE_MODULE_GLOBALS(snuffleupagus) |
| 40 | 42 | ||
| 41 | static PHP_INI_MH(StrictMode) { | ||
| 42 | TSRMLS_FETCH(); | ||
| 43 | |||
| 44 | SNUFFLEUPAGUS_G(allow_broken_configuration) = false; | ||
| 45 | if (new_value && zend_string_equals_literal(new_value, "1")) { | ||
| 46 | SNUFFLEUPAGUS_G(allow_broken_configuration) = true; | ||
| 47 | } | ||
| 48 | return SUCCESS; | ||
| 49 | } | ||
| 50 | |||
| 51 | PHP_INI_BEGIN() | 43 | PHP_INI_BEGIN() |
| 52 | PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM, | 44 | PHP_INI_ENTRY("sp.configuration_file", "", PHP_INI_SYSTEM, OnUpdateConfiguration) |
| 53 | OnUpdateConfiguration) | 45 | STD_PHP_INI_BOOLEAN("sp.allow_broken_configuration", "0", PHP_INI_SYSTEM, OnUpdateBool, allow_broken_configuration, zend_snuffleupagus_globals, snuffleupagus_globals) |
| 54 | PHP_INI_ENTRY("sp.allow_broken_configuration", "0", PHP_INI_SYSTEM, StrictMode) | 46 | |
| 55 | PHP_INI_END() | 47 | PHP_INI_END() |
| 56 | 48 | ||
| 57 | ZEND_DLEXPORT zend_extension zend_extension_entry = { | 49 | ZEND_DLEXPORT zend_extension zend_extension_entry = { |
| @@ -73,155 +65,170 @@ ZEND_DLEXPORT zend_extension zend_extension_entry = { | |||
| 73 | NULL, /* op_array_dtor_func_t */ | 65 | NULL, /* op_array_dtor_func_t */ |
| 74 | STANDARD_ZEND_EXTENSION_PROPERTIES}; | 66 | STANDARD_ZEND_EXTENSION_PROPERTIES}; |
| 75 | 67 | ||
| 76 | PHP_GINIT_FUNCTION(snuffleupagus) { | 68 | static void sp_load_other_modules() { |
| 69 | // try to load other modules before initializing Snuffleupagus | ||
| 70 | zend_module_entry *module; | ||
| 71 | bool should_start = false; | ||
| 72 | ZEND_HASH_FOREACH_PTR(&module_registry, module) { | ||
| 73 | if (should_start) { | ||
| 74 | sp_log_debug("attempting to start module '%s' early", module->name); | ||
| 75 | if (zend_startup_module_ex(module) != SUCCESS) { | ||
| 76 | // startup failed. let's try again later. | ||
| 77 | module->module_started = 0; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | if (strcmp(module->name, PHP_SNUFFLEUPAGUS_EXTNAME) == 0) { | ||
| 81 | should_start = true; | ||
| 82 | } | ||
| 83 | } ZEND_HASH_FOREACH_END(); | ||
| 84 | |||
| 85 | |||
| 86 | } | ||
| 87 | |||
| 88 | static PHP_GINIT_FUNCTION(snuffleupagus) { | ||
| 77 | #ifdef SP_DEBUG_STDERR | 89 | #ifdef SP_DEBUG_STDERR |
| 78 | sp_debug_stderr = dup(STDERR_FILENO); | 90 | if (getenv("SP_NODEBUG")) { |
| 91 | sp_debug_stderr = -1; | ||
| 92 | } else { | ||
| 93 | sp_debug_stderr = dup(STDERR_FILENO); | ||
| 94 | } | ||
| 79 | #endif | 95 | #endif |
| 80 | sp_log_debug("(GINIT)"); | 96 | sp_log_debug("(GINIT)"); |
| 97 | sp_load_other_modules(); | ||
| 81 | snuffleupagus_globals->is_config_valid = SP_CONFIG_NONE; | 98 | snuffleupagus_globals->is_config_valid = SP_CONFIG_NONE; |
| 82 | snuffleupagus_globals->in_eval = 0; | 99 | snuffleupagus_globals->in_eval = 0; |
| 83 | 100 | ||
| 84 | #define SP_INIT_HT(F) \ | 101 | #define SP_INIT_HT(F) \ |
| 85 | snuffleupagus_globals->F = pemalloc(sizeof(*(snuffleupagus_globals->F)), 1); \ | 102 | snuffleupagus_globals->F = pemalloc(sizeof(*(snuffleupagus_globals->F)), 1); \ |
| 86 | zend_hash_init(snuffleupagus_globals->F, 10, NULL, NULL, 1); | 103 | zend_hash_init(snuffleupagus_globals->F, 10, NULL, NULL, 1); |
| 87 | SP_INIT_HT(disabled_functions_hook); | 104 | SP_INIT_HT(disabled_functions_hook); |
| 88 | SP_INIT_HT(sp_internal_functions_hook); | 105 | SP_INIT_HT(sp_internal_functions_hook); |
| 89 | SP_INIT_HT(sp_eval_blacklist_functions_hook); | 106 | SP_INIT_HT(sp_eval_blacklist_functions_hook); |
| 90 | SP_INIT_HT(config.config_disabled_functions); | 107 | SP_INIT_HT(config_disabled_functions); |
| 91 | SP_INIT_HT(config.config_disabled_functions_hooked); | 108 | SP_INIT_HT(config_disabled_functions_hooked); |
| 92 | SP_INIT_HT(config.config_disabled_functions_ret); | 109 | SP_INIT_HT(config_disabled_functions_ret); |
| 93 | SP_INIT_HT(config.config_disabled_functions_ret_hooked); | 110 | SP_INIT_HT(config_disabled_functions_ret_hooked); |
| 111 | SP_INIT_HT(config_ini.entries); | ||
| 94 | #undef SP_INIT_HT | 112 | #undef SP_INIT_HT |
| 95 | 113 | ||
| 96 | #define SP_INIT(F) \ | 114 | #define SP_INIT_NULL(F) snuffleupagus_globals->F = NULL; |
| 97 | snuffleupagus_globals->config.F = \ | 115 | SP_INIT_NULL(config_encryption_key); |
| 98 | pecalloc(sizeof(*(snuffleupagus_globals->config.F)), 1, 1); | 116 | SP_INIT_NULL(config_cookies_env_var); |
| 99 | SP_INIT(config_unserialize); | 117 | SP_INIT_NULL(config_disabled_functions_reg.disabled_functions); |
| 100 | SP_INIT(config_random); | 118 | SP_INIT_NULL(config_disabled_functions_reg_ret.disabled_functions); |
| 101 | SP_INIT(config_sloppy); | 119 | SP_INIT_NULL(config_cookie.cookies); |
| 102 | SP_INIT(config_readonly_exec); | 120 | SP_INIT_NULL(config_eval.blacklist); |
| 103 | SP_INIT(config_global_strict); | 121 | SP_INIT_NULL(config_eval.whitelist); |
| 104 | SP_INIT(config_auto_cookie_secure); | 122 | SP_INIT_NULL(config_wrapper.whitelist); |
| 105 | SP_INIT(config_snuffleupagus); | ||
| 106 | SP_INIT(config_disable_xxe); | ||
| 107 | SP_INIT(config_upload_validation); | ||
| 108 | SP_INIT(config_disabled_functions_reg); | ||
| 109 | SP_INIT(config_disabled_functions_reg_ret); | ||
| 110 | SP_INIT(config_cookie); | ||
| 111 | SP_INIT(config_session); | ||
| 112 | SP_INIT(config_eval); | ||
| 113 | SP_INIT(config_wrapper); | ||
| 114 | #undef SP_INIT | ||
| 115 | |||
| 116 | #define SP_INIT_NULL(F) snuffleupagus_globals->config.F = NULL; | ||
| 117 | SP_INIT_NULL(config_disabled_functions_reg->disabled_functions); | ||
| 118 | SP_INIT_NULL(config_disabled_functions_reg_ret->disabled_functions); | ||
| 119 | SP_INIT_NULL(config_cookie->cookies); | ||
| 120 | SP_INIT_NULL(config_eval->blacklist); | ||
| 121 | SP_INIT_NULL(config_eval->whitelist); | ||
| 122 | SP_INIT_NULL(config_wrapper->whitelist); | ||
| 123 | #undef SP_INIT_NULL | 123 | #undef SP_INIT_NULL |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | PHP_MINIT_FUNCTION(snuffleupagus) { | 126 | PHP_MINIT_FUNCTION(snuffleupagus) { |
| 127 | sp_log_debug("(MINIT)"); | 127 | sp_log_debug("(MINIT)"); |
| 128 | REGISTER_INI_ENTRIES(); | 128 | REGISTER_INI_ENTRIES(); |
| 129 | 129 | ||
| 130 | return SUCCESS; | 130 | return SUCCESS; |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | static void free_disabled_functions_hashtable(HashTable *const ht) { | 133 | PHP_MSHUTDOWN_FUNCTION(snuffleupagus) { |
| 134 | sp_log_debug("(MSHUTDOWN)"); | ||
| 135 | unhook_functions(SPG(sp_internal_functions_hook)); | ||
| 136 | unhook_functions(SPG(disabled_functions_hook)); | ||
| 137 | unhook_functions(SPG(sp_eval_blacklist_functions_hook)); | ||
| 138 | if (SPCFG(ini).enable) { sp_unhook_ini(); } | ||
| 139 | UNREGISTER_INI_ENTRIES(); | ||
| 140 | |||
| 141 | return SUCCESS; | ||
| 142 | } | ||
| 143 | |||
| 144 | static inline void free_disabled_functions_hashtable(HashTable *const ht) { | ||
| 134 | void *ptr = NULL; | 145 | void *ptr = NULL; |
| 135 | ZEND_HASH_FOREACH_PTR(ht, ptr) { sp_list_free(ptr); } | 146 | ZEND_HASH_FOREACH_PTR(ht, ptr) { sp_list_free(ptr, sp_free_disabled_function); } |
| 136 | ZEND_HASH_FOREACH_END(); | 147 | ZEND_HASH_FOREACH_END(); |
| 137 | } | 148 | } |
| 138 | 149 | ||
| 139 | PHP_MSHUTDOWN_FUNCTION(snuffleupagus) { | 150 | static inline void free_config_ini_entries(HashTable *const ht) { |
| 151 | void *ptr = NULL; | ||
| 152 | ZEND_HASH_FOREACH_PTR(ht, ptr) { sp_free_ini_entry(ptr); pefree(ptr, 1); } | ||
| 153 | ZEND_HASH_FOREACH_END(); | ||
| 154 | } | ||
| 155 | |||
| 156 | static PHP_GSHUTDOWN_FUNCTION(snuffleupagus) { | ||
| 157 | sp_log_debug("(GSHUTDOWN)"); | ||
| 140 | #define FREE_HT(F) \ | 158 | #define FREE_HT(F) \ |
| 141 | zend_hash_destroy(SNUFFLEUPAGUS_G(F)); \ | 159 | zend_hash_destroy(snuffleupagus_globals->F); \ |
| 142 | pefree(SNUFFLEUPAGUS_G(F), 1); | 160 | pefree(snuffleupagus_globals->F, 1); |
| 143 | FREE_HT(disabled_functions_hook); | 161 | FREE_HT(disabled_functions_hook); |
| 144 | FREE_HT(sp_eval_blacklist_functions_hook); | 162 | FREE_HT(sp_eval_blacklist_functions_hook); |
| 145 | 163 | ||
| 146 | #define FREE_HT_LIST(F) \ | 164 | #define FREE_HT_LIST(F) \ |
| 147 | free_disabled_functions_hashtable(SNUFFLEUPAGUS_G(config).F); \ | 165 | free_disabled_functions_hashtable(snuffleupagus_globals->F); \ |
| 148 | FREE_HT(config.F); | 166 | FREE_HT(F); |
| 149 | FREE_HT_LIST(config_disabled_functions); | 167 | FREE_HT_LIST(config_disabled_functions); |
| 150 | FREE_HT_LIST(config_disabled_functions_hooked); | 168 | FREE_HT_LIST(config_disabled_functions_hooked); |
| 151 | FREE_HT_LIST(config_disabled_functions_ret); | 169 | FREE_HT_LIST(config_disabled_functions_ret); |
| 152 | FREE_HT_LIST(config_disabled_functions_ret_hooked); | 170 | FREE_HT_LIST(config_disabled_functions_ret_hooked); |
| 153 | #undef FREE_HT_LIST | 171 | #undef FREE_HT_LIST |
| 154 | #undef FREE_HT | ||
| 155 | 172 | ||
| 156 | #define FREE_LST_DISABLE(L) \ | 173 | free_config_ini_entries(snuffleupagus_globals->config_ini.entries); |
| 157 | do { \ | 174 | FREE_HT(config_ini.entries); |
| 158 | sp_list_node *_n = SNUFFLEUPAGUS_G(config).L; \ | 175 | #undef FREE_HT |
| 159 | sp_disabled_function_list_free(_n); \ | ||
| 160 | sp_list_free(_n); \ | ||
| 161 | } while (0) | ||
| 162 | FREE_LST_DISABLE(config_disabled_functions_reg->disabled_functions); | ||
| 163 | FREE_LST_DISABLE(config_disabled_functions_reg_ret->disabled_functions); | ||
| 164 | #undef FREE_LST_DISABLE | ||
| 165 | 176 | ||
| 166 | sp_list_node *_n = SNUFFLEUPAGUS_G(config).config_cookie->cookies; | 177 | sp_list_free(snuffleupagus_globals->config_disabled_functions_reg.disabled_functions, sp_free_disabled_function); |
| 167 | sp_cookie_list_free(_n); | 178 | sp_list_free(snuffleupagus_globals->config_disabled_functions_reg_ret.disabled_functions, sp_free_disabled_function); |
| 168 | sp_list_free(_n); | 179 | sp_list_free(snuffleupagus_globals->config_cookie.cookies, sp_free_cookie); |
| 169 | 180 | ||
| 170 | #define FREE_LST(L) sp_list_free(SNUFFLEUPAGUS_G(config).L); | 181 | #define FREE_LST(L) sp_list_free(snuffleupagus_globals->L, sp_free_zstr); |
| 171 | FREE_LST(config_eval->blacklist); | 182 | FREE_LST(config_eval.blacklist); |
| 172 | FREE_LST(config_eval->whitelist); | 183 | FREE_LST(config_eval.whitelist); |
| 173 | FREE_LST(config_wrapper->whitelist); | 184 | FREE_LST(config_wrapper.whitelist); |
| 174 | #undef FREE_LST | 185 | #undef FREE_LST |
| 175 | 186 | ||
| 176 | #define FREE_CFG(C) pefree(SNUFFLEUPAGUS_G(config).C, 1); | ||
| 177 | FREE_CFG(config_unserialize); | ||
| 178 | FREE_CFG(config_random); | ||
| 179 | FREE_CFG(config_readonly_exec); | ||
| 180 | FREE_CFG(config_global_strict); | ||
| 181 | FREE_CFG(config_auto_cookie_secure); | ||
| 182 | FREE_CFG(config_snuffleupagus); | ||
| 183 | FREE_CFG(config_disable_xxe); | ||
| 184 | FREE_CFG(config_upload_validation); | ||
| 185 | FREE_CFG(config_session); | ||
| 186 | FREE_CFG(config_disabled_functions_reg); | ||
| 187 | FREE_CFG(config_disabled_functions_reg_ret); | ||
| 188 | FREE_CFG(config_cookie); | ||
| 189 | FREE_CFG(config_wrapper); | ||
| 190 | #undef FREE_CFG | ||
| 191 | 187 | ||
| 192 | UNREGISTER_INI_ENTRIES(); | 188 | // #define FREE_CFG(C) pefree(snuffleupagus_globals->config.C, 1); |
| 189 | #define FREE_CFG_ZSTR(C) sp_free_zstr(snuffleupagus_globals->C); | ||
| 190 | FREE_CFG_ZSTR(config_unserialize.dump); | ||
| 191 | FREE_CFG_ZSTR(config_unserialize.textual_representation); | ||
| 192 | FREE_CFG_ZSTR(config_upload_validation.script); | ||
| 193 | FREE_CFG_ZSTR(config_eval.dump); | ||
| 194 | FREE_CFG_ZSTR(config_eval.textual_representation); | ||
| 195 | // #undef FREE_CFG | ||
| 196 | #undef FREE_CFG_ZSTR | ||
| 193 | 197 | ||
| 194 | return SUCCESS; | 198 | #ifdef SP_DEBUG_STDERR |
| 199 | if (sp_debug_stderr >= 0) { | ||
| 200 | close(sp_debug_stderr); | ||
| 201 | sp_debug_stderr = STDERR_FILENO; | ||
| 202 | } | ||
| 203 | #endif | ||
| 195 | } | 204 | } |
| 196 | 205 | ||
| 197 | PHP_RINIT_FUNCTION(snuffleupagus) { | 206 | PHP_RINIT_FUNCTION(snuffleupagus) { |
| 198 | const sp_config_wrapper *const config_wrapper = | 207 | SPG(execution_depth) = 0; |
| 199 | SNUFFLEUPAGUS_G(config).config_wrapper; | 208 | SPG(in_eval) = 0; |
| 209 | |||
| 210 | const sp_config_wrapper *const config_wrapper = &(SPCFG(wrapper)); | ||
| 200 | #if defined(COMPILE_DL_SNUFFLEUPAGUS) && defined(ZTS) | 211 | #if defined(COMPILE_DL_SNUFFLEUPAGUS) && defined(ZTS) |
| 201 | ZEND_TSRMLS_CACHE_UPDATE(); | 212 | ZEND_TSRMLS_CACHE_UPDATE(); |
| 202 | #endif | 213 | #endif |
| 203 | 214 | ||
| 204 | if (!SNUFFLEUPAGUS_G(allow_broken_configuration)) { | 215 | if (!SPG(allow_broken_configuration)) { |
| 205 | if (SNUFFLEUPAGUS_G(is_config_valid) == SP_CONFIG_INVALID) { | 216 | if (SPG(is_config_valid) == SP_CONFIG_INVALID) { |
| 206 | sp_log_err("config", "Invalid configuration file"); | 217 | sp_log_err("config", "Invalid configuration file"); |
| 207 | } else if (SNUFFLEUPAGUS_G(is_config_valid) == SP_CONFIG_NONE) { | 218 | } else if (SPG(is_config_valid) == SP_CONFIG_NONE) { |
| 208 | sp_log_warn("config", | 219 | sp_log_warn("config", "No configuration specificed via sp.configuration_file"); |
| 209 | "No configuration specificed via sp.configuration_file"); | ||
| 210 | } | 220 | } |
| 211 | } | 221 | } |
| 212 | 222 | ||
| 213 | // We need to disable wrappers loaded by extensions loaded after | 223 | // We need to disable wrappers loaded by extensions loaded after SNUFFLEUPAGUS. |
| 214 | // SNUFFLEUPAGUS. | ||
| 215 | if (config_wrapper->enabled && | 224 | if (config_wrapper->enabled && |
| 216 | zend_hash_num_elements(php_stream_get_url_stream_wrappers_hash()) != | 225 | zend_hash_num_elements(php_stream_get_url_stream_wrappers_hash()) != config_wrapper->num_wrapper) { |
| 217 | config_wrapper->num_wrapper) { | ||
| 218 | sp_disable_wrapper(); | 226 | sp_disable_wrapper(); |
| 219 | } | 227 | } |
| 220 | 228 | ||
| 221 | if (NULL != SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key) { | 229 | if (NULL != SPCFG(encryption_key)) { |
| 222 | if (NULL != SNUFFLEUPAGUS_G(config).config_cookie->cookies) { | 230 | if (NULL != SPCFG(cookie).cookies) { |
| 223 | zend_hash_apply_with_arguments( | 231 | zend_hash_apply_with_arguments(Z_ARRVAL(PG(http_globals)[TRACK_VARS_COOKIE]), decrypt_cookie, 0); |
| 224 | Z_ARRVAL(PG(http_globals)[TRACK_VARS_COOKIE]), decrypt_cookie, 0); | ||
| 225 | } | 232 | } |
| 226 | } | 233 | } |
| 227 | return SUCCESS; | 234 | return SUCCESS; |
| @@ -231,7 +238,7 @@ PHP_RSHUTDOWN_FUNCTION(snuffleupagus) { return SUCCESS; } | |||
| 231 | 238 | ||
| 232 | PHP_MINFO_FUNCTION(snuffleupagus) { | 239 | PHP_MINFO_FUNCTION(snuffleupagus) { |
| 233 | const char *valid_config; | 240 | const char *valid_config; |
| 234 | switch (SNUFFLEUPAGUS_G(is_config_valid)) { | 241 | switch (SPG(is_config_valid)) { |
| 235 | case SP_CONFIG_VALID: | 242 | case SP_CONFIG_VALID: |
| 236 | valid_config = "yes"; | 243 | valid_config = "yes"; |
| 237 | break; | 244 | break; |
| @@ -245,22 +252,254 @@ PHP_MINFO_FUNCTION(snuffleupagus) { | |||
| 245 | php_info_print_table_start(); | 252 | php_info_print_table_start(); |
| 246 | php_info_print_table_row( | 253 | php_info_print_table_row( |
| 247 | 2, "snuffleupagus support", | 254 | 2, "snuffleupagus support", |
| 248 | SNUFFLEUPAGUS_G(is_config_valid) ? "enabled" : "disabled"); | 255 | SPG(is_config_valid) ? "enabled" : "disabled"); |
| 249 | php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION); | 256 | php_info_print_table_row(2, "Version", PHP_SNUFFLEUPAGUS_VERSION "-sng (with Suhosin-NG patches)"); |
| 250 | php_info_print_table_row(2, "Valid config", valid_config); | 257 | php_info_print_table_row(2, "Valid config", valid_config); |
| 251 | php_info_print_table_end(); | 258 | php_info_print_table_end(); |
| 252 | DISPLAY_INI_ENTRIES(); | 259 | DISPLAY_INI_ENTRIES(); |
| 253 | } | 260 | } |
| 254 | 261 | ||
| 255 | static PHP_INI_MH(OnUpdateConfiguration) { | 262 | #define ADD_ASSOC_ZSTR(arr, key, zstr) if (zstr) { add_assoc_str(arr, key, zstr); } else { add_assoc_null(arr, key); } |
| 256 | sp_log_debug("(OnUpdateConfiguration)"); | 263 | #define ADD_ASSOC_REGEXP(arr, key, regexp) if (regexp && regexp->pattern) { add_assoc_str(arr, key, regexp->pattern); } else { add_assoc_null(arr, key); } |
| 264 | |||
| 265 | static void add_df_to_arr(zval *arr, sp_disabled_function *df) { | ||
| 266 | zval arr_df; | ||
| 267 | array_init(&arr_df); | ||
| 268 | |||
| 269 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_FILENAME, df->filename); | ||
| 270 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_FILENAME_REGEXP, df->r_filename); | ||
| 271 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_FUNCTION, df->function); | ||
| 272 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_FUNCTION_REGEXP, df->r_function); | ||
| 273 | if (df->functions_list && df->functions_list->data) { | ||
| 274 | zval arr_fl; | ||
| 275 | array_init(&arr_fl); | ||
| 276 | for (sp_list_node *p = df->functions_list; p; p = p->next) { add_next_index_str(&arr_fl, p->data); } | ||
| 277 | add_assoc_zval(&arr_df, "function_list", &arr_fl); | ||
| 278 | } else { | ||
| 279 | add_assoc_null(&arr_df, "function_list"); | ||
| 280 | } | ||
| 281 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_HASH, df->hash); | ||
| 282 | add_assoc_bool(&arr_df, SP_TOKEN_SIM, df->simulation); | ||
| 283 | if (df->param && df->param->value) { | ||
| 284 | add_assoc_string(&arr_df, SP_TOKEN_PARAM, df->param->value); | ||
| 285 | } else { | ||
| 286 | add_assoc_null(&arr_df, SP_TOKEN_PARAM); | ||
| 287 | } | ||
| 288 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_PARAM_REGEXP, df->r_param); | ||
| 289 | add_assoc_long(&arr_df, SP_TOKEN_PARAM_TYPE, df->param_type); | ||
| 290 | add_assoc_long(&arr_df, SP_TOKEN_VALUE_ARG_POS, df->pos); | ||
| 291 | add_assoc_long(&arr_df, SP_TOKEN_LINE_NUMBER, df->line); | ||
| 292 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_RET, df->ret); | ||
| 293 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_RET_REGEXP, df->r_ret); | ||
| 294 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_VALUE, df->value); | ||
| 295 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_VALUE_REGEXP, df->r_value); | ||
| 296 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_KEY, df->key); | ||
| 297 | ADD_ASSOC_REGEXP(&arr_df, SP_TOKEN_KEY_REGEXP, df->r_key); | ||
| 298 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_DUMP, df->dump); | ||
| 299 | ADD_ASSOC_ZSTR(&arr_df, SP_TOKEN_ALIAS, df->alias); | ||
| 300 | add_assoc_bool(&arr_df, "param_is_array", df->param_is_array); | ||
| 301 | add_assoc_bool(&arr_df, "var_is_array", df->var_is_array); | ||
| 302 | add_assoc_bool(&arr_df, "allow", df->allow); | ||
| 303 | // todo: properly traverse tree for .var() and .param() | ||
| 304 | // sp_tree *tr = df->var; | ||
| 305 | // for (; tr; tr = tr->next) { | ||
| 306 | // sp_log_debug("tree: %s", tr->value); | ||
| 307 | // } | ||
| 308 | |||
| 309 | if (df->var && df->var->value) { | ||
| 310 | add_assoc_string(&arr_df, SP_TOKEN_LOCAL_VAR, df->var->value); | ||
| 311 | } else { | ||
| 312 | add_assoc_null(&arr_df, SP_TOKEN_LOCAL_VAR); | ||
| 313 | } | ||
| 314 | if (df->param && df->param->value) { | ||
| 315 | add_assoc_string(&arr_df, SP_TOKEN_PARAM, df->param->value); | ||
| 316 | } else { | ||
| 317 | add_assoc_null(&arr_df, SP_TOKEN_PARAM); | ||
| 318 | } | ||
| 319 | |||
| 320 | if (df->cidr) { | ||
| 321 | char cidrstr[INET6_ADDRSTRLEN+5]; | ||
| 322 | if (!get_ip_str(cidrstr, sizeof(cidrstr), df->cidr)) { | ||
| 323 | add_assoc_null(&arr_df, SP_TOKEN_CIDR); | ||
| 324 | } else { | ||
| 325 | add_assoc_string(&arr_df, SP_TOKEN_CIDR, cidrstr); | ||
| 326 | } | ||
| 327 | } else { | ||
| 328 | add_assoc_null(&arr_df, SP_TOKEN_CIDR); | ||
| 329 | } | ||
| 330 | |||
| 331 | add_next_index_zval(arr, &arr_df); | ||
| 332 | } | ||
| 333 | |||
| 334 | static void dump_config() { | ||
| 335 | zval arr; | ||
| 336 | php_serialize_data_t var_hash; | ||
| 337 | smart_str buf = {0}; | ||
| 338 | |||
| 339 | array_init(&arr); | ||
| 340 | add_assoc_string(&arr, "version", PHP_SNUFFLEUPAGUS_VERSION); | ||
| 257 | 341 | ||
| 342 | add_assoc_bool(&arr, SP_TOKEN_UNSERIALIZE_HMAC "." SP_TOKEN_ENABLE, SPCFG(unserialize).enable); | ||
| 343 | add_assoc_bool(&arr, SP_TOKEN_UNSERIALIZE_HMAC "." SP_TOKEN_SIM, SPCFG(unserialize).simulation); | ||
| 344 | ADD_ASSOC_ZSTR(&arr, SP_TOKEN_UNSERIALIZE_HMAC "." SP_TOKEN_DUMP, SPCFG(unserialize).dump); | ||
| 345 | |||
| 346 | add_assoc_bool(&arr, SP_TOKEN_HARDEN_RANDOM "." SP_TOKEN_ENABLE, SPCFG(random).enable); | ||
| 347 | |||
| 348 | add_assoc_bool(&arr, "readonly_exec.enable", SPCFG(readonly_exec).enable); | ||
| 349 | add_assoc_bool(&arr, "readonly_exec.sim", SPCFG(readonly_exec).simulation); | ||
| 350 | ADD_ASSOC_ZSTR(&arr, SP_TOKEN_READONLY_EXEC "." SP_TOKEN_DUMP, SPCFG(readonly_exec).dump); | ||
| 351 | |||
| 352 | add_assoc_bool(&arr, "global_strict.enable", SPCFG(global_strict).enable); | ||
| 353 | |||
| 354 | add_assoc_bool(&arr, "upload_validation.enable", SPCFG(upload_validation).enable); | ||
| 355 | add_assoc_bool(&arr, "upload_validation.sim", SPCFG(upload_validation).simulation); | ||
| 356 | ADD_ASSOC_ZSTR(&arr, SP_TOKEN_UPLOAD_VALIDATION "." SP_TOKEN_UPLOAD_SCRIPT, SPCFG(upload_validation).script); | ||
| 357 | |||
| 358 | // global | ||
| 359 | add_assoc_bool(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_ENCRYPTION_KEY, SPCFG(encryption_key) && ZSTR_LEN(SPCFG(encryption_key))); | ||
| 360 | ADD_ASSOC_ZSTR(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_ENV_VAR, SPCFG(cookies_env_var)); | ||
| 361 | add_assoc_long(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_LOG_MEDIA, SPCFG(log_media)); | ||
| 362 | add_assoc_long(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_MAX_EXECUTION_DEPTH, SPCFG(max_execution_depth)); | ||
| 363 | add_assoc_bool(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_SERVER_ENCODE, SPCFG(server_encode)); | ||
| 364 | add_assoc_bool(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_SERVER_STRIP, SPCFG(server_strip)); | ||
| 365 | add_assoc_bool(&arr, SP_TOKEN_GLOBAL "." SP_TOKEN_SHOW_OLD_PHP_WARNING, SPCFG(show_old_php_warning)); | ||
| 366 | |||
| 367 | add_assoc_bool(&arr, SP_TOKEN_AUTO_COOKIE_SECURE, SPCFG(auto_cookie_secure).enable); | ||
| 368 | add_assoc_bool(&arr, SP_TOKEN_XXE_PROTECTION, SPCFG(xxe_protection).enable); | ||
| 369 | |||
| 370 | add_assoc_bool(&arr, SP_TOKEN_EVAL_BLACKLIST "." SP_TOKEN_SIM, SPCFG(eval).simulation); | ||
| 371 | ADD_ASSOC_ZSTR(&arr, SP_TOKEN_EVAL_BLACKLIST "." SP_TOKEN_DUMP, SPCFG(eval).dump); | ||
| 372 | #define ADD_ASSOC_SPLIST(arr, key, splist) \ | ||
| 373 | if (splist) { \ | ||
| 374 | zval arr_sp; \ | ||
| 375 | array_init(&arr_sp); \ | ||
| 376 | for (sp_list_node *p = splist; p; p = p->next) { add_next_index_str(&arr_sp, p->data); } \ | ||
| 377 | add_assoc_zval(arr, key, &arr_sp); \ | ||
| 378 | } else { add_assoc_null(arr, key); } | ||
| 379 | |||
| 380 | ADD_ASSOC_SPLIST(&arr, SP_TOKEN_EVAL_BLACKLIST "." SP_TOKEN_LIST, SPCFG(eval).blacklist); | ||
| 381 | ADD_ASSOC_SPLIST(&arr, SP_TOKEN_EVAL_WHITELIST "." SP_TOKEN_LIST, SPCFG(eval).whitelist) | ||
| 382 | |||
| 383 | add_assoc_bool(&arr, SP_TOKEN_SESSION_ENCRYPTION "." SP_TOKEN_ENCRYPT, SPCFG(session).encrypt); | ||
| 384 | add_assoc_bool(&arr, SP_TOKEN_SESSION_ENCRYPTION "." SP_TOKEN_SIM, SPCFG(session).simulation); | ||
| 385 | |||
| 386 | add_assoc_long(&arr, SP_TOKEN_SESSION_ENCRYPTION "." SP_TOKEN_SID_MIN_LENGTH, SPCFG(session).sid_min_length); | ||
| 387 | add_assoc_long(&arr, SP_TOKEN_SESSION_ENCRYPTION "." SP_TOKEN_SID_MAX_LENGTH, SPCFG(session).sid_max_length); | ||
| 388 | add_assoc_bool(&arr, SP_TOKEN_SLOPPY_COMPARISON "." SP_TOKEN_ENABLE, SPCFG(sloppy).enable); | ||
| 389 | |||
| 390 | ADD_ASSOC_SPLIST(&arr, SP_TOKEN_ALLOW_WRAPPERS, SPCFG(wrapper).whitelist); | ||
| 391 | |||
| 392 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." SP_TOKEN_ENABLE, SPCFG(ini).enable); | ||
| 393 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." SP_TOKEN_SIM, SPCFG(ini).simulation); | ||
| 394 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." "policy_ro", SPCFG(ini).policy_readonly); | ||
| 395 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." "policy_silent_ro", SPCFG(ini).policy_silent_ro); | ||
| 396 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." "policy_silent_fail", SPCFG(ini).policy_silent_fail); | ||
| 397 | add_assoc_bool(&arr, SP_TOKEN_INI_PROTECTION "." "policy_drop", SPCFG(ini).policy_drop); | ||
| 398 | |||
| 399 | if (SPCFG(ini).entries && zend_hash_num_elements(SPCFG(ini).entries) > 0) { | ||
| 400 | zval arr_ini; | ||
| 401 | array_init(&arr_ini); | ||
| 402 | |||
| 403 | sp_ini_entry *sp_entry; | ||
| 404 | ZEND_HASH_FOREACH_PTR(SPCFG(ini).entries, sp_entry) | ||
| 405 | zval arr_ini_entry; | ||
| 406 | array_init(&arr_ini_entry); | ||
| 407 | add_assoc_bool(&arr_ini_entry, SP_TOKEN_SIM, sp_entry->simulation); | ||
| 408 | ADD_ASSOC_ZSTR(&arr_ini_entry, SP_TOKEN_KEY, sp_entry->key); | ||
| 409 | ADD_ASSOC_ZSTR(&arr_ini_entry, "msg", sp_entry->msg); | ||
| 410 | ADD_ASSOC_ZSTR(&arr_ini_entry, "set", sp_entry->set); | ||
| 411 | ADD_ASSOC_ZSTR(&arr_ini_entry, "min", sp_entry->min); | ||
| 412 | ADD_ASSOC_ZSTR(&arr_ini_entry, "max", sp_entry->max); | ||
| 413 | add_assoc_long(&arr_ini_entry, "access", sp_entry->access); | ||
| 414 | add_assoc_bool(&arr_ini_entry, "drop", sp_entry->drop); | ||
| 415 | add_assoc_bool(&arr_ini_entry, "allow_null", sp_entry->allow_null); | ||
| 416 | ADD_ASSOC_REGEXP(&arr_ini_entry, "regexp", sp_entry->regexp); | ||
| 417 | add_next_index_zval(&arr_ini, &arr_ini_entry); | ||
| 418 | ZEND_HASH_FOREACH_END(); | ||
| 419 | add_assoc_zval(&arr, SP_TOKEN_INI, &arr_ini); | ||
| 420 | } else { | ||
| 421 | add_assoc_null(&arr, SP_TOKEN_INI); | ||
| 422 | } | ||
| 423 | |||
| 424 | if (SPCFG(cookie).cookies && SPCFG(cookie).cookies->data) { | ||
| 425 | zval arr_cookies; | ||
| 426 | array_init(&arr_cookies); | ||
| 427 | |||
| 428 | sp_cookie *cookie; | ||
| 429 | sp_list_node *p = SPCFG(cookie).cookies; | ||
| 430 | for (; p; p = p->next) { | ||
| 431 | zval arr_cookie; | ||
| 432 | array_init(&arr_cookie); | ||
| 433 | cookie = (sp_cookie*)p->data; | ||
| 434 | |||
| 435 | add_assoc_long(&arr_cookie, SP_TOKEN_SAMESITE, cookie->samesite); | ||
| 436 | add_assoc_bool(&arr_cookie, SP_TOKEN_ENCRYPT, cookie->encrypt); | ||
| 437 | ADD_ASSOC_ZSTR(&arr_cookie, SP_TOKEN_NAME, cookie->name); | ||
| 438 | ADD_ASSOC_REGEXP(&arr_cookie, SP_TOKEN_NAME_REGEXP, cookie->name_r); | ||
| 439 | add_assoc_bool(&arr_cookie, SP_TOKEN_SIM, cookie->simulation); | ||
| 440 | |||
| 441 | add_next_index_zval(&arr_cookies, &arr_cookie); | ||
| 442 | } | ||
| 443 | |||
| 444 | add_assoc_zval(&arr, SP_TOKEN_COOKIE_ENCRYPTION, &arr_cookies); | ||
| 445 | } else { | ||
| 446 | add_assoc_null(&arr, SP_TOKEN_COOKIE_ENCRYPTION); | ||
| 447 | } | ||
| 448 | |||
| 449 | // disabled_functions | ||
| 450 | zval arr_dfs; | ||
| 451 | array_init(&arr_dfs); | ||
| 452 | size_t num_df = 0; | ||
| 453 | sp_list_node *dflist, *dfp; | ||
| 454 | ZEND_HASH_FOREACH_PTR(SPCFG(disabled_functions), dflist) | ||
| 455 | for (dfp = dflist; dfp; dfp = dfp->next) { | ||
| 456 | add_df_to_arr(&arr_dfs, dfp->data); | ||
| 457 | num_df++; | ||
| 458 | } | ||
| 459 | ZEND_HASH_FOREACH_END(); | ||
| 460 | ZEND_HASH_FOREACH_PTR(SPCFG(disabled_functions_ret), dflist) | ||
| 461 | for (dfp = dflist; dfp; dfp = dfp->next) { | ||
| 462 | add_df_to_arr(&arr_dfs, dfp->data); | ||
| 463 | num_df++; | ||
| 464 | } | ||
| 465 | ZEND_HASH_FOREACH_END(); | ||
| 466 | for (dfp = SPCFG(disabled_functions_reg).disabled_functions; dfp; dfp = dfp->next) { | ||
| 467 | add_df_to_arr(&arr_dfs, dfp->data); | ||
| 468 | num_df++; | ||
| 469 | } | ||
| 470 | for (dfp = SPCFG(disabled_functions_reg_ret).disabled_functions; dfp; dfp = dfp->next) { | ||
| 471 | add_df_to_arr(&arr_dfs, dfp->data); | ||
| 472 | num_df++; | ||
| 473 | } | ||
| 474 | |||
| 475 | if (num_df) { | ||
| 476 | add_assoc_zval(&arr, SP_TOKEN_DISABLE_FUNC, &arr_dfs); | ||
| 477 | } else { | ||
| 478 | add_assoc_null(&arr, SP_TOKEN_DISABLE_FUNC); | ||
| 479 | } | ||
| 480 | |||
| 481 | // serialize and print array | ||
| 482 | PHP_VAR_SERIALIZE_INIT(var_hash); | ||
| 483 | php_var_serialize(&buf, &arr, &var_hash); | ||
| 484 | PHP_VAR_SERIALIZE_DESTROY(var_hash); | ||
| 485 | |||
| 486 | printf("%s", ZSTR_VAL(buf.s)); | ||
| 487 | sp_log_debug("--"); | ||
| 488 | |||
| 489 | smart_str_free(&buf); | ||
| 490 | |||
| 491 | } | ||
| 492 | |||
| 493 | static PHP_INI_MH(OnUpdateConfiguration) { | ||
| 258 | TSRMLS_FETCH(); | 494 | TSRMLS_FETCH(); |
| 259 | 495 | ||
| 260 | if (!new_value || !new_value->len) { | 496 | if (!new_value || !new_value->len) { |
| 261 | return FAILURE; | 497 | return FAILURE; |
| 262 | } | 498 | } |
| 263 | 499 | ||
| 500 | // set some defaults | ||
| 501 | SPCFG(show_old_php_warning) = true; | ||
| 502 | |||
| 264 | char *str = new_value->val; | 503 | char *str = new_value->val; |
| 265 | 504 | ||
| 266 | while (1) { | 505 | while (1) { |
| @@ -270,14 +509,14 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 270 | 509 | ||
| 271 | glob_t globbuf; | 510 | glob_t globbuf; |
| 272 | if (0 != glob(config_file, GLOB_NOCHECK, NULL, &globbuf)) { | 511 | if (0 != glob(config_file, GLOB_NOCHECK, NULL, &globbuf)) { |
| 273 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_INVALID; | 512 | SPG(is_config_valid) = SP_CONFIG_INVALID; |
| 274 | globfree(&globbuf); | 513 | globfree(&globbuf); |
| 275 | return FAILURE; | 514 | return FAILURE; |
| 276 | } | 515 | } |
| 277 | 516 | ||
| 278 | for (size_t i = 0; globbuf.gl_pathv[i]; i++) { | 517 | for (size_t i = 0; globbuf.gl_pathv[i]; i++) { |
| 279 | if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) { | 518 | if (sp_parse_config(globbuf.gl_pathv[i]) != SUCCESS) { |
| 280 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_INVALID; | 519 | SPG(is_config_valid) = SP_CONFIG_INVALID; |
| 281 | globfree(&globbuf); | 520 | globfree(&globbuf); |
| 282 | return FAILURE; | 521 | return FAILURE; |
| 283 | } | 522 | } |
| @@ -285,43 +524,62 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 285 | globfree(&globbuf); | 524 | globfree(&globbuf); |
| 286 | } | 525 | } |
| 287 | 526 | ||
| 288 | SNUFFLEUPAGUS_G(is_config_valid) = SP_CONFIG_VALID; | 527 | SPG(is_config_valid) = SP_CONFIG_VALID; |
| 528 | |||
| 529 | // dump config | ||
| 530 | sp_log_debug("module name? %s", sapi_module.name); | ||
| 531 | if (getenv("SP_DUMP_CONFIG")) { | ||
| 532 | sp_log_debug("env? %s", getenv("SP_DUMP_CONFIG")); | ||
| 533 | } | ||
| 534 | |||
| 535 | if (strcmp(sapi_module.name, "cli") == 0 && getenv("SP_DUMP_CONFIG")) { | ||
| 536 | dump_config(); | ||
| 537 | return SUCCESS; | ||
| 538 | } | ||
| 539 | |||
| 289 | 540 | ||
| 290 | if ((SNUFFLEUPAGUS_G(config).config_sloppy->enable)) { | 541 | // start hooks |
| 542 | |||
| 543 | if (SPCFG(sloppy).enable) { | ||
| 291 | hook_sloppy(); | 544 | hook_sloppy(); |
| 292 | } | 545 | } |
| 293 | 546 | ||
| 294 | if (SNUFFLEUPAGUS_G(config).config_random->enable) { | 547 | if (SPCFG(random).enable) { |
| 295 | hook_rand(); | 548 | hook_rand(); |
| 296 | } | 549 | } |
| 297 | 550 | ||
| 298 | if (SNUFFLEUPAGUS_G(config).config_upload_validation->enable) { | 551 | if (SPCFG(upload_validation).enable) { |
| 299 | hook_upload(); | 552 | hook_upload(); |
| 300 | } | 553 | } |
| 301 | 554 | ||
| 302 | if (SNUFFLEUPAGUS_G(config).config_disable_xxe->enable == 0) { | 555 | if (SPCFG(xxe_protection).enable) { |
| 303 | hook_libxml_disable_entity_loader(); | 556 | hook_libxml_disable_entity_loader(); |
| 304 | } | 557 | } |
| 305 | 558 | ||
| 306 | if (SNUFFLEUPAGUS_G(config).config_wrapper->enabled) { | 559 | if (SPCFG(wrapper).enabled) { |
| 307 | hook_stream_wrappers(); | 560 | hook_stream_wrappers(); |
| 308 | } | 561 | } |
| 309 | 562 | ||
| 310 | if (SNUFFLEUPAGUS_G(config).config_session->encrypt) { | 563 | if (SPCFG(session).encrypt || SPCFG(session).sid_min_length || SPCFG(session).sid_max_length) { |
| 311 | hook_session(); | 564 | hook_session(); |
| 312 | } | 565 | } |
| 313 | 566 | ||
| 314 | if (NULL != SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key) { | 567 | if (NULL != SPCFG(encryption_key)) { |
| 315 | if (SNUFFLEUPAGUS_G(config).config_unserialize->enable) { | 568 | if (SPCFG(unserialize).enable) { |
| 316 | hook_serialize(); | 569 | hook_serialize(); |
| 317 | } | 570 | } |
| 318 | } | 571 | } |
| 319 | 572 | ||
| 320 | hook_disabled_functions(); | ||
| 321 | hook_execute(); | 573 | hook_execute(); |
| 322 | hook_cookies(); | 574 | hook_cookies(); |
| 323 | 575 | ||
| 324 | if (true == SNUFFLEUPAGUS_G(config).config_global_strict->enable) { | 576 | if (SPCFG(ini).enable) { |
| 577 | sp_hook_ini(); | ||
| 578 | } | ||
| 579 | |||
| 580 | sp_hook_register_server_variables(); | ||
| 581 | |||
| 582 | if (SPCFG(global_strict).enable) { | ||
| 325 | if (!zend_get_extension(PHP_SNUFFLEUPAGUS_EXTNAME)) { | 583 | if (!zend_get_extension(PHP_SNUFFLEUPAGUS_EXTNAME)) { |
| 326 | zend_extension_entry.startup = NULL; | 584 | zend_extension_entry.startup = NULL; |
| 327 | zend_register_extension(&zend_extension_entry, NULL); | 585 | zend_register_extension(&zend_extension_entry, NULL); |
| @@ -330,28 +588,31 @@ static PHP_INI_MH(OnUpdateConfiguration) { | |||
| 330 | CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; | 588 | CG(compiler_options) |= ZEND_COMPILE_HANDLE_OP_ARRAY; |
| 331 | } | 589 | } |
| 332 | 590 | ||
| 591 | hook_disabled_functions(); | ||
| 592 | |||
| 333 | // If `zend_write_default` is not NULL it is already hooked. | 593 | // If `zend_write_default` is not NULL it is already hooked. |
| 334 | if ((zend_hash_str_find( | 594 | if ((zend_hash_str_find(SPCFG(disabled_functions_hooked), ZEND_STRL("echo")) || |
| 335 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked, "echo", | 595 | zend_hash_str_find(SPCFG(disabled_functions_ret_hooked), ZEND_STRL("echo"))) && |
| 336 | sizeof("echo") - 1) || | ||
| 337 | zend_hash_str_find( | ||
| 338 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked, "echo", | ||
| 339 | sizeof("echo") - 1)) && | ||
| 340 | NULL == zend_write_default && zend_write != hook_echo) { | 596 | NULL == zend_write_default && zend_write != hook_echo) { |
| 341 | zend_write_default = zend_write; | 597 | zend_write_default = zend_write; |
| 342 | zend_write = hook_echo; | 598 | zend_write = hook_echo; |
| 343 | } | 599 | } |
| 344 | 600 | ||
| 345 | SNUFFLEUPAGUS_G(config).hook_execute = | 601 | SPG(hook_execute) = SPCFG(max_execution_depth) > 0 || |
| 346 | SNUFFLEUPAGUS_G(config) | 602 | SPCFG(disabled_functions_reg).disabled_functions || |
| 347 | .config_disabled_functions_reg->disabled_functions || | 603 | SPCFG(disabled_functions_reg_ret).disabled_functions || |
| 348 | SNUFFLEUPAGUS_G(config) | 604 | (SPCFG(disabled_functions) && zend_hash_num_elements(SPCFG(disabled_functions))) || |
| 349 | .config_disabled_functions_reg_ret->disabled_functions || | 605 | (SPCFG(disabled_functions_ret) && zend_hash_num_elements(SPCFG(disabled_functions_ret))); |
| 350 | zend_hash_num_elements( | ||
| 351 | SNUFFLEUPAGUS_G(config).config_disabled_functions) || | ||
| 352 | zend_hash_num_elements( | ||
| 353 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret); | ||
| 354 | 606 | ||
| 607 | if (SPCFG(show_old_php_warning) && getenv("SP_SKIP_OLD_PHP_CHECK") == NULL) { | ||
| 608 | time_t ts = time(NULL); | ||
| 609 | if ((PHP_VERSION_ID < 70300) || | ||
| 610 | (PHP_VERSION_ID < 70400 && ts >= (time_t)1638745200L) || | ||
| 611 | (PHP_VERSION_ID < 80000 && ts >= (time_t)1669590000L) || | ||
| 612 | (PHP_VERSION_ID < 80100 && ts >= (time_t)1700953200L)) { | ||
| 613 | sp_log_warn("End-of-Life Check", "Your PHP version '" PHP_VERSION "' is not officially mainained anymore. Please upgrade as soon as possible. - Note: This message can be switched off by setting 'sp.global.show_old_php_warning.disable();' in your rules file or by setting the environment variable SP_SKIP_OLD_PHP_CHECK=1."); | ||
| 614 | } | ||
| 615 | } | ||
| 355 | return SUCCESS; | 616 | return SUCCESS; |
| 356 | } | 617 | } |
| 357 | 618 | ||
| @@ -369,7 +630,7 @@ zend_module_entry snuffleupagus_module_entry = { | |||
| 369 | PHP_SNUFFLEUPAGUS_VERSION, | 630 | PHP_SNUFFLEUPAGUS_VERSION, |
| 370 | PHP_MODULE_GLOBALS(snuffleupagus), | 631 | PHP_MODULE_GLOBALS(snuffleupagus), |
| 371 | PHP_GINIT(snuffleupagus), | 632 | PHP_GINIT(snuffleupagus), |
| 372 | NULL, | 633 | PHP_GSHUTDOWN(snuffleupagus), |
| 373 | NULL, | 634 | NULL, |
| 374 | STANDARD_MODULE_PROPERTIES_EX}; | 635 | STANDARD_MODULE_PROPERTIES_EX}; |
| 375 | 636 | ||
diff --git a/src/sp_config.c b/src/sp_config.c index c12b435..7294b0e 100644 --- a/src/sp_config.c +++ b/src/sp_config.c | |||
| @@ -4,248 +4,302 @@ | |||
| 4 | 4 | ||
| 5 | #include "php_snuffleupagus.h" | 5 | #include "php_snuffleupagus.h" |
| 6 | 6 | ||
| 7 | size_t sp_line_no; | ||
| 8 | 7 | ||
| 9 | static sp_config_tokens const sp_func[] = { | 8 | static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) { |
| 10 | {.func = parse_unserialize, .token = SP_TOKEN_UNSERIALIZE_HMAC}, | 9 | sp_config_keyword sp_func[] = { |
| 11 | {.func = parse_random, .token = SP_TOKEN_HARDEN_RANDOM}, | 10 | {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))}, |
| 12 | {.func = parse_log_media, .token = SP_TOKEN_LOG_MEDIA}, | 11 | {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)}, |
| 13 | {.func = parse_disabled_functions, .token = SP_TOKEN_DISABLE_FUNC}, | 12 | {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, |
| 14 | {.func = parse_readonly_exec, .token = SP_TOKEN_READONLY_EXEC}, | 13 | {parse_disabled_functions, SP_TOKEN_DISABLE_FUNC, NULL}, |
| 15 | {.func = parse_global_strict, .token = SP_TOKEN_GLOBAL_STRICT}, | 14 | {parse_readonly_exec, SP_TOKEN_READONLY_EXEC, &(SPCFG(readonly_exec))}, |
| 16 | {.func = parse_upload_validation, .token = SP_TOKEN_UPLOAD_VALIDATION}, | 15 | {parse_enable, SP_TOKEN_GLOBAL_STRICT, &(SPCFG(global_strict).enable)}, |
| 17 | {.func = parse_cookie, .token = SP_TOKEN_COOKIE_ENCRYPTION}, | 16 | {parse_upload_validation, SP_TOKEN_UPLOAD_VALIDATION, &(SPCFG(upload_validation))}, |
| 18 | {.func = parse_global, .token = SP_TOKEN_GLOBAL}, | 17 | {parse_cookie, SP_TOKEN_COOKIE_ENCRYPTION, NULL}, |
| 19 | {.func = parse_auto_cookie_secure, .token = SP_TOKEN_AUTO_COOKIE_SECURE}, | 18 | {parse_global, SP_TOKEN_GLOBAL, NULL}, |
| 20 | {.func = parse_disable_xxe, .token = SP_TOKEN_DISABLE_XXE}, | 19 | {parse_enable, SP_TOKEN_AUTO_COOKIE_SECURE, &(SPCFG(auto_cookie_secure).enable)}, |
| 21 | {.func = parse_eval_blacklist, .token = SP_TOKEN_EVAL_BLACKLIST}, | 20 | {parse_enable, SP_TOKEN_XXE_PROTECTION, &(SPCFG(xxe_protection).enable)}, |
| 22 | {.func = parse_eval_whitelist, .token = SP_TOKEN_EVAL_WHITELIST}, | 21 | {parse_eval_filter_conf, SP_TOKEN_EVAL_BLACKLIST, &(SPCFG(eval).blacklist)}, |
| 23 | {.func = parse_session, .token = SP_TOKEN_SESSION_ENCRYPTION}, | 22 | {parse_eval_filter_conf, SP_TOKEN_EVAL_WHITELIST, &(SPCFG(eval).whitelist)}, |
| 24 | {.func = parse_sloppy_comparison, .token = SP_TOKEN_SLOPPY_COMPARISON}, | 23 | {parse_session, SP_TOKEN_SESSION_ENCRYPTION, &(SPCFG(session))}, |
| 25 | {.func = parse_wrapper_whitelist, .token = SP_TOKEN_ALLOW_WRAPPERS}, | 24 | {parse_enable, SP_TOKEN_SLOPPY_COMPARISON, &(SPCFG(sloppy).enable)}, |
| 26 | {NULL, NULL}}; | 25 | {parse_wrapper_whitelist, SP_TOKEN_ALLOW_WRAPPERS, &(SPCFG(wrapper))}, |
| 26 | {parse_ini_protection, SP_TOKEN_INI_PROTECTION, &(SPCFG(ini))}, | ||
| 27 | {parse_ini_entry, SP_TOKEN_INI, NULL}, | ||
| 28 | {NULL, NULL, NULL}}; | ||
| 29 | return sp_process_rule(parsed_rule, sp_func); | ||
| 30 | } | ||
| 27 | 31 | ||
| 28 | /* Top level keyword parsing */ | 32 | zend_result sp_parse_config(const char *filename) { |
| 33 | FILE *fd = fopen(filename, "rb"); | ||
| 34 | if (fd == NULL) { | ||
| 35 | sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno)); | ||
| 36 | return FAILURE; | ||
| 37 | } | ||
| 29 | 38 | ||
| 30 | static int parse_line(char *line) { | 39 | size_t step = 8192; |
| 31 | char *ptr = line; | 40 | size_t max_len = step, len = 0; |
| 41 | zend_string *data = zend_string_alloc(max_len, 0); | ||
| 42 | char *ptr = ZSTR_VAL(data); | ||
| 32 | 43 | ||
| 33 | while (*ptr == ' ' || *ptr == '\t') { | 44 | size_t bytes; |
| 34 | ++ptr; | 45 | while ((bytes = fread(ptr, 1, max_len - len, fd))) { |
| 46 | len += bytes; | ||
| 47 | if (max_len - len <= 0) { | ||
| 48 | max_len += step; | ||
| 49 | data = zend_string_extend(data, max_len, 0); | ||
| 50 | ptr = ZSTR_VAL(data) + len; | ||
| 51 | } else { | ||
| 52 | ptr += bytes; | ||
| 53 | } | ||
| 35 | } | 54 | } |
| 55 | fclose(fd); | ||
| 36 | 56 | ||
| 37 | if (!*ptr || *ptr == '#' || *ptr == ';') { | 57 | data = zend_string_truncate(data, len, 0); |
| 38 | return 0; | 58 | ZSTR_VAL(data)[len] = 0; |
| 39 | } | ||
| 40 | 59 | ||
| 41 | if (strncmp(ptr, SP_TOKEN_BASE, strlen(SP_TOKEN_BASE))) { | 60 | int ret = sp_config_scan(ZSTR_VAL(data), sp_process_config_root); |
| 42 | sp_log_err("config", "Invalid configuration prefix for '%s' on line %zu", | ||
| 43 | line, sp_line_no); | ||
| 44 | return -1; | ||
| 45 | } | ||
| 46 | ptr += strlen(SP_TOKEN_BASE); | ||
| 47 | 61 | ||
| 48 | for (size_t i = 0; sp_func[i].func; i++) { | 62 | zend_string_release_ex(data, 0); |
| 49 | if (!strncmp(sp_func[i].token, ptr, strlen(sp_func[i].token))) { | 63 | |
| 50 | return sp_func[i].func(ptr + strlen(sp_func[i].token)); | 64 | return ret; |
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, sp_config_keyword *config_keywords) { | ||
| 69 | for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) { | ||
| 70 | bool found_kw = false; | ||
| 71 | for (sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) { | ||
| 72 | if (kw->kwlen == strlen(ckw->token) && !strncmp(kw->kw, ckw->token, kw->kwlen)) { | ||
| 73 | if (ckw->func) { | ||
| 74 | int ret = ckw->func(ckw->token, kw, ckw->retval); | ||
| 75 | switch (ret) { | ||
| 76 | case SP_PARSER_SUCCESS: | ||
| 77 | break; | ||
| 78 | case SP_PARSER_ERROR: | ||
| 79 | return FAILURE; | ||
| 80 | case SP_PARSER_STOP: | ||
| 81 | return SUCCESS; | ||
| 82 | } | ||
| 83 | } | ||
| 84 | found_kw = true; | ||
| 85 | break; | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | if (!found_kw) { | ||
| 90 | zend_string *kwname = zend_string_init(kw->kw, kw->kwlen, 0); | ||
| 91 | sp_log_err("config", "Unexpected keyword '%s' on line %d", ZSTR_VAL(kwname), kw->lineno); | ||
| 92 | zend_string_release_ex(kwname, 0); | ||
| 93 | return FAILURE; | ||
| 51 | } | 94 | } |
| 52 | } | 95 | } |
| 53 | sp_log_err("config", "Invalid configuration section '%s' on line %zu", line, | 96 | return SUCCESS; |
| 54 | sp_line_no); | ||
| 55 | return -1; | ||
| 56 | } | 97 | } |
| 57 | 98 | ||
| 58 | /* keyword parsing */ | 99 | #define CHECK_DUPLICATE_KEYWORD(retval) \ |
| 59 | int parse_empty(char *restrict line, char *restrict keyword, void *retval) { | 100 | if (*(void**)(retval)) { \ |
| 101 | sp_log_err("config", "duplicate keyword '%s' on line %zu", token, kw->lineno); \ | ||
| 102 | return SP_PARSER_ERROR; } | ||
| 103 | |||
| 104 | |||
| 105 | SP_PARSEKW_FN(parse_empty) { | ||
| 106 | if (kw->arglen) { | ||
| 107 | sp_log_err("config", "Unexpected argument for keyword '%s' - it should be '%s()' on line %zu", token, token, kw->lineno); | ||
| 108 | return SP_PARSER_ERROR; | ||
| 109 | } | ||
| 110 | if (kw->argtype != SP_ARGTYPE_EMPTY) { | ||
| 111 | sp_log_err("config", "Missing paranthesis for keyword '%s' - it should be '%s()' on line %zu", token, token, kw->lineno); | ||
| 112 | return SP_PARSER_ERROR; | ||
| 113 | } | ||
| 60 | *(bool *)retval = true; | 114 | *(bool *)retval = true; |
| 61 | return 0; | 115 | return SP_PARSER_SUCCESS; |
| 62 | } | 116 | } |
| 63 | 117 | ||
| 64 | int parse_list(char *restrict line, char *restrict keyword, void *list_ptr) { | 118 | SP_PARSEKW_FN(parse_list) { |
| 65 | zend_string *value = NULL; | 119 | CHECK_DUPLICATE_KEYWORD(retval); |
| 66 | sp_list_node **list = list_ptr; | ||
| 67 | char *token, *tmp; | ||
| 68 | 120 | ||
| 69 | size_t consumed = 0; | 121 | sp_list_node **list = retval; |
| 70 | value = get_param(&consumed, line, SP_TYPE_STR, keyword); | 122 | char *tok, *tmp; |
| 71 | if (!value) { | 123 | |
| 72 | return -1; | 124 | SP_PARSE_ARG(value); |
| 73 | } | ||
| 74 | 125 | ||
| 75 | tmp = ZSTR_VAL(value); | 126 | tmp = ZSTR_VAL(value); |
| 76 | while (1) { | 127 | while (1) { |
| 77 | token = strsep(&tmp, ","); | 128 | tok = strsep(&tmp, ","); |
| 78 | if (token == NULL) { | 129 | if (tok == NULL) { |
| 79 | break; | 130 | break; |
| 80 | } | 131 | } |
| 81 | *list = sp_list_insert(*list, zend_string_init(token, strlen(token), 1)); | 132 | *list = sp_list_insert(*list, zend_string_init(tok, strlen(tok), 1)); |
| 82 | } | 133 | } |
| 134 | zend_string_release(value); | ||
| 83 | 135 | ||
| 84 | pefree(value, 1); | 136 | return SP_PARSER_SUCCESS; |
| 85 | return consumed; | ||
| 86 | } | 137 | } |
| 87 | 138 | ||
| 88 | int parse_php_type(char *restrict line, char *restrict keyword, void *retval) { | 139 | SP_PARSEKW_FN(parse_php_type) { |
| 89 | size_t consumed = 0; | 140 | SP_PARSE_ARG(value); |
| 90 | zend_string *value = get_param(&consumed, line, SP_TYPE_STR, keyword); | 141 | |
| 91 | if (value) { | 142 | if (zend_string_equals_literal_ci(value, "undef")) { |
| 92 | if (zend_string_equals_literal_ci(value, "undef")) { | 143 | *(sp_php_type *)retval = SP_PHP_TYPE_UNDEF; |
| 93 | *(sp_php_type *)retval = SP_PHP_TYPE_UNDEF; | 144 | } else if (zend_string_equals_literal_ci(value, "null")) { |
| 94 | } else if (zend_string_equals_literal_ci(value, "null")) { | 145 | *(sp_php_type *)retval = SP_PHP_TYPE_NULL; |
| 95 | *(sp_php_type *)retval = SP_PHP_TYPE_NULL; | 146 | } else if (zend_string_equals_literal_ci(value, "true")) { |
| 96 | } else if (zend_string_equals_literal_ci(value, "true")) { | 147 | *(sp_php_type *)retval = SP_PHP_TYPE_TRUE; |
| 97 | *(sp_php_type *)retval = SP_PHP_TYPE_TRUE; | 148 | } else if (zend_string_equals_literal_ci(value, "false")) { |
| 98 | } else if (zend_string_equals_literal_ci(value, "false")) { | 149 | *(sp_php_type *)retval = SP_PHP_TYPE_FALSE; |
| 99 | *(sp_php_type *)retval = SP_PHP_TYPE_FALSE; | 150 | } else if (zend_string_equals_literal_ci(value, "long")) { |
| 100 | } else if (zend_string_equals_literal_ci(value, "long")) { | 151 | *(sp_php_type *)retval = SP_PHP_TYPE_LONG; |
| 101 | *(sp_php_type *)retval = SP_PHP_TYPE_LONG; | 152 | } else if (zend_string_equals_literal_ci(value, "double")) { |
| 102 | } else if (zend_string_equals_literal_ci(value, "double")) { | 153 | *(sp_php_type *)retval = SP_PHP_TYPE_DOUBLE; |
| 103 | *(sp_php_type *)retval = SP_PHP_TYPE_DOUBLE; | 154 | } else if (zend_string_equals_literal_ci(value, "string")) { |
| 104 | } else if (zend_string_equals_literal_ci(value, "string")) { | 155 | *(sp_php_type *)retval = SP_PHP_TYPE_STRING; |
| 105 | *(sp_php_type *)retval = SP_PHP_TYPE_STRING; | 156 | } else if (zend_string_equals_literal_ci(value, "array")) { |
| 106 | } else if (zend_string_equals_literal_ci(value, "array")) { | 157 | *(sp_php_type *)retval = SP_PHP_TYPE_ARRAY; |
| 107 | *(sp_php_type *)retval = SP_PHP_TYPE_ARRAY; | 158 | } else if (zend_string_equals_literal_ci(value, "object")) { |
| 108 | } else if (zend_string_equals_literal_ci(value, "object")) { | 159 | *(sp_php_type *)retval = SP_PHP_TYPE_OBJECT; |
| 109 | *(sp_php_type *)retval = SP_PHP_TYPE_OBJECT; | 160 | } else if (zend_string_equals_literal_ci(value, "resource")) { |
| 110 | } else if (zend_string_equals_literal_ci(value, "resource")) { | 161 | *(sp_php_type *)retval = SP_PHP_TYPE_RESOURCE; |
| 111 | *(sp_php_type *)retval = SP_PHP_TYPE_RESOURCE; | 162 | } else if (zend_string_equals_literal_ci(value, "reference")) { |
| 112 | } else if (zend_string_equals_literal_ci(value, "reference")) { | 163 | *(sp_php_type *)retval = SP_PHP_TYPE_REFERENCE; |
| 113 | *(sp_php_type *)retval = SP_PHP_TYPE_REFERENCE; | ||
| 114 | } else { | ||
| 115 | pefree(value, 1); | ||
| 116 | sp_log_err("error", | ||
| 117 | "%s) is expecting a valid php type ('false', 'true'," | ||
| 118 | " 'array'. 'object', 'long', 'double', 'null', 'resource', " | ||
| 119 | "'reference', 'undef') on line %zu", | ||
| 120 | keyword, sp_line_no); | ||
| 121 | return -1; | ||
| 122 | } | ||
| 123 | pefree(value, 1); | ||
| 124 | return consumed; | ||
| 125 | } else { | 164 | } else { |
| 126 | return -1; | 165 | zend_string_release(value); |
| 166 | sp_log_err("error", ".%s() is expecting a valid php type ('false', 'true'," | ||
| 167 | " 'array'. 'object', 'long', 'double', 'null', 'resource', " | ||
| 168 | "'reference', 'undef') on line %zu", token, kw->lineno); | ||
| 169 | return SP_PARSER_ERROR; | ||
| 127 | } | 170 | } |
| 171 | zend_string_release(value); | ||
| 172 | return SP_PARSER_SUCCESS; | ||
| 128 | } | 173 | } |
| 129 | 174 | ||
| 130 | int parse_str(char *restrict line, char *restrict keyword, void *retval) { | ||
| 131 | zend_string *value = NULL; | ||
| 132 | 175 | ||
| 133 | size_t consumed = 0; | 176 | SP_PARSEKW_FN(parse_str) { |
| 134 | value = get_param(&consumed, line, SP_TYPE_STR, keyword); | 177 | CHECK_DUPLICATE_KEYWORD(retval); |
| 135 | if (value) { | 178 | SP_PARSE_ARG(value); |
| 136 | *(zend_string **)retval = value; | 179 | |
| 137 | return consumed; | 180 | *(zend_string **)retval = value; |
| 138 | } | 181 | |
| 139 | return -1; | 182 | return SP_PARSER_SUCCESS; |
| 140 | } | 183 | } |
| 141 | 184 | ||
| 142 | int parse_cidr(char *restrict line, char *restrict keyword, void *retval) { | 185 | SP_PARSEKW_FN(parse_int) { |
| 143 | size_t consumed = 0; | 186 | int ret = SP_PARSER_SUCCESS; |
| 144 | zend_string *value = get_param(&consumed, line, SP_TYPE_STR, keyword); | 187 | SP_PARSE_ARG(value); |
| 145 | sp_cidr *cidr = pecalloc(sizeof(sp_cidr), 1, 1); | ||
| 146 | 188 | ||
| 147 | if (value) { | 189 | char *endptr; |
| 148 | if (-1 == get_ip_and_cidr(ZSTR_VAL(value), cidr)) { | 190 | errno = 0; |
| 149 | return -1; | 191 | *(int*)retval = (int)strtoimax(ZSTR_VAL(value), &endptr, 10); |
| 150 | } | 192 | if (errno != 0 || !endptr || endptr == ZSTR_VAL(value)) { |
| 151 | *(sp_cidr **)retval = cidr; | 193 | sp_log_err("config", "Failed to parse arg '%s' of `%s` on line %zu", ZSTR_VAL(value), token, kw->lineno); |
| 152 | return consumed; | 194 | ret = SP_PARSER_ERROR; |
| 153 | } else { | ||
| 154 | sp_log_err("config", "%s doesn't contain a valid cidr on line %zu", line, | ||
| 155 | sp_line_no); | ||
| 156 | return -1; | ||
| 157 | } | 195 | } |
| 196 | zend_string_release(value); | ||
| 197 | return ret; | ||
| 158 | } | 198 | } |
| 159 | 199 | ||
| 160 | int parse_regexp(char *restrict line, char *restrict keyword, void *retval) { | 200 | SP_PARSEKW_FN(parse_ulong) { |
| 161 | /* TODO: Do we want to use pcre_study? | 201 | int ret = SP_PARSER_SUCCESS; |
| 162 | * (http://www.pcre.org/original/doc/html/pcre_study.html) | 202 | SP_PARSE_ARG(value); |
| 163 | * maybe not: http://sljit.sourceforge.net/pcre.html*/ | ||
| 164 | size_t consumed = 0; | ||
| 165 | zend_string *value = get_param(&consumed, line, SP_TYPE_STR, keyword); | ||
| 166 | 203 | ||
| 167 | if (value) { | 204 | char *endptr; |
| 168 | sp_pcre *compiled_re = sp_pcre_compile(ZSTR_VAL(value)); | 205 | errno = 0; |
| 169 | if (NULL != compiled_re) { | 206 | *(u_long*)retval = (u_long)strtoul(ZSTR_VAL(value), &endptr, 10); |
| 170 | *(sp_pcre **)retval = compiled_re; | 207 | if (errno != 0 || !endptr || endptr == ZSTR_VAL(value)) { |
| 171 | return consumed; | 208 | sp_log_err("config", "Failed to parse arg '%s' of `%s` on line %zu", ZSTR_VAL(value), token, kw->lineno); |
| 172 | } | 209 | ret = SP_PARSER_ERROR; |
| 173 | } | 210 | } |
| 174 | char *closing_paren = strchr(line, ')'); | 211 | zend_string_release(value); |
| 175 | if (NULL != closing_paren) { | 212 | return ret; |
| 176 | closing_paren[0] = '\0'; | ||
| 177 | } | ||
| 178 | sp_log_err("config", | ||
| 179 | "'%s)' is expecting a valid regexp, and not '%s' on line %zu", | ||
| 180 | keyword, line, sp_line_no); | ||
| 181 | return -1; | ||
| 182 | } | 213 | } |
| 183 | 214 | ||
| 184 | int sp_parse_config(const char *conf_file) { | 215 | SP_PARSEKW_FN(parse_cidr) { |
| 185 | FILE *fd = fopen(conf_file, "r"); | 216 | CHECK_DUPLICATE_KEYWORD(retval); |
| 186 | char *lineptr = NULL; | 217 | SP_PARSE_ARG(value); |
| 187 | size_t n = 0; | ||
| 188 | sp_line_no = 1; | ||
| 189 | 218 | ||
| 190 | if (fd == NULL) { | 219 | sp_cidr *cidr = pecalloc(sizeof(sp_cidr), 1, 1); |
| 191 | sp_log_err("config", "Could not open configuration file %s : %s", conf_file, | 220 | |
| 192 | strerror(errno)); | 221 | if (0 != get_ip_and_cidr(ZSTR_VAL(value), cidr)) { |
| 193 | return FAILURE; | 222 | pefree(cidr, 1); |
| 223 | cidr = NULL; | ||
| 194 | } | 224 | } |
| 195 | 225 | ||
| 196 | while (getline(&lineptr, &n, fd) > 0) { | 226 | *(sp_cidr **)retval = cidr; |
| 197 | /* We trash the terminal `\n`. This simplify the display of logs. */ | 227 | return cidr ? SP_PARSER_SUCCESS : SP_PARSER_ERROR; |
| 198 | if (lineptr[strlen(lineptr) - 1] == '\n') { | 228 | } |
| 199 | if (strlen(lineptr) >= 2 && lineptr[strlen(lineptr) - 2] == '\r') { | 229 | |
| 200 | lineptr[strlen(lineptr) - 2] = '\0'; | 230 | SP_PARSEKW_FN(parse_regexp) { |
| 201 | } else { | 231 | CHECK_DUPLICATE_KEYWORD(retval); |
| 202 | lineptr[strlen(lineptr) - 1] = '\0'; | 232 | SP_PARSE_ARG(value); |
| 203 | } | 233 | |
| 204 | } | 234 | sp_regexp *compiled_re = sp_regexp_compile(value); |
| 205 | if (parse_line(lineptr) == -1) { | 235 | if (!compiled_re) { |
| 206 | fclose(fd); | 236 | sp_log_err("config", "Invalid regexp '%s' for '.%s()' on line %zu", ZSTR_VAL(value), token, kw->lineno); |
| 207 | free(lineptr); | 237 | zend_string_release_ex(value, 1); |
| 208 | return FAILURE; | 238 | return SP_PARSER_ERROR; |
| 209 | } | ||
| 210 | free(lineptr); | ||
| 211 | lineptr = NULL; | ||
| 212 | n = 0; | ||
| 213 | sp_line_no++; | ||
| 214 | } | 239 | } |
| 215 | fclose(fd); | 240 | |
| 216 | return SUCCESS; | 241 | *(sp_regexp **)retval = compiled_re; |
| 242 | |||
| 243 | return SP_PARSER_SUCCESS; | ||
| 217 | } | 244 | } |
| 218 | 245 | ||
| 219 | void sp_disabled_function_list_free(sp_list_node *list) { | 246 | void sp_free_disabled_function(void *data) { |
| 220 | sp_list_node *cursor = list; | 247 | sp_disabled_function *df = data; |
| 221 | while (cursor) { | ||
| 222 | sp_disabled_function *df = cursor->data; | ||
| 223 | if (df) { | ||
| 224 | sp_list_free(df->functions_list); | ||
| 225 | sp_list_free(df->param_array_keys); | ||
| 226 | sp_list_free(df->var_array_keys); | ||
| 227 | 248 | ||
| 228 | sp_pcre_free(df->r_filename); | 249 | sp_free_zstr(df->textual_representation); |
| 229 | sp_pcre_free(df->r_function); | ||
| 230 | sp_pcre_free(df->r_param); | ||
| 231 | sp_pcre_free(df->r_ret); | ||
| 232 | sp_pcre_free(df->r_value); | ||
| 233 | sp_pcre_free(df->r_key); | ||
| 234 | 250 | ||
| 235 | sp_tree_free(df->param); | 251 | sp_free_zstr(df->filename); |
| 236 | sp_tree_free(df->var); | 252 | sp_regexp_free(df->r_filename); |
| 237 | } | 253 | |
| 238 | cursor = cursor->next; | 254 | sp_free_zstr(df->function); |
| 239 | } | 255 | sp_regexp_free(df->r_function); |
| 256 | sp_list_free(df->functions_list, free); | ||
| 257 | |||
| 258 | sp_free_zstr(df->hash); | ||
| 259 | |||
| 260 | sp_tree_free(df->param); | ||
| 261 | sp_regexp_free(df->r_param); | ||
| 262 | |||
| 263 | sp_regexp_free(df->r_ret); | ||
| 264 | sp_free_zstr(df->ret); | ||
| 265 | |||
| 266 | sp_regexp_free(df->r_value); | ||
| 267 | sp_free_zstr(df->value); | ||
| 268 | |||
| 269 | sp_regexp_free(df->r_key); | ||
| 270 | sp_free_zstr(df->key); | ||
| 271 | |||
| 272 | sp_free_zstr(df->dump); | ||
| 273 | sp_free_zstr(df->alias); | ||
| 274 | |||
| 275 | // sp_list_free(df->param_array_keys); | ||
| 276 | // sp_list_free(df->var_array_keys); | ||
| 277 | |||
| 278 | sp_tree_free(df->var); | ||
| 279 | |||
| 280 | pefree(df->cidr, 1); | ||
| 240 | } | 281 | } |
| 241 | 282 | ||
| 242 | void sp_cookie_list_free(sp_list_node *list) { | 283 | void sp_free_cookie(void *data) { |
| 243 | sp_list_node *cursor = list; | 284 | sp_cookie *c = data; |
| 244 | while (cursor) { | 285 | if (c->name) |
| 245 | sp_cookie *c = cursor->data; | 286 | zend_string_release_ex(c->name, 1); |
| 246 | if (c) { | 287 | sp_regexp_free(c->name_r); |
| 247 | sp_pcre_free(c->name_r); | 288 | } |
| 248 | } | 289 | |
| 249 | cursor = cursor->next; | 290 | void sp_free_zstr(void *data) { |
| 291 | if (data) { | ||
| 292 | zend_string_release_ex((zend_string*)data, 1); | ||
| 250 | } | 293 | } |
| 251 | } | 294 | } |
| 295 | |||
| 296 | void sp_free_ini_entry(void *data) { | ||
| 297 | sp_ini_entry *entry = data; | ||
| 298 | |||
| 299 | sp_free_zstr(entry->key); | ||
| 300 | sp_free_zstr(entry->min); | ||
| 301 | sp_free_zstr(entry->max); | ||
| 302 | sp_regexp_free(entry->regexp); | ||
| 303 | sp_free_zstr(entry->msg); | ||
| 304 | sp_free_zstr(entry->set); | ||
| 305 | } | ||
diff --git a/src/sp_config.h b/src/sp_config.h index e7b1473..6d48240 100644 --- a/src/sp_config.h +++ b/src/sp_config.h | |||
| @@ -5,15 +5,6 @@ | |||
| 5 | #include <netinet/in.h> | 5 | #include <netinet/in.h> |
| 6 | #include <sys/socket.h> | 6 | #include <sys/socket.h> |
| 7 | 7 | ||
| 8 | extern size_t sp_line_no; | ||
| 9 | |||
| 10 | typedef enum { | ||
| 11 | SP_TYPE_STR = 0, | ||
| 12 | SP_TYPE_REGEXP, | ||
| 13 | SP_TYPE_INT, | ||
| 14 | SP_TYPE_EMPTY | ||
| 15 | } sp_type; | ||
| 16 | |||
| 17 | typedef enum { | 8 | typedef enum { |
| 18 | SP_PHP_TYPE_UNDEF = IS_UNDEF, | 9 | SP_PHP_TYPE_UNDEF = IS_UNDEF, |
| 19 | SP_PHP_TYPE_NULL = IS_NULL, | 10 | SP_PHP_TYPE_NULL = IS_NULL, |
| @@ -30,6 +21,8 @@ typedef enum { | |||
| 30 | 21 | ||
| 31 | typedef enum { SP_ZEND = 0, SP_SYSLOG = 1 } sp_log_media; | 22 | typedef enum { SP_ZEND = 0, SP_SYSLOG = 1 } sp_log_media; |
| 32 | 23 | ||
| 24 | typedef enum { SP_UNSET = 0, SP_READONLY = 1, SP_READWRITE = -1 } sp_ini_permission; | ||
| 25 | |||
| 33 | typedef struct { | 26 | typedef struct { |
| 34 | int ip_version; | 27 | int ip_version; |
| 35 | union { | 28 | union { |
| @@ -40,11 +33,6 @@ typedef struct { | |||
| 40 | } sp_cidr; | 33 | } sp_cidr; |
| 41 | 34 | ||
| 42 | typedef struct { | 35 | typedef struct { |
| 43 | zend_string *encryption_key; | ||
| 44 | zend_string *cookies_env_var; | ||
| 45 | } sp_config_global; | ||
| 46 | |||
| 47 | typedef struct { | ||
| 48 | bool enable; | 36 | bool enable; |
| 49 | bool simulation; | 37 | bool simulation; |
| 50 | zend_string *dump; | 38 | zend_string *dump; |
| @@ -69,13 +57,13 @@ typedef struct { | |||
| 69 | 57 | ||
| 70 | typedef struct { | 58 | typedef struct { |
| 71 | bool enable; | 59 | bool enable; |
| 72 | } sp_config_disable_xxe; | 60 | } sp_config_xxe_protection; |
| 73 | 61 | ||
| 74 | typedef struct { | 62 | typedef struct { |
| 75 | enum samesite_type { strict = 1, lax = 2 } samesite; | 63 | enum samesite_type { strict = 1, lax = 2 } samesite; |
| 76 | bool encrypt; | 64 | bool encrypt; |
| 77 | zend_string *name; | 65 | zend_string *name; |
| 78 | sp_pcre *name_r; | 66 | sp_regexp *name_r; |
| 79 | bool simulation; | 67 | bool simulation; |
| 80 | } sp_cookie; | 68 | } sp_cookie; |
| 81 | 69 | ||
| @@ -88,6 +76,8 @@ typedef struct { | |||
| 88 | typedef struct { | 76 | typedef struct { |
| 89 | bool encrypt; | 77 | bool encrypt; |
| 90 | bool simulation; | 78 | bool simulation; |
| 79 | u_long sid_min_length; | ||
| 80 | u_long sid_max_length; | ||
| 91 | } sp_config_session; | 81 | } sp_config_session; |
| 92 | 82 | ||
| 93 | typedef struct { | 83 | typedef struct { |
| @@ -101,37 +91,37 @@ typedef struct { | |||
| 101 | zend_string *textual_representation; | 91 | zend_string *textual_representation; |
| 102 | 92 | ||
| 103 | zend_string *filename; | 93 | zend_string *filename; |
| 104 | sp_pcre *r_filename; | 94 | sp_regexp *r_filename; |
| 105 | 95 | ||
| 106 | zend_string *function; | 96 | zend_string *function; |
| 107 | sp_pcre *r_function; | 97 | sp_regexp *r_function; |
| 108 | sp_list_node *functions_list; | 98 | sp_list_node *functions_list; |
| 109 | 99 | ||
| 110 | zend_string *hash; | 100 | zend_string *hash; |
| 111 | int simulation; | 101 | int simulation; |
| 112 | 102 | ||
| 113 | sp_tree *param; | 103 | sp_tree *param; |
| 114 | sp_pcre *r_param; | 104 | sp_regexp *r_param; |
| 115 | sp_php_type param_type; | 105 | sp_php_type param_type; |
| 116 | int pos; | 106 | int pos; |
| 117 | unsigned int line; | 107 | unsigned int line; |
| 118 | 108 | ||
| 119 | sp_pcre *r_ret; | 109 | sp_regexp *r_ret; |
| 120 | zend_string *ret; | 110 | zend_string *ret; |
| 121 | sp_php_type ret_type; | 111 | sp_php_type ret_type; |
| 122 | 112 | ||
| 123 | sp_pcre *r_value; | 113 | sp_regexp *r_value; |
| 124 | zend_string *value; | 114 | zend_string *value; |
| 125 | 115 | ||
| 126 | sp_pcre *r_key; | 116 | sp_regexp *r_key; |
| 127 | zend_string *key; | 117 | zend_string *key; |
| 128 | 118 | ||
| 129 | zend_string *dump; | 119 | zend_string *dump; |
| 130 | zend_string *alias; | 120 | zend_string *alias; |
| 131 | bool param_is_array; | 121 | bool param_is_array; |
| 132 | bool var_is_array; | 122 | bool var_is_array; |
| 133 | sp_list_node *param_array_keys; | 123 | // sp_list_node *param_array_keys; |
| 134 | sp_list_node *var_array_keys; | 124 | // sp_list_node *var_array_keys; |
| 135 | 125 | ||
| 136 | bool allow; | 126 | bool allow; |
| 137 | 127 | ||
| @@ -163,125 +153,149 @@ typedef struct { | |||
| 163 | } sp_config_upload_validation; | 153 | } sp_config_upload_validation; |
| 164 | 154 | ||
| 165 | typedef struct { | 155 | typedef struct { |
| 166 | sp_config_random *config_random; | 156 | zend_string *key; |
| 167 | sp_config_sloppy *config_sloppy; | 157 | sp_ini_permission access; |
| 168 | sp_config_unserialize *config_unserialize; | 158 | zend_string *min; |
| 169 | sp_config_readonly_exec *config_readonly_exec; | 159 | zend_string *max; |
| 170 | sp_config_upload_validation *config_upload_validation; | 160 | sp_regexp *regexp; |
| 171 | sp_config_cookie *config_cookie; | 161 | zend_string *msg; |
| 172 | sp_config_global *config_snuffleupagus; | 162 | zend_string *set; |
| 173 | sp_config_auto_cookie_secure *config_auto_cookie_secure; | 163 | bool allow_null; |
| 174 | sp_config_global_strict *config_global_strict; | 164 | bool simulation; |
| 175 | sp_config_disable_xxe *config_disable_xxe; | 165 | bool drop; |
| 176 | sp_config_eval *config_eval; | 166 | PHP_INI_MH((*orig_onmodify)); |
| 177 | sp_config_wrapper *config_wrapper; | 167 | } sp_ini_entry; |
| 178 | sp_config_session *config_session; | 168 | |
| 179 | bool hook_execute; | 169 | typedef struct { |
| 180 | char log_media; | 170 | bool enable; |
| 171 | bool simulation; | ||
| 172 | bool policy_readonly; | ||
| 173 | bool policy_silent_ro; | ||
| 174 | bool policy_silent_fail; | ||
| 175 | bool policy_drop; | ||
| 176 | HashTable *entries; // ht of sp_ini_entry | ||
| 177 | } sp_config_ini; | ||
| 181 | 178 | ||
| 182 | HashTable *config_disabled_functions; | 179 | #define SP_PARSE_FN_(fname, kwvar) int fname(char *token, sp_parsed_keyword *kwvar, void *retval) |
| 183 | HashTable *config_disabled_functions_hooked; | 180 | #define SP_PARSE_FN(fname) SP_PARSE_FN_(fname, parsed_rule) |
| 184 | HashTable *config_disabled_functions_ret; | 181 | #define SP_PARSEKW_FN(fname) SP_PARSE_FN_(fname, kw) |
| 185 | HashTable *config_disabled_functions_ret_hooked; | ||
| 186 | sp_config_disabled_functions *config_disabled_functions_reg; | ||
| 187 | sp_config_disabled_functions *config_disabled_functions_reg_ret; | ||
| 188 | } sp_config; | ||
| 189 | 182 | ||
| 190 | typedef struct { | 183 | typedef struct { |
| 191 | int (*func)(char *, char *, void *); | 184 | SP_PARSE_FN((*func)); |
| 192 | char *token; | 185 | char *token; |
| 193 | void *retval; | 186 | void *retval; |
| 194 | } sp_config_functions; | 187 | } sp_config_keyword; |
| 195 | 188 | ||
| 196 | typedef struct { | 189 | #define SP_PARSER_SUCCESS 0 |
| 197 | int (*func)(char *); | 190 | #define SP_PARSER_ERROR -1 |
| 198 | char *token; | 191 | #define SP_PARSER_STOP 1 |
| 199 | } sp_config_tokens; | ||
| 200 | 192 | ||
| 201 | #define SP_TOKEN_BASE "sp" | 193 | // #define SP_TOKEN_BASE "sp" |
| 202 | 194 | ||
| 203 | #define SP_TOKEN_AUTO_COOKIE_SECURE ".auto_cookie_secure" | 195 | #define SP_TOKEN_AUTO_COOKIE_SECURE "auto_cookie_secure" |
| 204 | #define SP_TOKEN_COOKIE_ENCRYPTION ".cookie" | 196 | #define SP_TOKEN_COOKIE_ENCRYPTION "cookie" |
| 205 | #define SP_TOKEN_SESSION_ENCRYPTION ".session" | 197 | #define SP_TOKEN_SESSION_ENCRYPTION "session" |
| 206 | #define SP_TOKEN_DISABLE_FUNC ".disable_function" | 198 | #define SP_TOKEN_DISABLE_FUNC "disable_function" |
| 207 | #define SP_TOKEN_GLOBAL ".global" | 199 | #define SP_TOKEN_GLOBAL "global" |
| 208 | #define SP_TOKEN_GLOBAL_STRICT ".global_strict" | 200 | #define SP_TOKEN_GLOBAL_STRICT "global_strict" |
| 209 | #define SP_TOKEN_HARDEN_RANDOM ".harden_random" | 201 | #define SP_TOKEN_HARDEN_RANDOM "harden_random" |
| 210 | #define SP_TOKEN_READONLY_EXEC ".readonly_exec" | 202 | #define SP_TOKEN_READONLY_EXEC "readonly_exec" |
| 211 | #define SP_TOKEN_UNSERIALIZE_HMAC ".unserialize_hmac" | 203 | #define SP_TOKEN_UNSERIALIZE_HMAC "unserialize_hmac" |
| 212 | #define SP_TOKEN_UPLOAD_VALIDATION ".upload_validation" | 204 | #define SP_TOKEN_UPLOAD_VALIDATION "upload_validation" |
| 213 | #define SP_TOKEN_DISABLE_XXE ".disable_xxe" | 205 | #define SP_TOKEN_XXE_PROTECTION "xxe_protection" |
| 214 | #define SP_TOKEN_EVAL_BLACKLIST ".eval_blacklist" | 206 | #define SP_TOKEN_EVAL_BLACKLIST "eval_blacklist" |
| 215 | #define SP_TOKEN_EVAL_WHITELIST ".eval_whitelist" | 207 | #define SP_TOKEN_EVAL_WHITELIST "eval_whitelist" |
| 216 | #define SP_TOKEN_SLOPPY_COMPARISON ".sloppy_comparison" | 208 | #define SP_TOKEN_SLOPPY_COMPARISON "sloppy_comparison" |
| 217 | #define SP_TOKEN_ALLOW_WRAPPERS ".wrappers_whitelist" | 209 | #define SP_TOKEN_ALLOW_WRAPPERS "wrappers_whitelist" |
| 210 | #define SP_TOKEN_INI_PROTECTION "ini_protection" | ||
| 211 | #define SP_TOKEN_INI "ini" | ||
| 218 | 212 | ||
| 219 | // common tokens | 213 | // common tokens |
| 220 | #define SP_TOKEN_ENABLE ".enable(" | 214 | #define SP_TOKEN_ENABLE "enable" |
| 221 | #define SP_TOKEN_DISABLE ".disable(" | 215 | #define SP_TOKEN_DISABLE "disable" |
| 222 | #define SP_TOKEN_SIMULATION ".simulation(" | 216 | #define SP_TOKEN_SIMULATION "simulation" |
| 223 | #define SP_TOKEN_TRUE "1" | 217 | #define SP_TOKEN_SIM "sim" |
| 224 | #define SP_TOKEN_FALSE "0" | 218 | // #define SP_TOKEN_TRUE "1" |
| 225 | #define SP_TOKEN_DUMP ".dump(" | 219 | // #define SP_TOKEN_FALSE "0" |
| 226 | #define SP_TOKEN_ALIAS ".alias(" | 220 | #define SP_TOKEN_DUMP "dump" |
| 227 | #define SP_TOKEN_ALLOW ".allow(" | 221 | #define SP_TOKEN_ALIAS "alias" |
| 228 | #define SP_TOKEN_DROP ".drop(" | 222 | #define SP_TOKEN_ALLOW "allow" |
| 229 | 223 | #define SP_TOKEN_DROP "drop" | |
| 230 | #define SP_TOKEN_END_PARAM ')' | ||
| 231 | 224 | ||
| 232 | // disable_function | 225 | // disable_function |
| 233 | #define SP_TOKEN_CIDR ".cidr(" | 226 | #define SP_TOKEN_CIDR "cidr" |
| 234 | #define SP_TOKEN_FILENAME ".filename(" | 227 | #define SP_TOKEN_FILENAME "filename" |
| 235 | #define SP_TOKEN_FILENAME_REGEXP ".filename_r(" | 228 | #define SP_TOKEN_FILENAME_REGEXP "filename_r" |
| 236 | #define SP_TOKEN_FUNCTION ".function(" | 229 | #define SP_TOKEN_FUNCTION "function" |
| 237 | #define SP_TOKEN_FUNCTION_REGEXP ".function_r(" | 230 | #define SP_TOKEN_FUNCTION_REGEXP "function_r" |
| 238 | #define SP_TOKEN_HASH ".hash(" | 231 | #define SP_TOKEN_HASH "hash" |
| 239 | #define SP_TOKEN_LOCAL_VAR ".var(" | 232 | #define SP_TOKEN_LOCAL_VAR "var" |
| 240 | #define SP_TOKEN_PARAM ".param(" | 233 | #define SP_TOKEN_PARAM "param" |
| 241 | #define SP_TOKEN_PARAM_REGEXP ".param_r(" | 234 | #define SP_TOKEN_PARAM_REGEXP "param_r" |
| 242 | #define SP_TOKEN_PARAM_TYPE ".param_type(" | 235 | #define SP_TOKEN_PARAM_TYPE "param_type" |
| 243 | #define SP_TOKEN_RET ".ret(" | 236 | #define SP_TOKEN_RET "ret" |
| 244 | #define SP_TOKEN_RET_REGEXP ".ret_r(" | 237 | #define SP_TOKEN_RET_REGEXP "ret_r" |
| 245 | #define SP_TOKEN_RET_TYPE ".ret_type(" | 238 | #define SP_TOKEN_RET_TYPE "ret_type" |
| 246 | #define SP_TOKEN_VALUE ".value(" | 239 | #define SP_TOKEN_VALUE "value" |
| 247 | #define SP_TOKEN_VALUE_REGEXP ".value_r(" | 240 | #define SP_TOKEN_VALUE_REGEXP "value_r" |
| 248 | #define SP_TOKEN_KEY ".key(" | 241 | #define SP_TOKEN_KEY "key" |
| 249 | #define SP_TOKEN_KEY_REGEXP ".key_r(" | 242 | #define SP_TOKEN_KEY_REGEXP "key_r" |
| 250 | #define SP_TOKEN_VALUE_ARG_POS ".pos(" | 243 | #define SP_TOKEN_VALUE_ARG_POS "pos" |
| 251 | #define SP_TOKEN_LINE_NUMBER ".line(" | 244 | #define SP_TOKEN_LINE_NUMBER "line" |
| 252 | 245 | ||
| 253 | // cookies encryption | 246 | // cookies encryption |
| 254 | #define SP_TOKEN_NAME ".name(" | 247 | #define SP_TOKEN_NAME "name" |
| 255 | #define SP_TOKEN_NAME_REGEXP ".name_r(" | 248 | #define SP_TOKEN_NAME_REGEXP "name_r" |
| 256 | 249 | ||
| 257 | // cookies samesite | 250 | // cookies samesite |
| 258 | #define SP_TOKEN_SAMESITE ".samesite(" | 251 | #define SP_TOKEN_SAMESITE "samesite" |
| 259 | #define SP_TOKEN_ENCRYPT ".encrypt(" | 252 | #define SP_TOKEN_ENCRYPT "encrypt" |
| 260 | #define SP_TOKEN_SAMESITE_LAX "Lax" | 253 | #define SP_TOKEN_SAMESITE_LAX "Lax" |
| 261 | #define SP_TOKEN_SAMESITE_STRICT "Strict" | 254 | #define SP_TOKEN_SAMESITE_STRICT "Strict" |
| 262 | 255 | ||
| 263 | // Global configuration options | 256 | // Global configuration options |
| 264 | #define SP_TOKEN_ENCRYPTION_KEY ".secret_key(" | 257 | #define SP_TOKEN_ENCRYPTION_KEY "secret_key" |
| 265 | #define SP_TOKEN_ENV_VAR ".cookie_env_var(" | 258 | #define SP_TOKEN_ENV_VAR "cookie_env_var" |
| 266 | #define SP_TOKEN_LOG_MEDIA ".log_media(" | 259 | #define SP_TOKEN_LOG_MEDIA "log_media" |
| 260 | #define SP_TOKEN_MAX_EXECUTION_DEPTH "max_execution_depth" | ||
| 261 | #define SP_TOKEN_SERVER_ENCODE "server_encode" | ||
| 262 | #define SP_TOKEN_SERVER_STRIP "server_strip" | ||
| 263 | #define SP_TOKEN_SID_MIN_LENGTH "sid_min_length" | ||
| 264 | #define SP_TOKEN_SID_MAX_LENGTH "sid_max_length" | ||
| 265 | #define SP_TOKEN_SHOW_OLD_PHP_WARNING "show_old_php_warning" | ||
| 267 | 266 | ||
| 268 | // upload_validator | 267 | // upload_validator |
| 269 | #define SP_TOKEN_UPLOAD_SCRIPT ".script(" | 268 | #define SP_TOKEN_UPLOAD_SCRIPT "script" |
| 269 | |||
| 270 | #define SP_TOKEN_LIST "list" | ||
| 271 | |||
| 272 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, sp_config_keyword *config_keywords); | ||
| 273 | |||
| 274 | zend_result sp_parse_config(const char *filename); | ||
| 270 | 275 | ||
| 271 | #define SP_TOKEN_LIST ".list(" | 276 | #define SP_PARSE_CHECK_ARG_EXISTS(value) \ |
| 277 | if (!value) { \ | ||
| 278 | sp_log_err("config", "Missing argument to keyword '%s' - it should be '%s(\"...\")' on line %zu", token, token, kw->lineno); \ | ||
| 279 | return SP_PARSER_ERROR; \ | ||
| 280 | } | ||
| 272 | 281 | ||
| 273 | int sp_parse_config(const char *); | 282 | #define SP_PARSE_ARG(value) \ |
| 274 | int parse_array(sp_disabled_function *); | 283 | zend_string *value = sp_get_arg_string(kw); \ |
| 284 | SP_PARSE_CHECK_ARG_EXISTS(value); | ||
| 275 | 285 | ||
| 276 | int parse_str(char *restrict, char *restrict, void *); | 286 | SP_PARSEKW_FN(parse_str); |
| 277 | int parse_regexp(char *restrict, char *restrict, void *); | 287 | SP_PARSEKW_FN(parse_regexp); |
| 278 | int parse_empty(char *restrict, char *restrict, void *); | 288 | SP_PARSEKW_FN(parse_empty); |
| 279 | int parse_cidr(char *restrict, char *restrict, void *); | 289 | SP_PARSEKW_FN(parse_int); |
| 280 | int parse_php_type(char *restrict, char *restrict, void *); | 290 | SP_PARSEKW_FN(parse_ulong); |
| 281 | int parse_list(char *restrict, char *restrict, void *); | 291 | SP_PARSEKW_FN(parse_php_type); |
| 292 | SP_PARSEKW_FN(parse_cidr); | ||
| 293 | SP_PARSEKW_FN(parse_list); | ||
| 282 | 294 | ||
| 283 | // cleanup | 295 | // cleanup |
| 284 | void sp_disabled_function_list_free(sp_list_node *); | 296 | void sp_free_disabled_function(void *data); |
| 285 | void sp_cookie_list_free(sp_list_node *); | 297 | void sp_free_cookie(void *data); |
| 298 | void sp_free_zstr(void *data); | ||
| 299 | void sp_free_ini_entry(void *data); | ||
| 286 | 300 | ||
| 287 | #endif /* SP_CONFIG_H */ | 301 | #endif /* SP_CONFIG_H */ |
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c index 325ee6c..9a9b608 100644 --- a/src/sp_config_keywords.c +++ b/src/sp_config_keywords.c | |||
| @@ -1,321 +1,246 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | static int parse_enable(char *line, bool *restrict retval, | 3 | #define SP_SET_ENABLE_DISABLE(enable, disable, varname) \ |
| 4 | bool *restrict simulation) { | 4 | if (enable && disable) { \ |
| 5 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", parsed_rule->lineno); \ | ||
| 6 | return SP_PARSER_ERROR; \ | ||
| 7 | } \ | ||
| 8 | if (enable || disable) { \ | ||
| 9 | (varname) = (enable || !disable); \ | ||
| 10 | } | ||
| 11 | |||
| 12 | #define SP_PROCESS_CONFIG_KEYWORDS(CMD) if (sp_process_rule(&(parsed_rule[1]), config_keywords) != SUCCESS) { CMD; } | ||
| 13 | #define SP_PROCESS_CONFIG_KEYWORDS_ERR() SP_PROCESS_CONFIG_KEYWORDS(return SP_PARSER_ERROR) | ||
| 14 | |||
| 15 | SP_PARSE_FN(parse_enable) { | ||
| 5 | bool enable = false, disable = false; | 16 | bool enable = false, disable = false; |
| 6 | sp_config_functions sp_config_funcs[] = { | 17 | sp_config_keyword config_keywords[] = { |
| 7 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | 18 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, |
| 8 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | 19 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, |
| 9 | {parse_empty, SP_TOKEN_SIMULATION, simulation}, | ||
| 10 | {0, 0, 0}}; | 20 | {0, 0, 0}}; |
| 11 | 21 | ||
| 12 | int ret = parse_keywords(sp_config_funcs, line); | 22 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 13 | |||
| 14 | if (0 != ret) { | ||
| 15 | return ret; | ||
| 16 | } | ||
| 17 | |||
| 18 | if (!(enable ^ disable)) { | ||
| 19 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", | ||
| 20 | sp_line_no); | ||
| 21 | return -1; | ||
| 22 | } | ||
| 23 | 23 | ||
| 24 | *retval = enable; | 24 | SP_SET_ENABLE_DISABLE(enable, disable, *(bool*)retval); |
| 25 | 25 | ||
| 26 | return ret; | 26 | return SP_PARSER_STOP; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | int parse_session(char *line) { | 29 | SP_PARSE_FN(parse_session) { |
| 30 | sp_config_session *session = pecalloc(sizeof(sp_config_session), 1, 0); | 30 | sp_config_session *cfg = retval; |
| 31 | 31 | ||
| 32 | sp_config_functions sp_config_funcs_session_encryption[] = { | 32 | sp_config_keyword config_keywords[] = { |
| 33 | {parse_empty, SP_TOKEN_ENCRYPT, &(session->encrypt)}, | 33 | {parse_empty, SP_TOKEN_ENCRYPT, &(cfg->encrypt)}, |
| 34 | {parse_empty, SP_TOKEN_SIMULATION, &(session->simulation)}, | 34 | {parse_empty, SP_TOKEN_SIMULATION, &(cfg->simulation)}, |
| 35 | {parse_empty, SP_TOKEN_SIM, &(cfg->simulation)}, | ||
| 36 | {parse_ulong, SP_TOKEN_SID_MIN_LENGTH, &(cfg->sid_min_length)}, | ||
| 37 | {parse_ulong, SP_TOKEN_SID_MAX_LENGTH, &(cfg->sid_max_length)}, | ||
| 35 | {0, 0, 0}}; | 38 | {0, 0, 0}}; |
| 36 | int ret = parse_keywords(sp_config_funcs_session_encryption, line); | ||
| 37 | if (0 != ret) { | ||
| 38 | return ret; | ||
| 39 | } | ||
| 40 | 39 | ||
| 41 | #if (!HAVE_PHP_SESSION || defined(COMPILE_DL_SESSION)) | 40 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 42 | sp_log_err( | ||
| 43 | "config", | ||
| 44 | "You're trying to use the session cookie encryption feature " | ||
| 45 | "on line %zu without having session support statically built into PHP. " | ||
| 46 | "This isn't supported, see " | ||
| 47 | "https://github.com/jvoisin/snuffleupagus/issues/278 for details.", | ||
| 48 | sp_line_no); | ||
| 49 | pefree(session, 0); | ||
| 50 | return -1; | ||
| 51 | #endif | ||
| 52 | 41 | ||
| 53 | if (session->encrypt) { | 42 | if (cfg->encrypt) { |
| 54 | if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)) { | 43 | if (!SPCFG(cookies_env_var)) { |
| 55 | sp_log_err( | 44 | sp_log_err("config", "You're trying to use the session cookie encryption feature " |
| 56 | "config", | 45 | "on line %zu without having set the `.cookie_env_var` option in " |
| 57 | "You're trying to use the session cookie encryption feature " | 46 | "`sp.global`: please set it first", parsed_rule->lineno); |
| 58 | "on line %zu without having set the `.cookie_env_var` option in" | 47 | return SP_PARSER_ERROR; |
| 59 | "`sp.global`: please set it first", | 48 | } else if (!SPCFG(encryption_key)) { |
| 60 | sp_line_no); | 49 | sp_log_err("config", "You're trying to use the session cookie encryption feature " |
| 61 | pefree(session, 0); | 50 | "on line %zu without having set the `.secret_key` option in " |
| 62 | return -1; | 51 | "`sp.global`: please set it first", parsed_rule->lineno); |
| 63 | } else if (0 == | 52 | return SP_PARSER_ERROR; |
| 64 | (SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)) { | ||
| 65 | sp_log_err("config", | ||
| 66 | "You're trying to use the session cookie encryption feature " | ||
| 67 | "on line %zu without having set the `.secret_key` option in" | ||
| 68 | "`sp.global`: please set it first", | ||
| 69 | sp_line_no); | ||
| 70 | pefree(session, 0); | ||
| 71 | return -1; | ||
| 72 | } | 53 | } |
| 73 | } | 54 | } |
| 74 | 55 | ||
| 75 | SNUFFLEUPAGUS_G(config).config_session->encrypt = session->encrypt; | 56 | return SP_PARSER_STOP; |
| 76 | SNUFFLEUPAGUS_G(config).config_session->simulation = session->simulation; | ||
| 77 | pefree(session, 0); | ||
| 78 | return ret; | ||
| 79 | } | ||
| 80 | |||
| 81 | int parse_random(char *line) { | ||
| 82 | return parse_enable(line, &(SNUFFLEUPAGUS_G(config).config_random->enable), | ||
| 83 | NULL); | ||
| 84 | } | 57 | } |
| 85 | 58 | ||
| 86 | int parse_log_media(char *line) { | 59 | SP_PARSEKW_FN(parse_log_media) { |
| 87 | size_t consumed = 0; | 60 | SP_PARSE_ARG(value); |
| 88 | zend_string *value = | 61 | |
| 89 | get_param(&consumed, line, SP_TYPE_STR, SP_TOKEN_LOG_MEDIA); | 62 | if (!strcmp(ZSTR_VAL(value), "php")) { |
| 90 | 63 | *(char*)retval = SP_ZEND; | |
| 91 | if (value) { | 64 | zend_string_release_ex(value, 1); |
| 92 | if (!strcmp(ZSTR_VAL(value), "php")) { | 65 | return SP_PARSER_SUCCESS; |
| 93 | SNUFFLEUPAGUS_G(config).log_media = SP_ZEND; | 66 | } else if (!strcmp(ZSTR_VAL(value), "syslog")) { |
| 94 | return 0; | 67 | *(char*)retval = SP_SYSLOG; |
| 95 | } else if (!strcmp(ZSTR_VAL(value), "syslog")) { | 68 | zend_string_release_ex(value, 1); |
| 96 | SNUFFLEUPAGUS_G(config).log_media = SP_SYSLOG; | 69 | return SP_PARSER_SUCCESS; |
| 97 | return 0; | ||
| 98 | } | ||
| 99 | } | 70 | } |
| 100 | sp_log_err("config", "%s) only supports 'syslog' or 'php', on line %zu", | ||
| 101 | SP_TOKEN_LOG_MEDIA, sp_line_no); | ||
| 102 | return -1; | ||
| 103 | } | ||
| 104 | 71 | ||
| 105 | int parse_sloppy_comparison(char *line) { | 72 | sp_log_err("config", "." SP_TOKEN_LOG_MEDIA "() only supports 'syslog' or 'php' on line %zu", kw->lineno); |
| 106 | return parse_enable(line, &(SNUFFLEUPAGUS_G(config).config_sloppy->enable), | ||
| 107 | NULL); | ||
| 108 | } | ||
| 109 | |||
| 110 | int parse_disable_xxe(char *line) { | ||
| 111 | return parse_enable( | ||
| 112 | line, &(SNUFFLEUPAGUS_G(config).config_disable_xxe->enable), NULL); | ||
| 113 | } | ||
| 114 | |||
| 115 | int parse_auto_cookie_secure(char *line) { | ||
| 116 | return parse_enable( | ||
| 117 | line, &(SNUFFLEUPAGUS_G(config).config_auto_cookie_secure->enable), NULL); | ||
| 118 | } | ||
| 119 | 73 | ||
| 120 | int parse_global_strict(char *line) { | 74 | return SP_PARSER_ERROR; |
| 121 | return parse_enable( | ||
| 122 | line, &(SNUFFLEUPAGUS_G(config).config_global_strict->enable), NULL); | ||
| 123 | } | 75 | } |
| 124 | 76 | ||
| 125 | int parse_unserialize(char *line) { | 77 | SP_PARSE_FN(parse_unserialize) { |
| 126 | bool enable = false, disable = false; | 78 | bool enable = false, disable = false; |
| 127 | sp_config_unserialize *unserialize = | 79 | sp_config_unserialize *cfg = (sp_config_unserialize*)retval; |
| 128 | SNUFFLEUPAGUS_G(config).config_unserialize; | ||
| 129 | 80 | ||
| 130 | sp_config_functions sp_config_funcs[] = { | 81 | sp_config_keyword config_keywords[] = { |
| 131 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | 82 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, |
| 132 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | 83 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, |
| 133 | {parse_empty, SP_TOKEN_SIMULATION, &(unserialize->simulation)}, | 84 | {parse_empty, SP_TOKEN_SIMULATION, &(cfg->simulation)}, |
| 134 | {parse_str, SP_TOKEN_DUMP, &(unserialize->dump)}, | 85 | {parse_empty, SP_TOKEN_SIM, &(cfg->simulation)}, |
| 86 | {parse_str, SP_TOKEN_DUMP, &(cfg->dump)}, | ||
| 135 | {0, 0, 0}}; | 87 | {0, 0, 0}}; |
| 136 | 88 | ||
| 137 | unserialize->textual_representation = zend_string_init(line, strlen(line), 1); | 89 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 138 | 90 | ||
| 139 | int ret = parse_keywords(sp_config_funcs, line); | 91 | SP_SET_ENABLE_DISABLE(enable, disable, cfg->enable); |
| 140 | if (0 != ret) { | ||
| 141 | return ret; | ||
| 142 | } | ||
| 143 | |||
| 144 | if (!(enable ^ disable)) { | ||
| 145 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", | ||
| 146 | sp_line_no); | ||
| 147 | return -1; | ||
| 148 | } | ||
| 149 | 92 | ||
| 150 | SNUFFLEUPAGUS_G(config).config_unserialize->enable = enable; | 93 | cfg->textual_representation = sp_get_textual_representation(parsed_rule); |
| 151 | 94 | ||
| 152 | return ret; | 95 | return SP_PARSER_STOP; |
| 153 | } | 96 | } |
| 154 | 97 | ||
| 155 | int parse_readonly_exec(char *line) { | 98 | SP_PARSE_FN(parse_readonly_exec) { |
| 156 | bool enable = false, disable = false; | 99 | bool enable = false, disable = false; |
| 157 | sp_config_readonly_exec *readonly_exec = | 100 | sp_config_readonly_exec *cfg = (sp_config_readonly_exec*)retval; |
| 158 | SNUFFLEUPAGUS_G(config).config_readonly_exec; | ||
| 159 | 101 | ||
| 160 | sp_config_functions sp_config_funcs[] = { | 102 | sp_config_keyword config_keywords[] = { |
| 161 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | 103 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, |
| 162 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | 104 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, |
| 163 | {parse_empty, SP_TOKEN_SIMULATION, &(readonly_exec->simulation)}, | 105 | {parse_empty, SP_TOKEN_SIMULATION, &(cfg->simulation)}, |
| 164 | {parse_str, SP_TOKEN_DUMP, &(readonly_exec->dump)}, | 106 | {parse_empty, SP_TOKEN_SIM, &(cfg->simulation)}, |
| 107 | {parse_str, SP_TOKEN_DUMP, &(cfg->dump)}, | ||
| 165 | {0, 0, 0}}; | 108 | {0, 0, 0}}; |
| 166 | 109 | ||
| 167 | readonly_exec->textual_representation = | 110 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 168 | zend_string_init(line, strlen(line), 1); | ||
| 169 | int ret = parse_keywords(sp_config_funcs, line); | ||
| 170 | |||
| 171 | if (0 != ret) { | ||
| 172 | return ret; | ||
| 173 | } | ||
| 174 | 111 | ||
| 175 | if (!(enable ^ disable)) { | 112 | cfg->textual_representation = sp_get_textual_representation(parsed_rule); |
| 176 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", | ||
| 177 | sp_line_no); | ||
| 178 | return -1; | ||
| 179 | } | ||
| 180 | 113 | ||
| 181 | SNUFFLEUPAGUS_G(config).config_readonly_exec->enable = enable; | 114 | SP_SET_ENABLE_DISABLE(enable, disable, cfg->enable); |
| 182 | 115 | ||
| 183 | return ret; | 116 | return SP_PARSER_STOP; |
| 184 | } | 117 | } |
| 185 | 118 | ||
| 186 | int parse_global(char *line) { | 119 | SP_PARSE_FN(parse_global) { |
| 187 | sp_config_functions sp_config_funcs_global[] = { | 120 | sp_config_keyword config_keywords[] = { |
| 188 | {parse_str, SP_TOKEN_ENCRYPTION_KEY, | 121 | {parse_str, SP_TOKEN_ENCRYPTION_KEY, &(SPCFG(encryption_key))}, |
| 189 | &(SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)}, | 122 | {parse_str, SP_TOKEN_ENV_VAR, &(SPCFG(cookies_env_var))}, |
| 190 | {parse_str, SP_TOKEN_ENV_VAR, | 123 | {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, |
| 191 | &(SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)}, | 124 | {parse_ulong, SP_TOKEN_MAX_EXECUTION_DEPTH, &(SPCFG(max_execution_depth))}, |
| 125 | {parse_enable, SP_TOKEN_SERVER_ENCODE, &(SPCFG(server_encode))}, | ||
| 126 | {parse_enable, SP_TOKEN_SERVER_STRIP, &(SPCFG(server_strip))}, | ||
| 127 | {parse_enable, SP_TOKEN_SHOW_OLD_PHP_WARNING, &(SPCFG(show_old_php_warning))}, | ||
| 192 | {0, 0, 0}}; | 128 | {0, 0, 0}}; |
| 193 | return parse_keywords(sp_config_funcs_global, line); | 129 | |
| 130 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); | ||
| 131 | |||
| 132 | if (SPCFG(encryption_key)) { | ||
| 133 | if (ZSTR_LEN(SPCFG(encryption_key)) < 10) { | ||
| 134 | sp_log_err("config", "The encryption key set on line %zu is too short. please use at least 10 bytes", parsed_rule->lineno); | ||
| 135 | return SP_PARSER_ERROR; | ||
| 136 | } | ||
| 137 | if (zend_string_equals_literal(SPCFG(encryption_key), "YOU _DO_ NEED TO CHANGE THIS WITH SOME RANDOM CHARACTERS.") || | ||
| 138 | zend_string_equals_literal(SPCFG(encryption_key), "c6a0e02b3b818f7559d5f85303d8fe44")) { | ||
| 139 | sp_log_err("config", "The encryption key set on line %zu is an unchanged dummy value. please use a unique secret.", parsed_rule->lineno); | ||
| 140 | return SP_PARSER_ERROR; | ||
| 141 | } | ||
| 142 | } | ||
| 143 | |||
| 144 | return SP_PARSER_STOP; | ||
| 194 | } | 145 | } |
| 195 | 146 | ||
| 196 | static int parse_eval_filter_conf(char *line, sp_list_node **list) { | 147 | SP_PARSE_FN(parse_eval_filter_conf) { |
| 197 | sp_config_eval *eval = SNUFFLEUPAGUS_G(config).config_eval; | 148 | sp_config_eval *cfg = &(SPCFG(eval)); |
| 198 | 149 | ||
| 199 | sp_config_functions sp_config_funcs[] = { | 150 | sp_config_keyword config_keywords[] = { |
| 200 | {parse_list, SP_TOKEN_LIST, list}, | 151 | {parse_list, SP_TOKEN_LIST, retval}, |
| 201 | {parse_empty, SP_TOKEN_SIMULATION, | 152 | {parse_empty, SP_TOKEN_SIMULATION, &(cfg->simulation)}, |
| 202 | &(SNUFFLEUPAGUS_G(config).config_eval->simulation)}, | 153 | {parse_empty, SP_TOKEN_SIM, &(cfg->simulation)}, |
| 203 | {parse_str, SP_TOKEN_DUMP, &(SNUFFLEUPAGUS_G(config).config_eval->dump)}, | 154 | {parse_str, SP_TOKEN_DUMP, &(cfg->dump)}, |
| 204 | {0, 0, 0}}; | 155 | {0, 0, 0}}; |
| 205 | 156 | ||
| 206 | eval->textual_representation = zend_string_init(line, strlen(line), 1); | 157 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 207 | 158 | ||
| 208 | int ret = parse_keywords(sp_config_funcs, line); | 159 | cfg->textual_representation = sp_get_textual_representation(parsed_rule); |
| 209 | if (0 != ret) { | ||
| 210 | return ret; | ||
| 211 | } | ||
| 212 | 160 | ||
| 213 | return SUCCESS; | 161 | return SP_PARSER_STOP; |
| 214 | } | 162 | } |
| 215 | 163 | ||
| 216 | int parse_wrapper_whitelist(char *line) { | 164 | SP_PARSE_FN(parse_wrapper_whitelist) { |
| 217 | SNUFFLEUPAGUS_G(config).config_wrapper->enabled = true; | 165 | sp_config_wrapper *cfg = (sp_config_wrapper*)retval; |
| 218 | sp_config_functions sp_config_funcs[] = { | 166 | |
| 219 | {parse_list, SP_TOKEN_LIST, | 167 | sp_config_keyword config_keywords[] = { |
| 220 | &SNUFFLEUPAGUS_G(config).config_wrapper->whitelist}, | 168 | {parse_list, SP_TOKEN_LIST, &cfg->whitelist}, |
| 221 | {0, 0, 0}}; | 169 | {0, 0, 0}}; |
| 222 | int ret = parse_keywords(sp_config_funcs, line); | ||
| 223 | if (0 != ret) { | ||
| 224 | return ret; | ||
| 225 | } | ||
| 226 | return SUCCESS; | ||
| 227 | } | ||
| 228 | 170 | ||
| 229 | int parse_eval_blacklist(char *line) { | 171 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 230 | return parse_eval_filter_conf( | 172 | |
| 231 | line, &SNUFFLEUPAGUS_G(config).config_eval->blacklist); | 173 | cfg->enabled = true; |
| 232 | } | ||
| 233 | 174 | ||
| 234 | int parse_eval_whitelist(char *line) { | 175 | return SP_PARSER_STOP; |
| 235 | return parse_eval_filter_conf( | ||
| 236 | line, &SNUFFLEUPAGUS_G(config).config_eval->whitelist); | ||
| 237 | } | 176 | } |
| 238 | 177 | ||
| 239 | int parse_cookie(char *line) { | 178 | SP_PARSE_FN(parse_cookie) { |
| 240 | int ret = 0; | ||
| 241 | zend_string *samesite = NULL; | 179 | zend_string *samesite = NULL; |
| 242 | sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); | 180 | sp_cookie *cookie = pecalloc(sizeof(sp_cookie), 1, 1); |
| 243 | 181 | ||
| 244 | sp_config_functions sp_config_funcs_cookie_encryption[] = { | 182 | sp_config_keyword config_keywords[] = { |
| 245 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, | 183 | {parse_str, SP_TOKEN_NAME, &(cookie->name)}, |
| 246 | {parse_regexp, SP_TOKEN_NAME_REGEXP, &(cookie->name_r)}, | 184 | {parse_regexp, SP_TOKEN_NAME_REGEXP, &(cookie->name_r)}, |
| 247 | {parse_str, SP_TOKEN_SAMESITE, &samesite}, | 185 | {parse_str, SP_TOKEN_SAMESITE, &samesite}, |
| 248 | {parse_empty, SP_TOKEN_ENCRYPT, &cookie->encrypt}, | 186 | {parse_empty, SP_TOKEN_ENCRYPT, &cookie->encrypt}, |
| 249 | {parse_empty, SP_TOKEN_SIMULATION, &cookie->simulation}, | 187 | {parse_empty, SP_TOKEN_SIMULATION, &cookie->simulation}, |
| 188 | {parse_empty, SP_TOKEN_SIM, &cookie->simulation}, | ||
| 250 | {0, 0, 0}}; | 189 | {0, 0, 0}}; |
| 251 | 190 | ||
| 252 | ret = parse_keywords(sp_config_funcs_cookie_encryption, line); | 191 | SP_PROCESS_CONFIG_KEYWORDS(goto err); |
| 253 | if (0 != ret) { | ||
| 254 | return ret; | ||
| 255 | } | ||
| 256 | 192 | ||
| 257 | if (cookie->encrypt) { | 193 | if (cookie->encrypt) { |
| 258 | if (0 == (SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var)) { | 194 | if (!SPCFG(cookies_env_var)) { |
| 259 | sp_log_err( | 195 | sp_log_err("config", "You're trying to use the cookie encryption feature on line %zu " |
| 260 | "config", | 196 | "without having set the `." SP_TOKEN_ENV_VAR "` option in `sp.global`: please set it first", parsed_rule->lineno); |
| 261 | "You're trying to use the cookie encryption feature" | 197 | goto err; |
| 262 | "on line %zu without having set the `.cookie_env_var` option in" | 198 | } else if (!SPCFG(encryption_key)) { |
| 263 | "`sp.global`: please set it first", | 199 | sp_log_err("config", "You're trying to use the cookie encryption feature " |
| 264 | sp_line_no); | 200 | "on line %zu without having set the `." SP_TOKEN_ENCRYPTION_KEY "` option in " |
| 265 | return -1; | 201 | "`sp." SP_TOKEN_GLOBAL "`: please set it first", parsed_rule->lineno); |
| 266 | } else if (0 == | 202 | goto err; |
| 267 | (SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)) { | ||
| 268 | sp_log_err( | ||
| 269 | "config", | ||
| 270 | "You're trying to use the cookie encryption feature" | ||
| 271 | "on line %zu without having set the `.encryption_key` option in" | ||
| 272 | "`sp.global`: please set it first", | ||
| 273 | sp_line_no); | ||
| 274 | return -1; | ||
| 275 | } | 203 | } |
| 276 | } else if (!samesite) { | 204 | } else if (!samesite) { |
| 277 | sp_log_err("config", | 205 | sp_log_err("config", "You must specify a at least one action to a cookie on line %zu", parsed_rule->lineno); |
| 278 | "You must specify a at least one action to a cookie on line " | 206 | goto err; |
| 279 | "%zu", | ||
| 280 | sp_line_no); | ||
| 281 | return -1; | ||
| 282 | } | 207 | } |
| 283 | if ((!cookie->name || 0 == ZSTR_LEN(cookie->name)) && !cookie->name_r) { | 208 | if ((!cookie->name || 0 == ZSTR_LEN(cookie->name)) && !cookie->name_r) { |
| 284 | sp_log_err("config", | 209 | sp_log_err("config", "You must specify a cookie name/regexp on line %zu", parsed_rule->lineno); |
| 285 | "You must specify a cookie name/regexp on line " | 210 | goto err; |
| 286 | "%zu", | ||
| 287 | sp_line_no); | ||
| 288 | return -1; | ||
| 289 | } | 211 | } |
| 290 | if (cookie->name && cookie->name_r) { | 212 | if (cookie->name && cookie->name_r) { |
| 291 | sp_log_err("config", | 213 | sp_log_err("config", "name and name_r are mutually exclusive on line %zu", parsed_rule->lineno); |
| 292 | "name and name_r are mutually exclusive on line " | 214 | goto err; |
| 293 | "%zu", | ||
| 294 | sp_line_no); | ||
| 295 | return -1; | ||
| 296 | } | 215 | } |
| 297 | if (samesite) { | 216 | if (samesite) { |
| 298 | if (zend_string_equals_literal_ci(samesite, SP_TOKEN_SAMESITE_LAX)) { | 217 | if (zend_string_equals_literal_ci(samesite, SP_TOKEN_SAMESITE_LAX)) { |
| 299 | cookie->samesite = lax; | 218 | cookie->samesite = lax; |
| 300 | } else if (zend_string_equals_literal_ci(samesite, | 219 | } else if (zend_string_equals_literal_ci(samesite, SP_TOKEN_SAMESITE_STRICT)) { |
| 301 | SP_TOKEN_SAMESITE_STRICT)) { | ||
| 302 | cookie->samesite = strict; | 220 | cookie->samesite = strict; |
| 303 | } else { | 221 | } else { |
| 304 | sp_log_err( | 222 | sp_log_err("config", "'%s' is an invalid value to samesite (expected " SP_TOKEN_SAMESITE_LAX " or " SP_TOKEN_SAMESITE_STRICT ") on line %zu", |
| 305 | "config", | 223 | ZSTR_VAL(samesite), parsed_rule->lineno); |
| 306 | "%s is an invalid value to samesite (expected %s or %s) on line " | 224 | goto err; |
| 307 | "%zu", | ||
| 308 | ZSTR_VAL(samesite), SP_TOKEN_SAMESITE_LAX, SP_TOKEN_SAMESITE_STRICT, | ||
| 309 | sp_line_no); | ||
| 310 | return -1; | ||
| 311 | } | 225 | } |
| 312 | } | 226 | } |
| 313 | SNUFFLEUPAGUS_G(config).config_cookie->cookies = | 227 | |
| 314 | sp_list_insert(SNUFFLEUPAGUS_G(config).config_cookie->cookies, cookie); | 228 | SPCFG(cookie).cookies = sp_list_insert(SPCFG(cookie).cookies, cookie); |
| 315 | return SUCCESS; | 229 | |
| 230 | return SP_PARSER_STOP; | ||
| 231 | |||
| 232 | err: | ||
| 233 | if (samesite) { | ||
| 234 | zend_string_release(samesite); | ||
| 235 | } | ||
| 236 | if (cookie) { | ||
| 237 | sp_free_cookie(cookie); | ||
| 238 | pefree(cookie, 1); | ||
| 239 | } | ||
| 240 | return SP_PARSER_ERROR; | ||
| 316 | } | 241 | } |
| 317 | 242 | ||
| 318 | int add_df_to_hashtable(HashTable *ht, sp_disabled_function *df) { | 243 | static int add_df_to_hashtable(HashTable *ht, sp_disabled_function *df) { |
| 319 | zval *list = zend_hash_find(ht, df->function); | 244 | zval *list = zend_hash_find(ht, df->function); |
| 320 | 245 | ||
| 321 | if (NULL == list) { | 246 | if (NULL == list) { |
| @@ -326,19 +251,19 @@ int add_df_to_hashtable(HashTable *ht, sp_disabled_function *df) { | |||
| 326 | return SUCCESS; | 251 | return SUCCESS; |
| 327 | } | 252 | } |
| 328 | 253 | ||
| 329 | int parse_disabled_functions(char *line) { | 254 | SP_PARSE_FN(parse_disabled_functions) { |
| 330 | int ret = 0; | 255 | int ret = SP_PARSER_ERROR; |
| 331 | bool enable = true, disable = false, allow = false, drop = false; | 256 | bool enable = false, disable = false, allow = false, drop = false; |
| 332 | zend_string *pos = NULL, *var = NULL, *param = NULL; | 257 | zend_string *var = NULL, *param = NULL; |
| 333 | zend_string *line_number = NULL; | ||
| 334 | sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); | 258 | sp_disabled_function *df = pecalloc(sizeof(*df), 1, 1); |
| 335 | df->pos = -1; | 259 | df->pos = -1; |
| 336 | 260 | ||
| 337 | sp_config_functions sp_config_funcs_disabled_functions[] = { | 261 | sp_config_keyword config_keywords[] = { |
| 338 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | 262 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, |
| 339 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | 263 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, |
| 340 | {parse_str, SP_TOKEN_ALIAS, &(df->alias)}, | 264 | {parse_str, SP_TOKEN_ALIAS, &(df->alias)}, |
| 341 | {parse_empty, SP_TOKEN_SIMULATION, &(df->simulation)}, | 265 | {parse_empty, SP_TOKEN_SIMULATION, &(df->simulation)}, |
| 266 | {parse_empty, SP_TOKEN_SIM, &(df->simulation)}, | ||
| 342 | {parse_str, SP_TOKEN_FILENAME, &(df->filename)}, | 267 | {parse_str, SP_TOKEN_FILENAME, &(df->filename)}, |
| 343 | {parse_regexp, SP_TOKEN_FILENAME_REGEXP, &(df->r_filename)}, | 268 | {parse_regexp, SP_TOKEN_FILENAME_REGEXP, &(df->r_filename)}, |
| 344 | {parse_str, SP_TOKEN_FUNCTION, &(df->function)}, | 269 | {parse_str, SP_TOKEN_FUNCTION, &(df->function)}, |
| @@ -359,86 +284,54 @@ int parse_disabled_functions(char *line) { | |||
| 359 | {parse_regexp, SP_TOKEN_RET_REGEXP, &(df->r_ret)}, | 284 | {parse_regexp, SP_TOKEN_RET_REGEXP, &(df->r_ret)}, |
| 360 | {parse_php_type, SP_TOKEN_RET_TYPE, &(df->ret_type)}, | 285 | {parse_php_type, SP_TOKEN_RET_TYPE, &(df->ret_type)}, |
| 361 | {parse_str, SP_TOKEN_LOCAL_VAR, &(var)}, | 286 | {parse_str, SP_TOKEN_LOCAL_VAR, &(var)}, |
| 362 | {parse_str, SP_TOKEN_VALUE_ARG_POS, &(pos)}, | 287 | {parse_int, SP_TOKEN_VALUE_ARG_POS, &(df->pos)}, |
| 363 | {parse_str, SP_TOKEN_LINE_NUMBER, &(line_number)}, | 288 | {parse_ulong, SP_TOKEN_LINE_NUMBER, &(df->line)}, |
| 364 | {0, 0, 0}}; | 289 | {0, 0, 0}}; |
| 365 | 290 | ||
| 366 | ret = parse_keywords(sp_config_funcs_disabled_functions, line); | 291 | SP_PROCESS_CONFIG_KEYWORDS(goto out); |
| 367 | 292 | ||
| 368 | if (0 != ret) { | 293 | SP_SET_ENABLE_DISABLE(enable, disable, enable); |
| 369 | return ret; | 294 | if (disable) { |
| 295 | ret = SP_PARSER_STOP; goto out; | ||
| 370 | } | 296 | } |
| 371 | 297 | ||
| 372 | #define MUTUALLY_EXCLUSIVE(X, Y, STR1, STR2) \ | 298 | #define MUTUALLY_EXCLUSIVE(X, Y, STR1, STR2) \ |
| 373 | if (X && Y) { \ | 299 | if (X && Y) { \ |
| 374 | sp_log_err("config", \ | 300 | sp_log_err("config", "Invalid configuration line for 'sp.disabled_functions': '.%s' and '.%s' are mutually exclusive on line %zu", STR1, STR2, parsed_rule->lineno); \ |
| 375 | "Invalid configuration line: 'sp.disabled_functions%s': " \ | 301 | goto out; \ |
| 376 | "'.%s' and '.%s' are mutually exclusive on line %zu", \ | ||
| 377 | line, STR1, STR2, sp_line_no); \ | ||
| 378 | return -1; \ | ||
| 379 | } | 302 | } |
| 380 | 303 | ||
| 381 | MUTUALLY_EXCLUSIVE(df->r_value, df->value, "r_value", "regexp"); | 304 | MUTUALLY_EXCLUSIVE(df->value, df->r_value, "value", "value_r"); |
| 382 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "r_function", "function"); | 305 | MUTUALLY_EXCLUSIVE(df->r_function, df->function, "function", "function_r"); |
| 383 | MUTUALLY_EXCLUSIVE(df->r_filename, df->filename, "r_filename", "filename"); | 306 | MUTUALLY_EXCLUSIVE(df->filename, df->r_filename, "filename", "filename_r"); |
| 384 | MUTUALLY_EXCLUSIVE(df->r_ret, df->ret, "r_ret", "ret"); | 307 | MUTUALLY_EXCLUSIVE(df->ret, df->r_ret, "ret", "ret_r"); |
| 385 | MUTUALLY_EXCLUSIVE(df->r_key, df->key, "r_key", "key"); | 308 | MUTUALLY_EXCLUSIVE(df->key, df->r_key, "key", "key_r"); |
| 386 | MUTUALLY_EXCLUSIVE(pos, param, "pos", "param"); | 309 | MUTUALLY_EXCLUSIVE((df->pos >= 0), param, "pos", "param"); |
| 387 | MUTUALLY_EXCLUSIVE(pos, df->r_param, "pos", "param_r"); | 310 | MUTUALLY_EXCLUSIVE((df->pos >= 0), df->r_param, "pos", "param_r"); |
| 388 | MUTUALLY_EXCLUSIVE(param, df->r_param, "param", "param_r"); | 311 | MUTUALLY_EXCLUSIVE(param, df->r_param, "param", "param_r"); |
| 389 | MUTUALLY_EXCLUSIVE((df->r_key || df->key), (df->r_value || df->value), "key", "value"); | 312 | MUTUALLY_EXCLUSIVE((df->r_key || df->key), (df->r_value || df->value), "key", "value"); |
| 390 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->r_param || param), "ret", "param"); | 313 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->r_param || param), "ret", "param"); |
| 391 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (var), "ret", "var"); | 314 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (var), "ret", "var"); |
| 392 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->value || df->r_value), "ret", "value"); | 315 | MUTUALLY_EXCLUSIVE((df->r_ret || df->ret || df->ret_type), (df->value || df->r_value), "ret", "value"); |
| 316 | |||
| 393 | #undef MUTUALLY_EXCLUSIVE | 317 | #undef MUTUALLY_EXCLUSIVE |
| 394 | 318 | ||
| 395 | if (!(df->r_function || df->function)) { | 319 | if (!(df->r_function || df->function)) { |
| 396 | sp_log_err("config", | 320 | sp_log_err("config", "Invalid configuration line: 'sp.disabled_functions': must take a function name on line %zu", parsed_rule->lineno); |
| 397 | "Invalid configuration line: 'sp.disabled_functions%s':" | 321 | goto out; |
| 398 | " must take a function name on line %zu", | ||
| 399 | line, sp_line_no); | ||
| 400 | return -1; | ||
| 401 | } | 322 | } |
| 402 | if (df->filename && (*ZSTR_VAL(df->filename) != '/') && | 323 | if (df->filename && (*ZSTR_VAL(df->filename) != '/') && |
| 403 | (0 != strncmp(ZSTR_VAL(df->filename), "phar://", strlen("phar://")))) { | 324 | (0 != strncmp(ZSTR_VAL(df->filename), ZEND_STRL("phar://")))) { |
| 404 | sp_log_err( | 325 | sp_log_err("config", "Invalid configuration line: 'sp.disabled_functions': '.filename' must be an absolute path or a phar archive on line %zu", parsed_rule->lineno); |
| 405 | "config", | 326 | goto out; |
| 406 | "Invalid configuration line: 'sp.disabled_functions%s':" | ||
| 407 | "'.filename' must be an absolute path or a phar archive on line %zu", | ||
| 408 | line, sp_line_no); | ||
| 409 | return -1; | ||
| 410 | } | 327 | } |
| 411 | if (!(allow ^ drop)) { | 328 | if (!(allow ^ drop)) { |
| 412 | sp_log_err("config", | 329 | sp_log_err("config", "Invalid configuration line: 'sp.disabled_functions': The rule must either be a `drop` or `allow` one on line %zu", parsed_rule->lineno); |
| 413 | "Invalid configuration line: 'sp.disabled_functions%s': The " | 330 | goto out; |
| 414 | "rule must either be a `drop` or `allow` one on line %zu", | ||
| 415 | line, sp_line_no); | ||
| 416 | return -1; | ||
| 417 | } | 331 | } |
| 418 | 332 | ||
| 419 | if (pos) { | ||
| 420 | errno = 0; | ||
| 421 | char *endptr; | ||
| 422 | df->pos = (int)strtol(ZSTR_VAL(pos), &endptr, 10); | ||
| 423 | if (errno != 0 || endptr == ZSTR_VAL(pos)) { | ||
| 424 | sp_log_err("config", "Failed to parse arg '%s' of `pos` on line %zu", | ||
| 425 | ZSTR_VAL(pos), sp_line_no); | ||
| 426 | return -1; | ||
| 427 | } | ||
| 428 | } | ||
| 429 | |||
| 430 | if (line_number) { | ||
| 431 | errno = 0; | ||
| 432 | char *endptr; | ||
| 433 | df->line = (unsigned int)strtoul(ZSTR_VAL(line_number), &endptr, 10); | ||
| 434 | if (errno != 0 || endptr == ZSTR_VAL(line_number)) { | ||
| 435 | sp_log_err("config", "Failed to parse arg '%s' of `line` on line %zu", | ||
| 436 | ZSTR_VAL(line_number), sp_line_no); | ||
| 437 | return -1; | ||
| 438 | } | ||
| 439 | } | ||
| 440 | df->allow = allow; | 333 | df->allow = allow; |
| 441 | df->textual_representation = zend_string_init(line, strlen(line), 1); | 334 | df->textual_representation = sp_get_textual_representation(parsed_rule); |
| 442 | 335 | ||
| 443 | if (df->function) { | 336 | if (df->function) { |
| 444 | df->functions_list = parse_functions_list(ZSTR_VAL(df->function)); | 337 | df->functions_list = parse_functions_list(ZSTR_VAL(df->function)); |
| @@ -453,108 +346,162 @@ int parse_disabled_functions(char *line) { | |||
| 453 | new[0] = '$'; | 346 | new[0] = '$'; |
| 454 | memcpy(new + 1, ZSTR_VAL(param), ZSTR_LEN(param)); | 347 | memcpy(new + 1, ZSTR_VAL(param), ZSTR_LEN(param)); |
| 455 | df->param = sp_parse_var(new); | 348 | df->param = sp_parse_var(new); |
| 456 | free(new); | 349 | pefree(new, 1); |
| 457 | } else { | 350 | } else { |
| 458 | df->param = sp_parse_var(ZSTR_VAL(param)); | 351 | df->param = sp_parse_var(ZSTR_VAL(param)); |
| 459 | } | 352 | } |
| 460 | if (!df->param) { | 353 | if (!df->param) { |
| 461 | sp_log_err("config", "Invalid value '%s' for `param` on line %zu", | 354 | sp_log_err("config", "Invalid value '%s' for `param` on line %zu", ZSTR_VAL(param), parsed_rule->lineno); |
| 462 | ZSTR_VAL(param), sp_line_no); | 355 | goto out; |
| 463 | return -1; | ||
| 464 | } | 356 | } |
| 465 | } | 357 | } |
| 466 | |||
| 467 | if (var) { | 358 | if (var) { |
| 468 | if (ZSTR_LEN(var)) { | 359 | if (ZSTR_LEN(var)) { |
| 469 | df->var = sp_parse_var(ZSTR_VAL(var)); | 360 | df->var = sp_parse_var(ZSTR_VAL(var)); |
| 470 | if (!df->var) { | 361 | if (!df->var) { |
| 471 | sp_log_err("config", "Invalid value '%s' for `var` on line %zu", | 362 | sp_log_err("config", "Invalid value '%s' for `var` on line %zu", ZSTR_VAL(var), parsed_rule->lineno); |
| 472 | ZSTR_VAL(var), sp_line_no); | 363 | goto out; |
| 473 | return -1; | ||
| 474 | } | 364 | } |
| 475 | } else { | 365 | } else { |
| 476 | sp_log_err("config", "Empty value in `var` on line %zu", sp_line_no); | 366 | sp_log_err("config", "Empty value in `var` on line %zu", parsed_rule->lineno); |
| 477 | return -1; | 367 | goto out; |
| 478 | } | 368 | } |
| 479 | } | 369 | } |
| 480 | 370 | ||
| 481 | if (true == disable) { | ||
| 482 | return ret; | ||
| 483 | } | ||
| 484 | |||
| 485 | if (df->function && zend_string_equals_literal(df->function, "print")) { | 371 | if (df->function && zend_string_equals_literal(df->function, "print")) { |
| 486 | zend_string_release(df->function); | 372 | zend_string_release(df->function); |
| 487 | df->function = zend_string_init("echo", sizeof("echo") - 1, 1); | 373 | df->function = zend_string_init(ZEND_STRL("echo"), 1); |
| 488 | } | 374 | } |
| 489 | 375 | ||
| 490 | if (df->function && !df->functions_list) { | 376 | if (df->function && !df->functions_list) { |
| 491 | if (df->ret || df->r_ret || df->ret_type) { | 377 | if (df->ret || df->r_ret || df->ret_type) { |
| 492 | add_df_to_hashtable(SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, | 378 | add_df_to_hashtable(SPCFG(disabled_functions_ret), df); |
| 493 | df); | ||
| 494 | } else { | 379 | } else { |
| 495 | add_df_to_hashtable(SNUFFLEUPAGUS_G(config).config_disabled_functions, | 380 | add_df_to_hashtable(SPCFG(disabled_functions), df); |
| 496 | df); | ||
| 497 | } | 381 | } |
| 498 | } else { | 382 | } else { |
| 499 | if (df->ret || df->r_ret || df->ret_type) { | 383 | if (df->ret || df->r_ret || df->ret_type) { |
| 500 | SNUFFLEUPAGUS_G(config) | 384 | SPCFG(disabled_functions_reg_ret).disabled_functions = sp_list_insert(SPCFG(disabled_functions_reg_ret).disabled_functions, df); |
| 501 | .config_disabled_functions_reg_ret->disabled_functions = | ||
| 502 | sp_list_insert( | ||
| 503 | SNUFFLEUPAGUS_G(config) | ||
| 504 | .config_disabled_functions_reg_ret->disabled_functions, | ||
| 505 | df); | ||
| 506 | } else { | 385 | } else { |
| 507 | SNUFFLEUPAGUS_G(config) | 386 | SPCFG(disabled_functions_reg).disabled_functions = sp_list_insert(SPCFG(disabled_functions_reg).disabled_functions, df); |
| 508 | .config_disabled_functions_reg->disabled_functions = | ||
| 509 | sp_list_insert(SNUFFLEUPAGUS_G(config) | ||
| 510 | .config_disabled_functions_reg->disabled_functions, | ||
| 511 | df); | ||
| 512 | } | 387 | } |
| 513 | } | 388 | } |
| 389 | return SP_PARSER_STOP; | ||
| 390 | |||
| 391 | out: | ||
| 392 | if (df) { | ||
| 393 | sp_free_disabled_function(df); | ||
| 394 | pefree(df, 1); | ||
| 395 | } | ||
| 396 | if (param) { zend_string_release(param); } | ||
| 397 | if (var) { zend_string_release(var); } | ||
| 398 | |||
| 514 | return ret; | 399 | return ret; |
| 515 | } | 400 | } |
| 516 | 401 | ||
| 517 | int parse_upload_validation(char *line) { | 402 | SP_PARSE_FN(parse_upload_validation) { |
| 518 | bool disable = false, enable = false; | 403 | bool disable = false, enable = false; |
| 519 | sp_config_functions sp_config_funcs_upload_validation[] = { | 404 | sp_config_upload_validation *cfg = (sp_config_upload_validation*)retval; |
| 520 | {parse_str, SP_TOKEN_UPLOAD_SCRIPT, | 405 | |
| 521 | &(SNUFFLEUPAGUS_G(config).config_upload_validation->script)}, | 406 | sp_config_keyword config_keywords[] = { |
| 522 | {parse_empty, SP_TOKEN_SIMULATION, | ||
| 523 | &(SNUFFLEUPAGUS_G(config).config_upload_validation->simulation)}, | ||
| 524 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, | 407 | {parse_empty, SP_TOKEN_ENABLE, &(enable)}, |
| 525 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, | 408 | {parse_empty, SP_TOKEN_DISABLE, &(disable)}, |
| 409 | {parse_str, SP_TOKEN_UPLOAD_SCRIPT, &(cfg->script)}, | ||
| 410 | {parse_empty, SP_TOKEN_SIMULATION, &(cfg->simulation)}, | ||
| 411 | {parse_empty, SP_TOKEN_SIM, &(cfg->simulation)}, | ||
| 526 | {0, 0, 0}}; | 412 | {0, 0, 0}}; |
| 527 | 413 | ||
| 528 | int ret = parse_keywords(sp_config_funcs_upload_validation, line); | 414 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); |
| 415 | SP_SET_ENABLE_DISABLE(enable, disable, cfg->enable); | ||
| 529 | 416 | ||
| 530 | if (0 != ret) { | 417 | if (!cfg->script) { |
| 531 | return ret; | 418 | sp_log_err("config", "The `script` directive is mandatory in '.%s' on line %zu", token, parsed_rule->lineno); |
| 419 | return SP_PARSER_ERROR; | ||
| 420 | } else if (-1 == access(ZSTR_VAL(cfg->script), F_OK)) { | ||
| 421 | sp_log_err("config", "The `script` (%s) doesn't exist on line %zu", ZSTR_VAL(cfg->script), parsed_rule->lineno); | ||
| 422 | return SP_PARSER_ERROR; | ||
| 532 | } | 423 | } |
| 533 | 424 | ||
| 534 | if (!(enable ^ disable)) { | 425 | return SP_PARSER_STOP; |
| 535 | sp_log_err("config", "A rule can't be enabled and disabled on line %zu", | 426 | } |
| 536 | sp_line_no); | 427 | |
| 537 | return -1; | 428 | SP_PARSE_FN(parse_ini_protection) { |
| 429 | bool disable = false, enable = false; | ||
| 430 | bool rw = false, ro = false; // rw is ignored, but declaring .policy_rw is valid for readability | ||
| 431 | sp_config_ini *cfg = (sp_config_ini*)retval; | ||
| 432 | sp_config_keyword config_keywords[] = { | ||
| 433 | {parse_empty, "enable", &(enable)}, | ||
| 434 | {parse_empty, "disable", &(disable)}, | ||
| 435 | {parse_empty, "simulation", &cfg->simulation}, | ||
| 436 | {parse_empty, "sim", &cfg->simulation}, | ||
| 437 | {parse_empty, "policy_readonly", &ro}, | ||
| 438 | {parse_empty, "policy_ro", &ro}, | ||
| 439 | {parse_empty, "policy_readwrite", &rw}, | ||
| 440 | {parse_empty, "policy_rw", &rw}, | ||
| 441 | {parse_empty, "policy_silent_ro", &cfg->policy_silent_ro}, | ||
| 442 | {parse_empty, "policy_silent_fail", &cfg->policy_silent_fail}, | ||
| 443 | {parse_empty, "policy_no_log", &cfg->policy_silent_fail}, | ||
| 444 | {parse_empty, "policy_drop", &cfg->policy_drop}, | ||
| 445 | {0, 0, 0}}; | ||
| 446 | |||
| 447 | SP_PROCESS_CONFIG_KEYWORDS_ERR(); | ||
| 448 | |||
| 449 | SP_SET_ENABLE_DISABLE(enable, disable, cfg->enable); | ||
| 450 | |||
| 451 | if (ro && rw) { | ||
| 452 | sp_log_err("config", "rule cannot be both read-write and read-only on line %zu", parsed_rule->lineno); | ||
| 453 | return SP_PARSER_ERROR; | ||
| 538 | } | 454 | } |
| 539 | SNUFFLEUPAGUS_G(config).config_upload_validation->enable = enable; | 455 | cfg->policy_readonly = ro; |
| 540 | 456 | ||
| 541 | zend_string const *script = | 457 | if (cfg->policy_silent_fail && cfg->policy_drop) { |
| 542 | SNUFFLEUPAGUS_G(config).config_upload_validation->script; | 458 | sp_log_err("config", "policy cannot be drop and silent at the same time on line %zu", parsed_rule->lineno); |
| 459 | return SP_PARSER_ERROR; | ||
| 460 | } | ||
| 461 | return SP_PARSER_STOP; | ||
| 462 | } | ||
| 463 | |||
| 464 | SP_PARSE_FN(parse_ini_entry) { | ||
| 465 | sp_ini_entry *entry = pecalloc(sizeof(sp_ini_entry), 1, 1); | ||
| 466 | bool rw = false, ro = false; | ||
| 467 | |||
| 468 | sp_config_keyword config_keywords[] = { | ||
| 469 | {parse_empty, "simulation", &entry->simulation}, | ||
| 470 | {parse_empty, "sim", &entry->simulation}, | ||
| 471 | {parse_str, "key", &entry->key}, | ||
| 472 | {parse_str, "msg", &entry->msg}, | ||
| 473 | {parse_str, "set", &entry->set}, | ||
| 474 | {parse_str, "min", &entry->min}, | ||
| 475 | {parse_str, "max", &entry->max}, | ||
| 476 | {parse_regexp, "regexp", &entry->regexp}, | ||
| 477 | {parse_empty, "readonly", &ro}, | ||
| 478 | {parse_empty, "ro", &ro}, | ||
| 479 | {parse_empty, "readwrite", &rw}, | ||
| 480 | {parse_empty, "rw", &rw}, | ||
| 481 | {parse_empty, "drop", &entry->drop}, | ||
| 482 | {parse_empty, "allow_null", &entry->allow_null}, | ||
| 483 | {0, 0, 0}}; | ||
| 543 | 484 | ||
| 544 | if (!script) { | 485 | SP_PROCESS_CONFIG_KEYWORDS(goto err); |
| 545 | sp_log_err("config", | 486 | |
| 546 | "The `script` directive is mandatory in '%s' on line %zu", line, | 487 | if (!entry->key) { |
| 547 | sp_line_no); | 488 | sp_log_err("config", "A .key() must be provided on line %zu", parsed_rule->lineno); |
| 548 | return -1; | 489 | goto err; |
| 549 | } else if (-1 == access(ZSTR_VAL(script), F_OK)) { | ||
| 550 | sp_log_err("config", "The `script` (%s) doesn't exist on line %zu", | ||
| 551 | ZSTR_VAL(script), sp_line_no); | ||
| 552 | return -1; | ||
| 553 | } else if (-1 == access(ZSTR_VAL(script), X_OK)) { | ||
| 554 | sp_log_err("config", "The `script` (%s) isn't executable on line %zu", | ||
| 555 | ZSTR_VAL(script), sp_line_no); | ||
| 556 | return -1; | ||
| 557 | } | 490 | } |
| 558 | 491 | ||
| 559 | return ret; | 492 | if (ro && rw) { |
| 493 | sp_log_err("config", "rule cannot be both read-write and read-only on line %zu", parsed_rule->lineno); | ||
| 494 | goto err; | ||
| 495 | } | ||
| 496 | entry->access = ro - rw; | ||
| 497 | |||
| 498 | zend_hash_add_ptr(SPCFG(ini).entries, entry->key, entry); | ||
| 499 | return SP_PARSER_STOP; | ||
| 500 | |||
| 501 | err: | ||
| 502 | if (entry) { | ||
| 503 | sp_free_ini_entry(entry); | ||
| 504 | pefree(entry, 1); | ||
| 505 | } | ||
| 506 | return SP_PARSER_ERROR; | ||
| 560 | } | 507 | } |
diff --git a/src/sp_config_keywords.h b/src/sp_config_keywords.h index a279cc9..01eb0d1 100644 --- a/src/sp_config_keywords.h +++ b/src/sp_config_keywords.h | |||
| @@ -2,21 +2,18 @@ | |||
| 2 | #define SP_CONFIG_KEYWORDS_H | 2 | #define SP_CONFIG_KEYWORDS_H |
| 3 | #include "php_snuffleupagus.h" | 3 | #include "php_snuffleupagus.h" |
| 4 | 4 | ||
| 5 | int parse_random(char *line); | 5 | SP_PARSE_FN(parse_enable); |
| 6 | int parse_disable_xxe(char *line); | 6 | SP_PARSE_FN(parse_global); |
| 7 | int parse_auto_cookie_secure(char *line); | 7 | SP_PARSE_FN(parse_cookie); |
| 8 | int parse_global_strict(char *line); | 8 | SP_PARSE_FN(parse_unserialize); |
| 9 | int parse_global(char *line); | 9 | SP_PARSE_FN(parse_readonly_exec); |
| 10 | int parse_cookie(char *line); | 10 | SP_PARSE_FN(parse_disabled_functions); |
| 11 | int parse_unserialize(char *line); | 11 | SP_PARSE_FN(parse_upload_validation); |
| 12 | int parse_readonly_exec(char *line); | 12 | SP_PARSE_FN(parse_eval_filter_conf); |
| 13 | int parse_disabled_functions(char *line); | 13 | SP_PARSE_FN(parse_session); |
| 14 | int parse_upload_validation(char *line); | 14 | SP_PARSE_FN(parse_wrapper_whitelist); |
| 15 | int parse_eval_blacklist(char *line); | 15 | SP_PARSE_FN(parse_log_media); |
| 16 | int parse_eval_whitelist(char *line); | 16 | SP_PARSE_FN(parse_ini_protection); |
| 17 | int parse_session(char *line); | 17 | SP_PARSE_FN(parse_ini_entry); |
| 18 | int parse_sloppy_comparison(char *line); | ||
| 19 | int parse_wrapper_whitelist(char *line); | ||
| 20 | int parse_log_media(char *line); | ||
| 21 | 18 | ||
| 22 | #endif // __SP_CONFIG_KEYWORDS_H | 19 | #endif // __SP_CONFIG_KEYWORDS_H |
diff --git a/src/sp_config_scanner.cached.c b/src/sp_config_scanner.cached.c new file mode 100644 index 0000000..7617ebf --- /dev/null +++ b/src/sp_config_scanner.cached.c | |||
| @@ -0,0 +1,1677 @@ | |||
| 1 | /* Generated by re2c */ | ||
| 2 | #include "php_snuffleupagus.h" | ||
| 3 | |||
| 4 | enum YYCONDTYPE { | ||
| 5 | yycinit, | ||
| 6 | yyccond, | ||
| 7 | yyccond_op, | ||
| 8 | yycrule, | ||
| 9 | }; | ||
| 10 | |||
| 11 | |||
| 12 | #define cs_log_error(fmt, ...) sp_log_err("config", fmt, ##__VA_ARGS__) | ||
| 13 | #define cs_log_info(fmt, ...) sp_log_msg("config", SP_LOG_INFO, fmt, ##__VA_ARGS__) | ||
| 14 | #define cs_log_warning(fmt, ...) sp_log_warn("config", fmt, ##__VA_ARGS__) | ||
| 15 | |||
| 16 | |||
| 17 | zend_string *sp_get_arg_string(sp_parsed_keyword *kw) { | ||
| 18 | if (!kw || !kw->arg) { | ||
| 19 | return NULL; | ||
| 20 | } | ||
| 21 | zend_string *ret = zend_string_init(kw->arg, kw->arglen, 1); | ||
| 22 | char *pin, *pout; | ||
| 23 | pin = pout = ZSTR_VAL(ret); | ||
| 24 | char *pend = pin + ZSTR_LEN(ret); | ||
| 25 | |||
| 26 | while (pin < pend) { | ||
| 27 | if (*pin == '\\') { | ||
| 28 | pin++; | ||
| 29 | } | ||
| 30 | *pout = *pin; | ||
| 31 | pin++; pout++; | ||
| 32 | } | ||
| 33 | |||
| 34 | if (pin != pout) { | ||
| 35 | size_t len = pout - ZSTR_VAL(ret); | ||
| 36 | ret = zend_string_truncate(ret, len, 1); | ||
| 37 | ZSTR_VAL(ret)[len] = 0; | ||
| 38 | } | ||
| 39 | |||
| 40 | return ret; | ||
| 41 | } | ||
| 42 | |||
| 43 | zend_string *sp_get_textual_representation(sp_parsed_keyword *parsed_rule) { | ||
| 44 | // a rule is "sp.keyword...keyword(arg);\0" | ||
| 45 | size_t len = 3; // sp + ; | ||
| 46 | sp_parsed_keyword *kw; | ||
| 47 | for (kw = parsed_rule; kw->kw; kw++) { | ||
| 48 | len++; // . | ||
| 49 | len += kw->kwlen; | ||
| 50 | if (kw->argtype == SP_ARGTYPE_EMPTY) { | ||
| 51 | len += 2; // () | ||
| 52 | } else if (kw->argtype == SP_ARGTYPE_STR) { | ||
| 53 | len += 4; | ||
| 54 | len += kw->arglen; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | zend_string *ret = zend_string_alloc(len, 1); | ||
| 58 | char *ptr = ZSTR_VAL(ret); | ||
| 59 | memcpy(ptr, "sp", 2); ptr += 2; | ||
| 60 | for (kw = parsed_rule; kw->kw; kw++) { | ||
| 61 | *ptr++ = '.'; | ||
| 62 | memcpy(ptr, kw->kw, kw->kwlen); ptr += kw->kwlen; | ||
| 63 | if (kw->argtype == SP_ARGTYPE_EMPTY || kw->argtype == SP_ARGTYPE_STR || kw->argtype == SP_ARGTYPE_UNKNOWN) { | ||
| 64 | *ptr++ = '('; | ||
| 65 | } | ||
| 66 | if (kw->argtype == SP_ARGTYPE_STR && kw->arg) { | ||
| 67 | *ptr++ = '"'; | ||
| 68 | memcpy(ptr, kw->arg, kw->arglen); ptr += kw->arglen; | ||
| 69 | *ptr++ = '"'; | ||
| 70 | } | ||
| 71 | if (kw->argtype == SP_ARGTYPE_EMPTY || kw->argtype == SP_ARGTYPE_STR || kw->argtype == SP_ARGTYPE_UNKNOWN) { | ||
| 72 | *ptr++ = ')'; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | *ptr++ = ';'; | ||
| 76 | *ptr = 0; | ||
| 77 | return ret; | ||
| 78 | } | ||
| 79 | |||
| 80 | static void str_dtor(zval *zv) { | ||
| 81 | zend_string_release_ex(Z_STR_P(zv), 1); | ||
| 82 | } | ||
| 83 | |||
| 84 | // sy_ functions and macros are helpers for the shunting yard algorithm | ||
| 85 | #define sy_res_push(val) \ | ||
| 86 | if (cond_res_i >= 100) { cs_log_error("condition too complex on line %d", lineno); goto out; } \ | ||
| 87 | cond_res[cond_res_i++] = val; | ||
| 88 | #define sy_res_pop() cond_res[--cond_res_i] | ||
| 89 | #define sy_op_push(op) \ | ||
| 90 | if (cond_op_i >= 100) { cs_log_error("condition too complex on line %d", lineno); goto out; } \ | ||
| 91 | cond_op[cond_op_i++] = op; | ||
| 92 | #define sy_op_pop() cond_op[--cond_op_i] | ||
| 93 | #define sy_op_peek() cond_op[cond_op_i-1] | ||
| 94 | |||
| 95 | static inline int sy_op_precedence(char op) { | ||
| 96 | switch (op) { | ||
| 97 | case '!': return 120; | ||
| 98 | case '<': | ||
| 99 | case '>': | ||
| 100 | case 'L': // <= | ||
| 101 | case 'G': // >= | ||
| 102 | return 90; | ||
| 103 | case '&': return 70; | ||
| 104 | case '|': return 60; | ||
| 105 | case '=': return 20; | ||
| 106 | } | ||
| 107 | return 0; | ||
| 108 | } | ||
| 109 | static inline int sy_op_is_left_assoc(char op) { | ||
| 110 | switch (op) { | ||
| 111 | case '!': return 0; | ||
| 112 | } | ||
| 113 | return 1; | ||
| 114 | } | ||
| 115 | static int sy_apply_op(char op, int a, int b) { | ||
| 116 | switch (op) { | ||
| 117 | case '!': return !a; | ||
| 118 | case '&': return (b && a); | ||
| 119 | case '|': return (b || a); | ||
| 120 | case '<': return (b < a); | ||
| 121 | case 'L': return (b <= a); | ||
| 122 | case 'G': return (b >= a); | ||
| 123 | case '>': return (b > a); | ||
| 124 | case '=': return (b == a); | ||
| 125 | } | ||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | #define SY_APPLY_OP_FROM_STACK() \ | ||
| 130 | char op = sy_op_pop(); \ | ||
| 131 | int unary = (op == '!'); \ | ||
| 132 | if (cond_res_i < (2 - unary)) { cs_log_error("not enough input on line %d", lineno); goto out; } \ | ||
| 133 | int a = sy_res_pop(); \ | ||
| 134 | int b = unary ? 0 : sy_res_pop(); \ | ||
| 135 | int res = sy_apply_op(op, a, b); \ | ||
| 136 | sy_res_push(res); | ||
| 137 | |||
| 138 | #define TMPSTR(tmpstr, t2, t1) \ | ||
| 139 | char tmpstr[1024]; \ | ||
| 140 | size_t tmplen = MIN(t2-t1-2, 1023); \ | ||
| 141 | strncpy(tmpstr, t1+1, tmplen); \ | ||
| 142 | tmpstr[tmplen] = 0; | ||
| 143 | |||
| 144 | |||
| 145 | zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_keyword*)) | ||
| 146 | { | ||
| 147 | const char *YYCURSOR = data; | ||
| 148 | const char *YYMARKER, *t1, *t2, *t3, *t4; | ||
| 149 | const char *yyt1; | ||
| 150 | const char *yyt2; | ||
| 151 | const char *yyt3; | ||
| 152 | const char *yyt4; | ||
| 153 | |||
| 154 | |||
| 155 | int ret = FAILURE; | ||
| 156 | |||
| 157 | const int max_keywords = 16; | ||
| 158 | sp_parsed_keyword parsed_rule[max_keywords+1]; | ||
| 159 | int kw_i = 0; | ||
| 160 | |||
| 161 | HashTable vars; | ||
| 162 | zend_hash_init(&vars, 10, NULL, str_dtor, 1); | ||
| 163 | zend_hash_str_add_ptr(&vars, ZEND_STRL("PHP_VERSION_ID"), zend_string_init(ZEND_STRL(ZEND_TOSTR(PHP_VERSION_ID)), 1)); | ||
| 164 | |||
| 165 | |||
| 166 | int cond_res[100] = {1}; | ||
| 167 | int cond_res_i = 0; | ||
| 168 | char cond_op[100] = {0}; | ||
| 169 | int cond_op_i = 0; | ||
| 170 | |||
| 171 | int cond = yycinit; | ||
| 172 | long lineno = 1; | ||
| 173 | |||
| 174 | |||
| 175 | { | ||
| 176 | unsigned char yych; | ||
| 177 | unsigned int yyaccept = 0; | ||
| 178 | if (cond < 2) { | ||
| 179 | if (cond < 1) { | ||
| 180 | goto yyc_init; | ||
| 181 | } else { | ||
| 182 | goto yyc_cond; | ||
| 183 | } | ||
| 184 | } else { | ||
| 185 | if (cond < 3) { | ||
| 186 | goto yyc_cond_op; | ||
| 187 | } else { | ||
| 188 | goto yyc_rule; | ||
| 189 | } | ||
| 190 | } | ||
| 191 | /* *********************************** */ | ||
| 192 | yyc_init: | ||
| 193 | { | ||
| 194 | static const unsigned char yybm[] = { | ||
| 195 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 196 | 80, 88, 0, 80, 80, 16, 80, 80, | ||
| 197 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 198 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 199 | 88, 80, 16, 80, 80, 80, 80, 80, | ||
| 200 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 201 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 202 | 112, 112, 80, 80, 80, 80, 80, 80, | ||
| 203 | 80, 112, 112, 112, 112, 112, 112, 112, | ||
| 204 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 205 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 206 | 112, 112, 112, 80, 144, 80, 80, 112, | ||
| 207 | 80, 112, 112, 112, 112, 112, 112, 112, | ||
| 208 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 209 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 210 | 112, 112, 112, 80, 80, 80, 80, 80, | ||
| 211 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 212 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 213 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 214 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 215 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 216 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 217 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 218 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 219 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 220 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 221 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 222 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 223 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 224 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 225 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 226 | 80, 80, 80, 80, 80, 80, 80, 80, | ||
| 227 | }; | ||
| 228 | yych = *YYCURSOR; | ||
| 229 | if (yybm[0+yych] & 8) { | ||
| 230 | goto yy6; | ||
| 231 | } | ||
| 232 | if (yych <= '#') { | ||
| 233 | if (yych <= '\n') { | ||
| 234 | if (yych <= 0x00) goto yy2; | ||
| 235 | if (yych <= 0x08) goto yy4; | ||
| 236 | goto yy9; | ||
| 237 | } else { | ||
| 238 | if (yych == '\r') goto yy11; | ||
| 239 | if (yych <= '"') goto yy4; | ||
| 240 | goto yy12; | ||
| 241 | } | ||
| 242 | } else { | ||
| 243 | if (yych <= '?') { | ||
| 244 | if (yych == ';') goto yy12; | ||
| 245 | goto yy4; | ||
| 246 | } else { | ||
| 247 | if (yych <= '@') goto yy15; | ||
| 248 | if (yych == 's') goto yy16; | ||
| 249 | goto yy4; | ||
| 250 | } | ||
| 251 | } | ||
| 252 | yy2: | ||
| 253 | ++YYCURSOR; | ||
| 254 | { ret = SUCCESS; goto out; } | ||
| 255 | yy4: | ||
| 256 | ++YYCURSOR; | ||
| 257 | yy5: | ||
| 258 | { cs_log_error("Parser error on line %d", lineno); goto out; } | ||
| 259 | yy6: | ||
| 260 | yych = *++YYCURSOR; | ||
| 261 | if (yybm[0+yych] & 8) { | ||
| 262 | goto yy6; | ||
| 263 | } | ||
| 264 | { goto yyc_init; } | ||
| 265 | yy9: | ||
| 266 | ++YYCURSOR; | ||
| 267 | { lineno++; goto yyc_init; } | ||
| 268 | yy11: | ||
| 269 | yych = *++YYCURSOR; | ||
| 270 | if (yych == '\n') goto yy9; | ||
| 271 | goto yy5; | ||
| 272 | yy12: | ||
| 273 | yych = *++YYCURSOR; | ||
| 274 | if (yybm[0+yych] & 16) { | ||
| 275 | goto yy12; | ||
| 276 | } | ||
| 277 | { goto yyc_init; } | ||
| 278 | yy15: | ||
| 279 | yyaccept = 0; | ||
| 280 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 281 | switch (yych) { | ||
| 282 | case 'c': goto yy17; | ||
| 283 | case 'e': goto yy19; | ||
| 284 | case 'i': goto yy20; | ||
| 285 | case 'l': goto yy21; | ||
| 286 | case 's': goto yy22; | ||
| 287 | case 'w': goto yy23; | ||
| 288 | default: goto yy5; | ||
| 289 | } | ||
| 290 | yy16: | ||
| 291 | yyaccept = 0; | ||
| 292 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 293 | if (yych == 'e') goto yy24; | ||
| 294 | if (yych == 'p') goto yy25; | ||
| 295 | goto yy5; | ||
| 296 | yy17: | ||
| 297 | yych = *++YYCURSOR; | ||
| 298 | if (yych == 'o') goto yy27; | ||
| 299 | yy18: | ||
| 300 | YYCURSOR = YYMARKER; | ||
| 301 | if (yyaccept <= 4) { | ||
| 302 | if (yyaccept <= 2) { | ||
| 303 | if (yyaccept <= 1) { | ||
| 304 | if (yyaccept == 0) { | ||
| 305 | goto yy5; | ||
| 306 | } else { | ||
| 307 | yyt2 = YYCURSOR; | ||
| 308 | goto yy67; | ||
| 309 | } | ||
| 310 | } else { | ||
| 311 | yyt2 = YYCURSOR; | ||
| 312 | goto yy71; | ||
| 313 | } | ||
| 314 | } else { | ||
| 315 | if (yyaccept == 3) { | ||
| 316 | goto yy67; | ||
| 317 | } else { | ||
| 318 | goto yy71; | ||
| 319 | } | ||
| 320 | } | ||
| 321 | } else { | ||
| 322 | if (yyaccept <= 6) { | ||
| 323 | if (yyaccept == 5) { | ||
| 324 | yyt2 = YYCURSOR; | ||
| 325 | goto yy86; | ||
| 326 | } else { | ||
| 327 | yyt4 = YYCURSOR; | ||
| 328 | goto yy91; | ||
| 329 | } | ||
| 330 | } else { | ||
| 331 | if (yyaccept == 7) { | ||
| 332 | goto yy86; | ||
| 333 | } else { | ||
| 334 | goto yy91; | ||
| 335 | } | ||
| 336 | } | ||
| 337 | } | ||
| 338 | yy19: | ||
| 339 | yych = *++YYCURSOR; | ||
| 340 | if (yych == 'n') goto yy28; | ||
| 341 | if (yych == 'r') goto yy29; | ||
| 342 | goto yy18; | ||
| 343 | yy20: | ||
| 344 | yych = *++YYCURSOR; | ||
| 345 | if (yych == 'n') goto yy30; | ||
| 346 | goto yy18; | ||
| 347 | yy21: | ||
| 348 | yych = *++YYCURSOR; | ||
| 349 | if (yych == 'o') goto yy31; | ||
| 350 | goto yy18; | ||
| 351 | yy22: | ||
| 352 | yych = *++YYCURSOR; | ||
| 353 | if (yych == 'e') goto yy24; | ||
| 354 | goto yy18; | ||
| 355 | yy23: | ||
| 356 | yych = *++YYCURSOR; | ||
| 357 | if (yych == 'a') goto yy32; | ||
| 358 | goto yy18; | ||
| 359 | yy24: | ||
| 360 | yych = *++YYCURSOR; | ||
| 361 | if (yych == 't') goto yy33; | ||
| 362 | goto yy18; | ||
| 363 | yy25: | ||
| 364 | ++YYCURSOR; | ||
| 365 | { kw_i = 0; goto yyc_rule; } | ||
| 366 | yy27: | ||
| 367 | yych = *++YYCURSOR; | ||
| 368 | if (yych == 'n') goto yy34; | ||
| 369 | goto yy18; | ||
| 370 | yy28: | ||
| 371 | yych = *++YYCURSOR; | ||
| 372 | if (yych == 'd') goto yy35; | ||
| 373 | goto yy18; | ||
| 374 | yy29: | ||
| 375 | yych = *++YYCURSOR; | ||
| 376 | if (yych == 'r') goto yy36; | ||
| 377 | goto yy18; | ||
| 378 | yy30: | ||
| 379 | yych = *++YYCURSOR; | ||
| 380 | if (yych == 'f') goto yy37; | ||
| 381 | goto yy18; | ||
| 382 | yy31: | ||
| 383 | yych = *++YYCURSOR; | ||
| 384 | if (yych == 'g') goto yy38; | ||
| 385 | goto yy18; | ||
| 386 | yy32: | ||
| 387 | yych = *++YYCURSOR; | ||
| 388 | if (yych == 'r') goto yy39; | ||
| 389 | goto yy18; | ||
| 390 | yy33: | ||
| 391 | yych = *++YYCURSOR; | ||
| 392 | if (yych == '\t') goto yy40; | ||
| 393 | if (yych == ' ') goto yy40; | ||
| 394 | goto yy18; | ||
| 395 | yy34: | ||
| 396 | yych = *++YYCURSOR; | ||
| 397 | if (yych == 'd') goto yy42; | ||
| 398 | goto yy18; | ||
| 399 | yy35: | ||
| 400 | yych = *++YYCURSOR; | ||
| 401 | if (yych == '_') goto yy43; | ||
| 402 | goto yy18; | ||
| 403 | yy36: | ||
| 404 | yych = *++YYCURSOR; | ||
| 405 | if (yych == '"') goto yy18; | ||
| 406 | if (yych == 'o') goto yy46; | ||
| 407 | goto yy45; | ||
| 408 | yy37: | ||
| 409 | yych = *++YYCURSOR; | ||
| 410 | if (yych != 'o') goto yy18; | ||
| 411 | yy38: | ||
| 412 | yych = *++YYCURSOR; | ||
| 413 | if (yych == '"') goto yy18; | ||
| 414 | goto yy48; | ||
| 415 | yy39: | ||
| 416 | yych = *++YYCURSOR; | ||
| 417 | if (yych == 'n') goto yy49; | ||
| 418 | goto yy18; | ||
| 419 | yy40: | ||
| 420 | yych = *++YYCURSOR; | ||
| 421 | if (yych <= '@') { | ||
| 422 | if (yych <= '\t') { | ||
| 423 | if (yych <= 0x08) goto yy18; | ||
| 424 | goto yy40; | ||
| 425 | } else { | ||
| 426 | if (yych == ' ') goto yy40; | ||
| 427 | goto yy18; | ||
| 428 | } | ||
| 429 | } else { | ||
| 430 | if (yych <= '_') { | ||
| 431 | if (yych <= 'Z') { | ||
| 432 | yyt1 = YYCURSOR; | ||
| 433 | goto yy50; | ||
| 434 | } | ||
| 435 | if (yych <= '^') goto yy18; | ||
| 436 | yyt1 = YYCURSOR; | ||
| 437 | goto yy50; | ||
| 438 | } else { | ||
| 439 | if (yych <= '`') goto yy18; | ||
| 440 | if (yych <= 'z') { | ||
| 441 | yyt1 = YYCURSOR; | ||
| 442 | goto yy50; | ||
| 443 | } | ||
| 444 | goto yy18; | ||
| 445 | } | ||
| 446 | } | ||
| 447 | yy42: | ||
| 448 | yych = *++YYCURSOR; | ||
| 449 | if (yych == 'i') goto yy52; | ||
| 450 | goto yy18; | ||
| 451 | yy43: | ||
| 452 | yych = *++YYCURSOR; | ||
| 453 | if (yych == 'c') goto yy53; | ||
| 454 | goto yy18; | ||
| 455 | yy44: | ||
| 456 | yych = *++YYCURSOR; | ||
| 457 | yy45: | ||
| 458 | if (yych <= 0x1F) { | ||
| 459 | if (yych == '\t') goto yy44; | ||
| 460 | goto yy18; | ||
| 461 | } else { | ||
| 462 | if (yych <= ' ') goto yy44; | ||
| 463 | if (yych == '"') { | ||
| 464 | yyt1 = YYCURSOR; | ||
| 465 | goto yy54; | ||
| 466 | } | ||
| 467 | goto yy18; | ||
| 468 | } | ||
| 469 | yy46: | ||
| 470 | yych = *++YYCURSOR; | ||
| 471 | if (yych == 'r') goto yy56; | ||
| 472 | goto yy18; | ||
| 473 | yy47: | ||
| 474 | yych = *++YYCURSOR; | ||
| 475 | yy48: | ||
| 476 | if (yych <= 0x1F) { | ||
| 477 | if (yych == '\t') goto yy47; | ||
| 478 | goto yy18; | ||
| 479 | } else { | ||
| 480 | if (yych <= ' ') goto yy47; | ||
| 481 | if (yych == '"') { | ||
| 482 | yyt1 = YYCURSOR; | ||
| 483 | goto yy57; | ||
| 484 | } | ||
| 485 | goto yy18; | ||
| 486 | } | ||
| 487 | yy49: | ||
| 488 | yych = *++YYCURSOR; | ||
| 489 | if (yych == '"') goto yy18; | ||
| 490 | if (yych == 'i') goto yy61; | ||
| 491 | goto yy60; | ||
| 492 | yy50: | ||
| 493 | yych = *++YYCURSOR; | ||
| 494 | if (yybm[0+yych] & 32) { | ||
| 495 | goto yy50; | ||
| 496 | } | ||
| 497 | if (yych == '\t') { | ||
| 498 | yyt2 = YYCURSOR; | ||
| 499 | goto yy62; | ||
| 500 | } | ||
| 501 | if (yych == ' ') { | ||
| 502 | yyt2 = YYCURSOR; | ||
| 503 | goto yy62; | ||
| 504 | } | ||
| 505 | goto yy18; | ||
| 506 | yy52: | ||
| 507 | yych = *++YYCURSOR; | ||
| 508 | if (yych == 't') goto yy64; | ||
| 509 | goto yy18; | ||
| 510 | yy53: | ||
| 511 | yych = *++YYCURSOR; | ||
| 512 | if (yych == 'o') goto yy65; | ||
| 513 | goto yy18; | ||
| 514 | yy54: | ||
| 515 | yych = *++YYCURSOR; | ||
| 516 | if (yybm[0+yych] & 64) { | ||
| 517 | goto yy54; | ||
| 518 | } | ||
| 519 | if (yych <= '\r') goto yy18; | ||
| 520 | if (yych <= '"') goto yy66; | ||
| 521 | goto yy68; | ||
| 522 | yy56: | ||
| 523 | yych = *++YYCURSOR; | ||
| 524 | if (yych == '"') goto yy18; | ||
| 525 | goto yy45; | ||
| 526 | yy57: | ||
| 527 | yych = *++YYCURSOR; | ||
| 528 | if (yych <= '\r') { | ||
| 529 | if (yych == '\n') goto yy18; | ||
| 530 | if (yych <= '\f') goto yy57; | ||
| 531 | goto yy18; | ||
| 532 | } else { | ||
| 533 | if (yych <= '"') { | ||
| 534 | if (yych <= '!') goto yy57; | ||
| 535 | goto yy70; | ||
| 536 | } else { | ||
| 537 | if (yych == '\\') goto yy72; | ||
| 538 | goto yy57; | ||
| 539 | } | ||
| 540 | } | ||
| 541 | yy59: | ||
| 542 | yych = *++YYCURSOR; | ||
| 543 | yy60: | ||
| 544 | if (yych <= 0x1F) { | ||
| 545 | if (yych == '\t') goto yy59; | ||
| 546 | goto yy18; | ||
| 547 | } else { | ||
| 548 | if (yych <= ' ') goto yy59; | ||
| 549 | if (yych == '"') { | ||
| 550 | yyt1 = YYCURSOR; | ||
| 551 | goto yy74; | ||
| 552 | } | ||
| 553 | goto yy18; | ||
| 554 | } | ||
| 555 | yy61: | ||
| 556 | yych = *++YYCURSOR; | ||
| 557 | if (yych == 'n') goto yy76; | ||
| 558 | goto yy18; | ||
| 559 | yy62: | ||
| 560 | yych = *++YYCURSOR; | ||
| 561 | if (yych <= 0x1F) { | ||
| 562 | if (yych == '\t') goto yy62; | ||
| 563 | goto yy18; | ||
| 564 | } else { | ||
| 565 | if (yych <= ' ') goto yy62; | ||
| 566 | if (yych == '"') { | ||
| 567 | yyt3 = YYCURSOR; | ||
| 568 | goto yy77; | ||
| 569 | } | ||
| 570 | goto yy18; | ||
| 571 | } | ||
| 572 | yy64: | ||
| 573 | yych = *++YYCURSOR; | ||
| 574 | if (yych == 'i') goto yy79; | ||
| 575 | goto yy18; | ||
| 576 | yy65: | ||
| 577 | yych = *++YYCURSOR; | ||
| 578 | if (yych == 'n') goto yy80; | ||
| 579 | goto yy18; | ||
| 580 | yy66: | ||
| 581 | yych = *++YYCURSOR; | ||
| 582 | yyt2 = YYCURSOR; | ||
| 583 | if (yych == ';') goto yy81; | ||
| 584 | yy67: | ||
| 585 | t1 = yyt1; | ||
| 586 | t2 = yyt2; | ||
| 587 | { | ||
| 588 | if (!cond_res[0]) { goto yyc_init; } | ||
| 589 | TMPSTR(tmpstr, t2, t1); | ||
| 590 | cs_log_error("[line %d]: %s", lineno, tmpstr); | ||
| 591 | goto out; | ||
| 592 | } | ||
| 593 | yy68: | ||
| 594 | yych = *++YYCURSOR; | ||
| 595 | if (yybm[0+yych] & 64) { | ||
| 596 | goto yy54; | ||
| 597 | } | ||
| 598 | if (yych <= '\r') goto yy18; | ||
| 599 | if (yych <= '"') goto yy82; | ||
| 600 | goto yy68; | ||
| 601 | yy70: | ||
| 602 | yych = *++YYCURSOR; | ||
| 603 | yyt2 = YYCURSOR; | ||
| 604 | if (yych == ';') goto yy83; | ||
| 605 | yy71: | ||
| 606 | t1 = yyt1; | ||
| 607 | t2 = yyt2; | ||
| 608 | { | ||
| 609 | if (!cond_res[0]) { goto yyc_init; } | ||
| 610 | TMPSTR(tmpstr, t2, t1); | ||
| 611 | cs_log_info("[line %d]: %s", lineno, tmpstr); | ||
| 612 | goto yyc_init; | ||
| 613 | } | ||
| 614 | yy72: | ||
| 615 | yych = *++YYCURSOR; | ||
| 616 | if (yych <= '\r') { | ||
| 617 | if (yych == '\n') goto yy18; | ||
| 618 | if (yych <= '\f') goto yy57; | ||
| 619 | goto yy18; | ||
| 620 | } else { | ||
| 621 | if (yych <= '"') { | ||
| 622 | if (yych <= '!') goto yy57; | ||
| 623 | goto yy84; | ||
| 624 | } else { | ||
| 625 | if (yych == '\\') goto yy72; | ||
| 626 | goto yy57; | ||
| 627 | } | ||
| 628 | } | ||
| 629 | yy74: | ||
| 630 | yych = *++YYCURSOR; | ||
| 631 | if (yych <= '\r') { | ||
| 632 | if (yych == '\n') goto yy18; | ||
| 633 | if (yych <= '\f') goto yy74; | ||
| 634 | goto yy18; | ||
| 635 | } else { | ||
| 636 | if (yych <= '"') { | ||
| 637 | if (yych <= '!') goto yy74; | ||
| 638 | goto yy85; | ||
| 639 | } else { | ||
| 640 | if (yych == '\\') goto yy87; | ||
| 641 | goto yy74; | ||
| 642 | } | ||
| 643 | } | ||
| 644 | yy76: | ||
| 645 | yych = *++YYCURSOR; | ||
| 646 | if (yych == 'g') goto yy89; | ||
| 647 | goto yy18; | ||
| 648 | yy77: | ||
| 649 | yych = *++YYCURSOR; | ||
| 650 | if (yych <= '\r') { | ||
| 651 | if (yych == '\n') goto yy18; | ||
| 652 | if (yych <= '\f') goto yy77; | ||
| 653 | goto yy18; | ||
| 654 | } else { | ||
| 655 | if (yych <= '"') { | ||
| 656 | if (yych <= '!') goto yy77; | ||
| 657 | goto yy90; | ||
| 658 | } else { | ||
| 659 | if (yych == '\\') goto yy92; | ||
| 660 | goto yy77; | ||
| 661 | } | ||
| 662 | } | ||
| 663 | yy79: | ||
| 664 | yych = *++YYCURSOR; | ||
| 665 | if (yych == 'o') goto yy94; | ||
| 666 | goto yy18; | ||
| 667 | yy80: | ||
| 668 | yych = *++YYCURSOR; | ||
| 669 | if (yych == 'd') goto yy95; | ||
| 670 | goto yy18; | ||
| 671 | yy81: | ||
| 672 | ++YYCURSOR; | ||
| 673 | goto yy67; | ||
| 674 | yy82: | ||
| 675 | yyaccept = 1; | ||
| 676 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 677 | if (yybm[0+yych] & 128) { | ||
| 678 | goto yy68; | ||
| 679 | } | ||
| 680 | if (yych <= '\r') { | ||
| 681 | if (yych == '\n') { | ||
| 682 | yyt2 = YYCURSOR; | ||
| 683 | goto yy67; | ||
| 684 | } | ||
| 685 | if (yych <= '\f') goto yy54; | ||
| 686 | yyt2 = YYCURSOR; | ||
| 687 | goto yy67; | ||
| 688 | } else { | ||
| 689 | if (yych <= '"') { | ||
| 690 | if (yych <= '!') goto yy54; | ||
| 691 | goto yy66; | ||
| 692 | } else { | ||
| 693 | if (yych == ';') { | ||
| 694 | yyt2 = YYCURSOR; | ||
| 695 | goto yy96; | ||
| 696 | } | ||
| 697 | goto yy54; | ||
| 698 | } | ||
| 699 | } | ||
| 700 | yy83: | ||
| 701 | ++YYCURSOR; | ||
| 702 | goto yy71; | ||
| 703 | yy84: | ||
| 704 | yyaccept = 2; | ||
| 705 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 706 | if (yych <= '!') { | ||
| 707 | if (yych <= '\n') { | ||
| 708 | if (yych <= '\t') goto yy57; | ||
| 709 | yyt2 = YYCURSOR; | ||
| 710 | goto yy71; | ||
| 711 | } else { | ||
| 712 | if (yych == '\r') { | ||
| 713 | yyt2 = YYCURSOR; | ||
| 714 | goto yy71; | ||
| 715 | } | ||
| 716 | goto yy57; | ||
| 717 | } | ||
| 718 | } else { | ||
| 719 | if (yych <= ';') { | ||
| 720 | if (yych <= '"') goto yy70; | ||
| 721 | if (yych <= ':') goto yy57; | ||
| 722 | yyt2 = YYCURSOR; | ||
| 723 | goto yy97; | ||
| 724 | } else { | ||
| 725 | if (yych == '\\') goto yy72; | ||
| 726 | goto yy57; | ||
| 727 | } | ||
| 728 | } | ||
| 729 | yy85: | ||
| 730 | yych = *++YYCURSOR; | ||
| 731 | yyt2 = YYCURSOR; | ||
| 732 | if (yych == ';') goto yy98; | ||
| 733 | yy86: | ||
| 734 | t1 = yyt1; | ||
| 735 | t2 = yyt2; | ||
| 736 | { | ||
| 737 | if (!cond_res[0]) { goto yyc_init; } | ||
| 738 | TMPSTR(tmpstr, t2, t1); | ||
| 739 | cs_log_warning("[line %d]: %s", lineno, tmpstr); | ||
| 740 | goto yyc_init; | ||
| 741 | } | ||
| 742 | yy87: | ||
| 743 | yych = *++YYCURSOR; | ||
| 744 | if (yych <= '\r') { | ||
| 745 | if (yych == '\n') goto yy18; | ||
| 746 | if (yych <= '\f') goto yy74; | ||
| 747 | goto yy18; | ||
| 748 | } else { | ||
| 749 | if (yych <= '"') { | ||
| 750 | if (yych <= '!') goto yy74; | ||
| 751 | goto yy99; | ||
| 752 | } else { | ||
| 753 | if (yych == '\\') goto yy87; | ||
| 754 | goto yy74; | ||
| 755 | } | ||
| 756 | } | ||
| 757 | yy89: | ||
| 758 | yych = *++YYCURSOR; | ||
| 759 | if (yych == '"') goto yy18; | ||
| 760 | goto yy60; | ||
| 761 | yy90: | ||
| 762 | yych = *++YYCURSOR; | ||
| 763 | yyt4 = YYCURSOR; | ||
| 764 | goto yy101; | ||
| 765 | yy91: | ||
| 766 | t1 = yyt1; | ||
| 767 | t2 = yyt2; | ||
| 768 | t3 = yyt3; | ||
| 769 | t4 = yyt4; | ||
| 770 | { | ||
| 771 | if (!cond_res[0]) { goto yyc_init; } | ||
| 772 | char *key = (char*)t1; | ||
| 773 | int keylen = t2-t1; | ||
| 774 | zend_string *tmp = zend_hash_str_find_ptr(&vars, key, keylen); | ||
| 775 | if (tmp) { | ||
| 776 | zend_hash_str_del(&vars, key, keylen); | ||
| 777 | } | ||
| 778 | tmp = zend_string_init(t3+1, t4-t3-2, 1); | ||
| 779 | zend_hash_str_add_ptr(&vars, key, keylen, tmp); | ||
| 780 | goto yyc_init; | ||
| 781 | } | ||
| 782 | yy92: | ||
| 783 | yych = *++YYCURSOR; | ||
| 784 | if (yych <= '\r') { | ||
| 785 | if (yych == '\n') goto yy18; | ||
| 786 | if (yych <= '\f') goto yy77; | ||
| 787 | goto yy18; | ||
| 788 | } else { | ||
| 789 | if (yych <= '"') { | ||
| 790 | if (yych <= '!') goto yy77; | ||
| 791 | goto yy103; | ||
| 792 | } else { | ||
| 793 | if (yych == '\\') goto yy92; | ||
| 794 | goto yy77; | ||
| 795 | } | ||
| 796 | } | ||
| 797 | yy94: | ||
| 798 | yych = *++YYCURSOR; | ||
| 799 | if (yych == 'n') goto yy104; | ||
| 800 | goto yy18; | ||
| 801 | yy95: | ||
| 802 | yych = *++YYCURSOR; | ||
| 803 | if (yych == 'i') goto yy105; | ||
| 804 | goto yy18; | ||
| 805 | yy96: | ||
| 806 | yyaccept = 3; | ||
| 807 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 808 | if (yybm[0+yych] & 64) { | ||
| 809 | goto yy54; | ||
| 810 | } | ||
| 811 | if (yych <= '\r') goto yy67; | ||
| 812 | if (yych <= '"') goto yy66; | ||
| 813 | goto yy68; | ||
| 814 | yy97: | ||
| 815 | yyaccept = 4; | ||
| 816 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 817 | if (yych <= '\r') { | ||
| 818 | if (yych == '\n') goto yy71; | ||
| 819 | if (yych <= '\f') goto yy57; | ||
| 820 | goto yy71; | ||
| 821 | } else { | ||
| 822 | if (yych <= '"') { | ||
| 823 | if (yych <= '!') goto yy57; | ||
| 824 | goto yy70; | ||
| 825 | } else { | ||
| 826 | if (yych == '\\') goto yy72; | ||
| 827 | goto yy57; | ||
| 828 | } | ||
| 829 | } | ||
| 830 | yy98: | ||
| 831 | ++YYCURSOR; | ||
| 832 | goto yy86; | ||
| 833 | yy99: | ||
| 834 | yyaccept = 5; | ||
| 835 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 836 | if (yych <= '!') { | ||
| 837 | if (yych <= '\n') { | ||
| 838 | if (yych <= '\t') goto yy74; | ||
| 839 | yyt2 = YYCURSOR; | ||
| 840 | goto yy86; | ||
| 841 | } else { | ||
| 842 | if (yych == '\r') { | ||
| 843 | yyt2 = YYCURSOR; | ||
| 844 | goto yy86; | ||
| 845 | } | ||
| 846 | goto yy74; | ||
| 847 | } | ||
| 848 | } else { | ||
| 849 | if (yych <= ';') { | ||
| 850 | if (yych <= '"') goto yy85; | ||
| 851 | if (yych <= ':') goto yy74; | ||
| 852 | yyt2 = YYCURSOR; | ||
| 853 | goto yy106; | ||
| 854 | } else { | ||
| 855 | if (yych == '\\') goto yy87; | ||
| 856 | goto yy74; | ||
| 857 | } | ||
| 858 | } | ||
| 859 | yy100: | ||
| 860 | yych = *++YYCURSOR; | ||
| 861 | yy101: | ||
| 862 | if (yych <= 0x1F) { | ||
| 863 | if (yych == '\t') goto yy100; | ||
| 864 | goto yy91; | ||
| 865 | } else { | ||
| 866 | if (yych <= ' ') goto yy100; | ||
| 867 | if (yych != ';') goto yy91; | ||
| 868 | } | ||
| 869 | ++YYCURSOR; | ||
| 870 | goto yy91; | ||
| 871 | yy103: | ||
| 872 | yyaccept = 6; | ||
| 873 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 874 | if (yych <= ' ') { | ||
| 875 | if (yych <= '\n') { | ||
| 876 | if (yych <= 0x08) goto yy77; | ||
| 877 | if (yych <= '\t') { | ||
| 878 | yyt4 = YYCURSOR; | ||
| 879 | goto yy107; | ||
| 880 | } | ||
| 881 | yyt4 = YYCURSOR; | ||
| 882 | goto yy91; | ||
| 883 | } else { | ||
| 884 | if (yych == '\r') { | ||
| 885 | yyt4 = YYCURSOR; | ||
| 886 | goto yy91; | ||
| 887 | } | ||
| 888 | if (yych <= 0x1F) goto yy77; | ||
| 889 | yyt4 = YYCURSOR; | ||
| 890 | goto yy107; | ||
| 891 | } | ||
| 892 | } else { | ||
| 893 | if (yych <= ':') { | ||
| 894 | if (yych == '"') goto yy90; | ||
| 895 | goto yy77; | ||
| 896 | } else { | ||
| 897 | if (yych <= ';') { | ||
| 898 | yyt4 = YYCURSOR; | ||
| 899 | goto yy109; | ||
| 900 | } | ||
| 901 | if (yych == '\\') goto yy92; | ||
| 902 | goto yy77; | ||
| 903 | } | ||
| 904 | } | ||
| 905 | yy104: | ||
| 906 | yych = *++YYCURSOR; | ||
| 907 | if (yych == '\t') goto yy110; | ||
| 908 | if (yych == ' ') goto yy110; | ||
| 909 | goto yy18; | ||
| 910 | yy105: | ||
| 911 | yych = *++YYCURSOR; | ||
| 912 | if (yych == 't') goto yy113; | ||
| 913 | goto yy18; | ||
| 914 | yy106: | ||
| 915 | yyaccept = 7; | ||
| 916 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 917 | if (yych <= '\r') { | ||
| 918 | if (yych == '\n') goto yy86; | ||
| 919 | if (yych <= '\f') goto yy74; | ||
| 920 | goto yy86; | ||
| 921 | } else { | ||
| 922 | if (yych <= '"') { | ||
| 923 | if (yych <= '!') goto yy74; | ||
| 924 | goto yy85; | ||
| 925 | } else { | ||
| 926 | if (yych == '\\') goto yy87; | ||
| 927 | goto yy74; | ||
| 928 | } | ||
| 929 | } | ||
| 930 | yy107: | ||
| 931 | yyaccept = 8; | ||
| 932 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 933 | if (yych <= ' ') { | ||
| 934 | if (yych <= '\n') { | ||
| 935 | if (yych <= 0x08) goto yy77; | ||
| 936 | if (yych <= '\t') goto yy107; | ||
| 937 | goto yy91; | ||
| 938 | } else { | ||
| 939 | if (yych == '\r') goto yy91; | ||
| 940 | if (yych <= 0x1F) goto yy77; | ||
| 941 | goto yy107; | ||
| 942 | } | ||
| 943 | } else { | ||
| 944 | if (yych <= ':') { | ||
| 945 | if (yych == '"') goto yy90; | ||
| 946 | goto yy77; | ||
| 947 | } else { | ||
| 948 | if (yych <= ';') goto yy109; | ||
| 949 | if (yych == '\\') goto yy92; | ||
| 950 | goto yy77; | ||
| 951 | } | ||
| 952 | } | ||
| 953 | yy109: | ||
| 954 | yyaccept = 8; | ||
| 955 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 956 | if (yych <= '\r') { | ||
| 957 | if (yych == '\n') goto yy91; | ||
| 958 | if (yych <= '\f') goto yy77; | ||
| 959 | goto yy91; | ||
| 960 | } else { | ||
| 961 | if (yych <= '"') { | ||
| 962 | if (yych <= '!') goto yy77; | ||
| 963 | goto yy90; | ||
| 964 | } else { | ||
| 965 | if (yych == '\\') goto yy92; | ||
| 966 | goto yy77; | ||
| 967 | } | ||
| 968 | } | ||
| 969 | yy110: | ||
| 970 | yych = *++YYCURSOR; | ||
| 971 | if (yych == '\t') goto yy110; | ||
| 972 | if (yych == ' ') goto yy110; | ||
| 973 | { cond_res_i = 0; goto yyc_cond; } | ||
| 974 | yy113: | ||
| 975 | yych = *++YYCURSOR; | ||
| 976 | if (yych != 'i') goto yy18; | ||
| 977 | yych = *++YYCURSOR; | ||
| 978 | if (yych != 'o') goto yy18; | ||
| 979 | yych = *++YYCURSOR; | ||
| 980 | if (yych != 'n') goto yy18; | ||
| 981 | yy116: | ||
| 982 | yych = *++YYCURSOR; | ||
| 983 | if (yych <= 0x1F) { | ||
| 984 | if (yych == '\t') goto yy116; | ||
| 985 | goto yy18; | ||
| 986 | } else { | ||
| 987 | if (yych <= ' ') goto yy116; | ||
| 988 | if (yych != ';') goto yy18; | ||
| 989 | } | ||
| 990 | ++YYCURSOR; | ||
| 991 | { cond_res[0] = 1; cond_res_i = 0; goto yyc_init; } | ||
| 992 | } | ||
| 993 | /* *********************************** */ | ||
| 994 | yyc_cond: | ||
| 995 | { | ||
| 996 | static const unsigned char yybm[] = { | ||
| 997 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 998 | 64, 72, 0, 64, 64, 0, 64, 64, | ||
| 999 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1000 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1001 | 72, 64, 0, 64, 64, 64, 64, 64, | ||
| 1002 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1003 | 112, 112, 112, 112, 112, 112, 112, 112, | ||
| 1004 | 112, 112, 64, 64, 64, 64, 64, 64, | ||
| 1005 | 64, 96, 96, 96, 96, 96, 96, 96, | ||
| 1006 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1007 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1008 | 96, 96, 96, 64, 128, 64, 64, 96, | ||
| 1009 | 64, 96, 96, 96, 96, 96, 96, 96, | ||
| 1010 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1011 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1012 | 96, 96, 96, 64, 64, 64, 64, 64, | ||
| 1013 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1014 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1015 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1016 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1017 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1018 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1019 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1020 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1021 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1022 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1023 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1024 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1025 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1026 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1027 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1028 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1029 | }; | ||
| 1030 | yych = *YYCURSOR; | ||
| 1031 | if (yybm[0+yych] & 8) { | ||
| 1032 | goto yy124; | ||
| 1033 | } | ||
| 1034 | if (yych <= '(') { | ||
| 1035 | if (yych <= '\r') { | ||
| 1036 | if (yych <= 0x08) goto yy122; | ||
| 1037 | if (yych <= '\n') goto yy127; | ||
| 1038 | if (yych >= '\r') goto yy129; | ||
| 1039 | } else { | ||
| 1040 | if (yych <= 0x1F) goto yy122; | ||
| 1041 | if (yych <= '!') goto yy130; | ||
| 1042 | if (yych >= '(') goto yy132; | ||
| 1043 | } | ||
| 1044 | } else { | ||
| 1045 | if (yych <= 'Z') { | ||
| 1046 | if (yych <= '/') goto yy122; | ||
| 1047 | if (yych <= '9') { | ||
| 1048 | yyt1 = YYCURSOR; | ||
| 1049 | goto yy134; | ||
| 1050 | } | ||
| 1051 | if (yych >= 'A') { | ||
| 1052 | yyt1 = YYCURSOR; | ||
| 1053 | goto yy137; | ||
| 1054 | } | ||
| 1055 | } else { | ||
| 1056 | if (yych <= '_') { | ||
| 1057 | if (yych >= '_') { | ||
| 1058 | yyt1 = YYCURSOR; | ||
| 1059 | goto yy137; | ||
| 1060 | } | ||
| 1061 | } else { | ||
| 1062 | if (yych <= '`') goto yy122; | ||
| 1063 | if (yych <= 'z') { | ||
| 1064 | yyt1 = YYCURSOR; | ||
| 1065 | goto yy137; | ||
| 1066 | } | ||
| 1067 | } | ||
| 1068 | } | ||
| 1069 | } | ||
| 1070 | yy122: | ||
| 1071 | ++YYCURSOR; | ||
| 1072 | yy123: | ||
| 1073 | { cs_log_error("Syntax error in condition on line %d", lineno); goto out; } | ||
| 1074 | yy124: | ||
| 1075 | yych = *++YYCURSOR; | ||
| 1076 | if (yybm[0+yych] & 8) { | ||
| 1077 | goto yy124; | ||
| 1078 | } | ||
| 1079 | { goto yyc_cond; } | ||
| 1080 | yy127: | ||
| 1081 | ++YYCURSOR; | ||
| 1082 | { lineno++; goto yyc_cond; } | ||
| 1083 | yy129: | ||
| 1084 | yych = *++YYCURSOR; | ||
| 1085 | if (yych == '\n') goto yy127; | ||
| 1086 | goto yy123; | ||
| 1087 | yy130: | ||
| 1088 | ++YYCURSOR; | ||
| 1089 | t1 = YYCURSOR - 1; | ||
| 1090 | { sy_op_push(*t1); goto yyc_cond; } | ||
| 1091 | yy132: | ||
| 1092 | ++YYCURSOR; | ||
| 1093 | t1 = YYCURSOR - 1; | ||
| 1094 | { sy_op_push(*t1); goto yyc_cond; } | ||
| 1095 | yy134: | ||
| 1096 | yych = *++YYCURSOR; | ||
| 1097 | if (yybm[0+yych] & 16) { | ||
| 1098 | goto yy134; | ||
| 1099 | } | ||
| 1100 | t1 = yyt1; | ||
| 1101 | t2 = YYCURSOR; | ||
| 1102 | { sy_res_push(atoi(t1)); goto yyc_cond_op; } | ||
| 1103 | yy137: | ||
| 1104 | yyaccept = 0; | ||
| 1105 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1106 | if (yybm[0+yych] & 32) { | ||
| 1107 | goto yy137; | ||
| 1108 | } | ||
| 1109 | if (yych == '(') goto yy140; | ||
| 1110 | yy139: | ||
| 1111 | t1 = yyt1; | ||
| 1112 | t2 = YYCURSOR; | ||
| 1113 | { | ||
| 1114 | zend_string *tmp = zend_hash_str_find_ptr(&vars, t1, t2-t1); | ||
| 1115 | if (!tmp) { | ||
| 1116 | cs_log_error("unknown variable in condition on line %d", lineno); | ||
| 1117 | goto out; | ||
| 1118 | } | ||
| 1119 | sy_res_push(atoi(ZSTR_VAL(tmp))); | ||
| 1120 | goto yyc_cond_op; | ||
| 1121 | } | ||
| 1122 | yy140: | ||
| 1123 | yych = *++YYCURSOR; | ||
| 1124 | if (yych == '"') { | ||
| 1125 | yyt2 = YYCURSOR; | ||
| 1126 | goto yy142; | ||
| 1127 | } | ||
| 1128 | if (yych == ')') { | ||
| 1129 | yyt2 = YYCURSOR; | ||
| 1130 | goto yy144; | ||
| 1131 | } | ||
| 1132 | yy141: | ||
| 1133 | YYCURSOR = YYMARKER; | ||
| 1134 | if (yyaccept == 0) { | ||
| 1135 | goto yy139; | ||
| 1136 | } else { | ||
| 1137 | goto yy145; | ||
| 1138 | } | ||
| 1139 | yy142: | ||
| 1140 | yych = *++YYCURSOR; | ||
| 1141 | if (yybm[0+yych] & 64) { | ||
| 1142 | goto yy142; | ||
| 1143 | } | ||
| 1144 | if (yych <= '\r') goto yy141; | ||
| 1145 | if (yych <= '"') goto yy146; | ||
| 1146 | goto yy147; | ||
| 1147 | yy144: | ||
| 1148 | ++YYCURSOR; | ||
| 1149 | yy145: | ||
| 1150 | t1 = yyt1; | ||
| 1151 | t3 = yyt2; | ||
| 1152 | t2 = yyt2 - 1; | ||
| 1153 | t4 = YYCURSOR - 1; | ||
| 1154 | { | ||
| 1155 | if (t4-t3 >= 2 && strlen("extension_loaded") == t2-t1 && strncmp("extension_loaded", t1, t2-t1) == 0) { | ||
| 1156 | int is_loaded = (zend_hash_str_find_ptr(&module_registry, t3+1, t4-t3-2) != NULL); | ||
| 1157 | sy_res_push(is_loaded); | ||
| 1158 | } else { | ||
| 1159 | cs_log_error("unknown function in condition on line %d", lineno); | ||
| 1160 | goto out; | ||
| 1161 | } | ||
| 1162 | goto yyc_cond_op; | ||
| 1163 | } | ||
| 1164 | yy146: | ||
| 1165 | yych = *++YYCURSOR; | ||
| 1166 | if (yych == ')') goto yy144; | ||
| 1167 | goto yy141; | ||
| 1168 | yy147: | ||
| 1169 | yych = *++YYCURSOR; | ||
| 1170 | if (yybm[0+yych] & 64) { | ||
| 1171 | goto yy142; | ||
| 1172 | } | ||
| 1173 | if (yych <= '\r') goto yy141; | ||
| 1174 | if (yych >= '#') goto yy147; | ||
| 1175 | yych = *++YYCURSOR; | ||
| 1176 | if (yybm[0+yych] & 128) { | ||
| 1177 | goto yy147; | ||
| 1178 | } | ||
| 1179 | if (yych <= '\r') { | ||
| 1180 | if (yych == '\n') goto yy141; | ||
| 1181 | if (yych <= '\f') goto yy142; | ||
| 1182 | goto yy141; | ||
| 1183 | } else { | ||
| 1184 | if (yych <= '"') { | ||
| 1185 | if (yych <= '!') goto yy142; | ||
| 1186 | goto yy146; | ||
| 1187 | } else { | ||
| 1188 | if (yych != ')') goto yy142; | ||
| 1189 | } | ||
| 1190 | } | ||
| 1191 | yyaccept = 1; | ||
| 1192 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1193 | if (yybm[0+yych] & 64) { | ||
| 1194 | goto yy142; | ||
| 1195 | } | ||
| 1196 | if (yych <= '\r') goto yy145; | ||
| 1197 | if (yych <= '"') goto yy146; | ||
| 1198 | goto yy147; | ||
| 1199 | } | ||
| 1200 | /* *********************************** */ | ||
| 1201 | yyc_cond_op: | ||
| 1202 | { | ||
| 1203 | static const unsigned char yybm[] = { | ||
| 1204 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1205 | 0, 128, 0, 0, 0, 0, 0, 0, | ||
| 1206 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1207 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1208 | 128, 0, 0, 0, 0, 0, 0, 0, | ||
| 1209 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1210 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1211 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1212 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1213 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1214 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1215 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1216 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1217 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1218 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1219 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1220 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1221 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1222 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1223 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1224 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1225 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1226 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1227 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1228 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1229 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1230 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1231 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1232 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1233 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1234 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1235 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 1236 | }; | ||
| 1237 | yych = *YYCURSOR; | ||
| 1238 | if (yybm[0+yych] & 128) { | ||
| 1239 | goto yy155; | ||
| 1240 | } | ||
| 1241 | if (yych <= ')') { | ||
| 1242 | if (yych <= '\r') { | ||
| 1243 | if (yych <= 0x08) goto yy153; | ||
| 1244 | if (yych <= '\n') goto yy158; | ||
| 1245 | if (yych >= '\r') goto yy160; | ||
| 1246 | } else { | ||
| 1247 | if (yych == '&') { | ||
| 1248 | yyt1 = YYCURSOR; | ||
| 1249 | goto yy161; | ||
| 1250 | } | ||
| 1251 | if (yych >= ')') goto yy162; | ||
| 1252 | } | ||
| 1253 | } else { | ||
| 1254 | if (yych <= '=') { | ||
| 1255 | if (yych <= ':') goto yy153; | ||
| 1256 | if (yych <= ';') goto yy164; | ||
| 1257 | if (yych <= '<') { | ||
| 1258 | yyt1 = YYCURSOR; | ||
| 1259 | goto yy166; | ||
| 1260 | } | ||
| 1261 | yyt1 = YYCURSOR; | ||
| 1262 | goto yy168; | ||
| 1263 | } else { | ||
| 1264 | if (yych <= '>') { | ||
| 1265 | yyt1 = YYCURSOR; | ||
| 1266 | goto yy166; | ||
| 1267 | } | ||
| 1268 | if (yych == '|') { | ||
| 1269 | yyt1 = YYCURSOR; | ||
| 1270 | goto yy169; | ||
| 1271 | } | ||
| 1272 | } | ||
| 1273 | } | ||
| 1274 | yy153: | ||
| 1275 | ++YYCURSOR; | ||
| 1276 | yy154: | ||
| 1277 | { cs_log_error("Syntax error in condition on line %d", lineno); goto out; } | ||
| 1278 | yy155: | ||
| 1279 | yych = *++YYCURSOR; | ||
| 1280 | if (yybm[0+yych] & 128) { | ||
| 1281 | goto yy155; | ||
| 1282 | } | ||
| 1283 | { goto yyc_cond_op; } | ||
| 1284 | yy158: | ||
| 1285 | ++YYCURSOR; | ||
| 1286 | { lineno++; goto yyc_cond_op; } | ||
| 1287 | yy160: | ||
| 1288 | yych = *++YYCURSOR; | ||
| 1289 | if (yych == '\n') goto yy158; | ||
| 1290 | goto yy154; | ||
| 1291 | yy161: | ||
| 1292 | yych = *++YYCURSOR; | ||
| 1293 | if (yych == '&') goto yy170; | ||
| 1294 | goto yy154; | ||
| 1295 | yy162: | ||
| 1296 | ++YYCURSOR; | ||
| 1297 | { | ||
| 1298 | while (cond_op_i && sy_op_peek() != '(') { | ||
| 1299 | SY_APPLY_OP_FROM_STACK(); | ||
| 1300 | } | ||
| 1301 | if (cond_op_i == 0 || sy_op_peek() != '(') { | ||
| 1302 | cs_log_error("unbalanced parathesis on line %d", lineno); goto out; | ||
| 1303 | } | ||
| 1304 | cond_op_i--; | ||
| 1305 | goto yyc_cond_op; | ||
| 1306 | } | ||
| 1307 | yy164: | ||
| 1308 | ++YYCURSOR; | ||
| 1309 | { | ||
| 1310 | while (cond_op_i) { | ||
| 1311 | if (sy_op_peek() == '(') { cs_log_error("unbalanced parathesis on line %d", lineno); goto out; } | ||
| 1312 | SY_APPLY_OP_FROM_STACK(); | ||
| 1313 | } | ||
| 1314 | if (cond_res_i > 1) { cs_log_error("invalid condition on line %d", lineno); goto out; } | ||
| 1315 | goto yyc_init; | ||
| 1316 | } | ||
| 1317 | yy166: | ||
| 1318 | yych = *++YYCURSOR; | ||
| 1319 | if (yych == '=') goto yy170; | ||
| 1320 | yy167: | ||
| 1321 | t1 = yyt1; | ||
| 1322 | t2 = YYCURSOR; | ||
| 1323 | { | ||
| 1324 | char op1 = *t1; | ||
| 1325 | if (t2-t1 == 2) { | ||
| 1326 | switch (op1) { | ||
| 1327 | case '<': op1 = 'L'; break; // <= | ||
| 1328 | case '>': op1 = 'G'; break; // >= | ||
| 1329 | } | ||
| 1330 | } | ||
| 1331 | while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1) && sy_op_is_left_assoc(*t1)))) { | ||
| 1332 | SY_APPLY_OP_FROM_STACK(); | ||
| 1333 | } | ||
| 1334 | sy_op_push(*t1); | ||
| 1335 | goto yyc_cond; | ||
| 1336 | } | ||
| 1337 | yy168: | ||
| 1338 | yych = *++YYCURSOR; | ||
| 1339 | if (yych == '=') goto yy170; | ||
| 1340 | goto yy154; | ||
| 1341 | yy169: | ||
| 1342 | yych = *++YYCURSOR; | ||
| 1343 | if (yych != '|') goto yy154; | ||
| 1344 | yy170: | ||
| 1345 | ++YYCURSOR; | ||
| 1346 | goto yy167; | ||
| 1347 | } | ||
| 1348 | /* *********************************** */ | ||
| 1349 | yyc_rule: | ||
| 1350 | { | ||
| 1351 | static const unsigned char yybm[] = { | ||
| 1352 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1353 | 64, 88, 16, 64, 64, 0, 64, 64, | ||
| 1354 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1355 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1356 | 88, 64, 0, 64, 64, 64, 64, 64, | ||
| 1357 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1358 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1359 | 96, 96, 64, 64, 64, 64, 64, 64, | ||
| 1360 | 64, 96, 96, 96, 96, 96, 96, 96, | ||
| 1361 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1362 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1363 | 96, 96, 96, 64, 128, 64, 64, 96, | ||
| 1364 | 64, 96, 96, 96, 96, 96, 96, 96, | ||
| 1365 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1366 | 96, 96, 96, 96, 96, 96, 96, 96, | ||
| 1367 | 96, 96, 96, 64, 64, 64, 64, 64, | ||
| 1368 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1369 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1370 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1371 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1372 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1373 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1374 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1375 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1376 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1377 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1378 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1379 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1380 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1381 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1382 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1383 | 64, 64, 64, 64, 64, 64, 64, 64, | ||
| 1384 | }; | ||
| 1385 | yych = *YYCURSOR; | ||
| 1386 | if (yybm[0+yych] & 8) { | ||
| 1387 | goto yy175; | ||
| 1388 | } | ||
| 1389 | if (yych <= '\r') { | ||
| 1390 | if (yych <= 0x08) goto yy173; | ||
| 1391 | if (yych <= '\n') goto yy178; | ||
| 1392 | if (yych >= '\r') goto yy179; | ||
| 1393 | } else { | ||
| 1394 | if (yych <= '.') { | ||
| 1395 | if (yych >= '.') goto yy180; | ||
| 1396 | } else { | ||
| 1397 | if (yych == ';') goto yy181; | ||
| 1398 | } | ||
| 1399 | } | ||
| 1400 | yy173: | ||
| 1401 | ++YYCURSOR; | ||
| 1402 | yy174: | ||
| 1403 | { goto end_of_rule; } | ||
| 1404 | yy175: | ||
| 1405 | yych = *++YYCURSOR; | ||
| 1406 | if (yybm[0+yych] & 8) { | ||
| 1407 | goto yy175; | ||
| 1408 | } | ||
| 1409 | { goto yyc_rule; } | ||
| 1410 | yy178: | ||
| 1411 | yyaccept = 0; | ||
| 1412 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1413 | if (yych <= '\r') { | ||
| 1414 | if (yych <= 0x08) goto yy174; | ||
| 1415 | if (yych <= '\n') { | ||
| 1416 | yyt1 = YYCURSOR; | ||
| 1417 | goto yy183; | ||
| 1418 | } | ||
| 1419 | if (yych <= '\f') goto yy174; | ||
| 1420 | yyt1 = YYCURSOR; | ||
| 1421 | goto yy186; | ||
| 1422 | } else { | ||
| 1423 | if (yych <= ' ') { | ||
| 1424 | if (yych <= 0x1F) goto yy174; | ||
| 1425 | yyt1 = YYCURSOR; | ||
| 1426 | goto yy183; | ||
| 1427 | } else { | ||
| 1428 | if (yych == '.') { | ||
| 1429 | yyt1 = YYCURSOR; | ||
| 1430 | goto yy187; | ||
| 1431 | } | ||
| 1432 | goto yy174; | ||
| 1433 | } | ||
| 1434 | } | ||
| 1435 | yy179: | ||
| 1436 | yyaccept = 0; | ||
| 1437 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1438 | if (yych == '\n') goto yy189; | ||
| 1439 | goto yy174; | ||
| 1440 | yy180: | ||
| 1441 | yych = *++YYCURSOR; | ||
| 1442 | if (yych <= '^') { | ||
| 1443 | if (yych <= '@') goto yy174; | ||
| 1444 | if (yych <= 'Z') { | ||
| 1445 | yyt1 = YYCURSOR; | ||
| 1446 | goto yy190; | ||
| 1447 | } | ||
| 1448 | goto yy174; | ||
| 1449 | } else { | ||
| 1450 | if (yych == '`') goto yy174; | ||
| 1451 | if (yych <= 'z') { | ||
| 1452 | yyt1 = YYCURSOR; | ||
| 1453 | goto yy190; | ||
| 1454 | } | ||
| 1455 | goto yy174; | ||
| 1456 | } | ||
| 1457 | yy181: | ||
| 1458 | ++YYCURSOR; | ||
| 1459 | { | ||
| 1460 | end_of_rule: | ||
| 1461 | if (!cond_res[0]) { goto yyc_init; } | ||
| 1462 | parsed_rule[kw_i++] = (sp_parsed_keyword){0, 0, 0, 0, 0, 0}; | ||
| 1463 | if (process_rule && process_rule(parsed_rule) != SUCCESS) { | ||
| 1464 | goto out; | ||
| 1465 | } | ||
| 1466 | goto yyc_init; | ||
| 1467 | } | ||
| 1468 | yy183: | ||
| 1469 | yych = *++YYCURSOR; | ||
| 1470 | if (yybm[0+yych] & 16) { | ||
| 1471 | goto yy183; | ||
| 1472 | } | ||
| 1473 | if (yych == '\r') goto yy186; | ||
| 1474 | if (yych == '.') goto yy187; | ||
| 1475 | yy185: | ||
| 1476 | YYCURSOR = YYMARKER; | ||
| 1477 | if (yyaccept <= 1) { | ||
| 1478 | if (yyaccept == 0) { | ||
| 1479 | goto yy174; | ||
| 1480 | } else { | ||
| 1481 | yyt3 = yyt4 = NULL; | ||
| 1482 | yyt2 = YYCURSOR; | ||
| 1483 | goto yy192; | ||
| 1484 | } | ||
| 1485 | } else { | ||
| 1486 | goto yy192; | ||
| 1487 | } | ||
| 1488 | yy186: | ||
| 1489 | yych = *++YYCURSOR; | ||
| 1490 | if (yych == '\n') goto yy183; | ||
| 1491 | goto yy185; | ||
| 1492 | yy187: | ||
| 1493 | ++YYCURSOR; | ||
| 1494 | YYCURSOR = yyt1; | ||
| 1495 | { lineno++; goto yyc_rule; } | ||
| 1496 | yy189: | ||
| 1497 | yych = *++YYCURSOR; | ||
| 1498 | if (yych <= '\r') { | ||
| 1499 | if (yych <= 0x08) goto yy185; | ||
| 1500 | if (yych <= '\n') { | ||
| 1501 | yyt1 = YYCURSOR; | ||
| 1502 | goto yy183; | ||
| 1503 | } | ||
| 1504 | if (yych <= '\f') goto yy185; | ||
| 1505 | yyt1 = YYCURSOR; | ||
| 1506 | goto yy186; | ||
| 1507 | } else { | ||
| 1508 | if (yych <= ' ') { | ||
| 1509 | if (yych <= 0x1F) goto yy185; | ||
| 1510 | yyt1 = YYCURSOR; | ||
| 1511 | goto yy183; | ||
| 1512 | } else { | ||
| 1513 | if (yych == '.') { | ||
| 1514 | yyt1 = YYCURSOR; | ||
| 1515 | goto yy187; | ||
| 1516 | } | ||
| 1517 | goto yy185; | ||
| 1518 | } | ||
| 1519 | } | ||
| 1520 | yy190: | ||
| 1521 | yyaccept = 1; | ||
| 1522 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1523 | if (yybm[0+yych] & 32) { | ||
| 1524 | goto yy190; | ||
| 1525 | } | ||
| 1526 | if (yych == '(') { | ||
| 1527 | yyt2 = YYCURSOR; | ||
| 1528 | goto yy193; | ||
| 1529 | } | ||
| 1530 | yyt3 = yyt4 = NULL; | ||
| 1531 | yyt2 = YYCURSOR; | ||
| 1532 | yy192: | ||
| 1533 | t1 = yyt1; | ||
| 1534 | t2 = yyt2; | ||
| 1535 | t3 = yyt3; | ||
| 1536 | t4 = yyt4; | ||
| 1537 | { | ||
| 1538 | if (!cond_res[0]) { goto yyc_rule; } | ||
| 1539 | if (kw_i == max_keywords) { | ||
| 1540 | cs_log_error("Too many keywords in rule (more than %d) on line %d", max_keywords, lineno); | ||
| 1541 | goto out; | ||
| 1542 | } | ||
| 1543 | sp_parsed_keyword kw = {.kw = (char*)t1, .kwlen = t2-t1, .arg = (char*)t3, .arglen = t4-t3, .argtype = SP_ARGTYPE_UNKNOWN, .lineno = lineno}; | ||
| 1544 | if (t3 && t4) { | ||
| 1545 | if (t3 == t4) { | ||
| 1546 | kw.argtype = SP_ARGTYPE_EMPTY; | ||
| 1547 | } else if (t4-t3 >= 2 && *t3 == '"') { | ||
| 1548 | kw.arg = (char*)t3 + 1; | ||
| 1549 | kw.arglen = t4 - t3 - 2; | ||
| 1550 | kw.argtype = SP_ARGTYPE_STR; | ||
| 1551 | } else { | ||
| 1552 | zend_string *tmp = zend_hash_str_find_ptr(&vars, t3, t4-t3); | ||
| 1553 | if (!tmp) { | ||
| 1554 | cs_log_error("unknown variable on line %d", lineno); | ||
| 1555 | goto out; | ||
| 1556 | } | ||
| 1557 | kw.arg = ZSTR_VAL(tmp); | ||
| 1558 | kw.arglen = ZSTR_LEN(tmp); | ||
| 1559 | kw.argtype = SP_ARGTYPE_STR; | ||
| 1560 | } | ||
| 1561 | } else { | ||
| 1562 | kw.argtype = SP_ARGTYPE_NONE; | ||
| 1563 | } | ||
| 1564 | parsed_rule[kw_i++] = kw; | ||
| 1565 | goto yyc_rule; | ||
| 1566 | } | ||
| 1567 | yy193: | ||
| 1568 | yych = *++YYCURSOR; | ||
| 1569 | if (yych <= '@') { | ||
| 1570 | if (yych <= '"') { | ||
| 1571 | if (yych <= '!') goto yy185; | ||
| 1572 | yyt3 = YYCURSOR; | ||
| 1573 | } else { | ||
| 1574 | if (yych == ')') { | ||
| 1575 | yyt3 = yyt4 = YYCURSOR; | ||
| 1576 | goto yy196; | ||
| 1577 | } | ||
| 1578 | goto yy185; | ||
| 1579 | } | ||
| 1580 | } else { | ||
| 1581 | if (yych <= '_') { | ||
| 1582 | if (yych <= 'Z') { | ||
| 1583 | yyt3 = YYCURSOR; | ||
| 1584 | goto yy197; | ||
| 1585 | } | ||
| 1586 | if (yych <= '^') goto yy185; | ||
| 1587 | yyt3 = YYCURSOR; | ||
| 1588 | goto yy197; | ||
| 1589 | } else { | ||
| 1590 | if (yych <= '`') goto yy185; | ||
| 1591 | if (yych <= 'z') { | ||
| 1592 | yyt3 = YYCURSOR; | ||
| 1593 | goto yy197; | ||
| 1594 | } | ||
| 1595 | goto yy185; | ||
| 1596 | } | ||
| 1597 | } | ||
| 1598 | yy194: | ||
| 1599 | yych = *++YYCURSOR; | ||
| 1600 | if (yybm[0+yych] & 64) { | ||
| 1601 | goto yy194; | ||
| 1602 | } | ||
| 1603 | if (yych <= '\r') goto yy185; | ||
| 1604 | if (yych <= '"') goto yy199; | ||
| 1605 | goto yy200; | ||
| 1606 | yy196: | ||
| 1607 | ++YYCURSOR; | ||
| 1608 | goto yy192; | ||
| 1609 | yy197: | ||
| 1610 | yych = *++YYCURSOR; | ||
| 1611 | if (yych <= '@') { | ||
| 1612 | if (yych <= ')') { | ||
| 1613 | if (yych <= '(') goto yy185; | ||
| 1614 | yyt4 = YYCURSOR; | ||
| 1615 | goto yy196; | ||
| 1616 | } else { | ||
| 1617 | if (yych <= '/') goto yy185; | ||
| 1618 | if (yych <= '9') goto yy197; | ||
| 1619 | goto yy185; | ||
| 1620 | } | ||
| 1621 | } else { | ||
| 1622 | if (yych <= '_') { | ||
| 1623 | if (yych <= 'Z') goto yy197; | ||
| 1624 | if (yych <= '^') goto yy185; | ||
| 1625 | goto yy197; | ||
| 1626 | } else { | ||
| 1627 | if (yych <= '`') goto yy185; | ||
| 1628 | if (yych <= 'z') goto yy197; | ||
| 1629 | goto yy185; | ||
| 1630 | } | ||
| 1631 | } | ||
| 1632 | yy199: | ||
| 1633 | yych = *++YYCURSOR; | ||
| 1634 | if (yych == ')') { | ||
| 1635 | yyt4 = YYCURSOR; | ||
| 1636 | goto yy196; | ||
| 1637 | } | ||
| 1638 | goto yy185; | ||
| 1639 | yy200: | ||
| 1640 | yych = *++YYCURSOR; | ||
| 1641 | if (yybm[0+yych] & 64) { | ||
| 1642 | goto yy194; | ||
| 1643 | } | ||
| 1644 | if (yych <= '\r') goto yy185; | ||
| 1645 | if (yych >= '#') goto yy200; | ||
| 1646 | yych = *++YYCURSOR; | ||
| 1647 | if (yybm[0+yych] & 128) { | ||
| 1648 | goto yy200; | ||
| 1649 | } | ||
| 1650 | if (yych <= '\r') { | ||
| 1651 | if (yych == '\n') goto yy185; | ||
| 1652 | if (yych <= '\f') goto yy194; | ||
| 1653 | goto yy185; | ||
| 1654 | } else { | ||
| 1655 | if (yych <= '"') { | ||
| 1656 | if (yych <= '!') goto yy194; | ||
| 1657 | goto yy199; | ||
| 1658 | } else { | ||
| 1659 | if (yych != ')') goto yy194; | ||
| 1660 | yyt4 = YYCURSOR; | ||
| 1661 | } | ||
| 1662 | } | ||
| 1663 | yyaccept = 2; | ||
| 1664 | yych = *(YYMARKER = ++YYCURSOR); | ||
| 1665 | if (yybm[0+yych] & 64) { | ||
| 1666 | goto yy194; | ||
| 1667 | } | ||
| 1668 | if (yych <= '\r') goto yy192; | ||
| 1669 | if (yych <= '"') goto yy199; | ||
| 1670 | goto yy200; | ||
| 1671 | } | ||
| 1672 | } | ||
| 1673 | |||
| 1674 | out: | ||
| 1675 | zend_hash_destroy(&vars); | ||
| 1676 | return ret; | ||
| 1677 | } \ No newline at end of file | ||
diff --git a/src/sp_config_scanner.h b/src/sp_config_scanner.h new file mode 100644 index 0000000..3284713 --- /dev/null +++ b/src/sp_config_scanner.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | |||
| 2 | #ifndef SP_CONFIG_SCANNER_H | ||
| 3 | #define SP_CONFIG_SCANNER_H | ||
| 4 | |||
| 5 | typedef enum { | ||
| 6 | SP_ARGTYPE_UNKNOWN = 0, | ||
| 7 | SP_ARGTYPE_NONE, | ||
| 8 | SP_ARGTYPE_EMPTY, | ||
| 9 | SP_ARGTYPE_STR | ||
| 10 | } sp_argtype; | ||
| 11 | |||
| 12 | typedef struct { | ||
| 13 | char *kw; // keyword points directly to the parsed input text and as such is not null-terminated | ||
| 14 | size_t kwlen; | ||
| 15 | char *arg; // optional argument / can be not null terminated | ||
| 16 | size_t arglen; | ||
| 17 | sp_argtype argtype; | ||
| 18 | long lineno; | ||
| 19 | } sp_parsed_keyword; | ||
| 20 | |||
| 21 | zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_keyword*)); | ||
| 22 | zend_string *sp_get_arg_string(sp_parsed_keyword *kw); | ||
| 23 | zend_string *sp_get_textual_representation(sp_parsed_keyword *parsed_rule); | ||
| 24 | |||
| 25 | #endif \ No newline at end of file | ||
diff --git a/src/sp_config_scanner.re b/src/sp_config_scanner.re new file mode 100644 index 0000000..d7c9884 --- /dev/null +++ b/src/sp_config_scanner.re | |||
| @@ -0,0 +1,325 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | /*!types:re2c*/ | ||
| 4 | |||
| 5 | #define cs_log_error(fmt, ...) sp_log_err("config", fmt, ##__VA_ARGS__) | ||
| 6 | #define cs_log_info(fmt, ...) sp_log_msg("config", SP_LOG_INFO, fmt, ##__VA_ARGS__) | ||
| 7 | #define cs_log_warning(fmt, ...) sp_log_warn("config", fmt, ##__VA_ARGS__) | ||
| 8 | |||
| 9 | |||
| 10 | zend_string *sp_get_arg_string(sp_parsed_keyword *kw) { | ||
| 11 | if (!kw || !kw->arg) { | ||
| 12 | return NULL; | ||
| 13 | } | ||
| 14 | zend_string *ret = zend_string_init(kw->arg, kw->arglen, 1); | ||
| 15 | char *pin, *pout; | ||
| 16 | pin = pout = ZSTR_VAL(ret); | ||
| 17 | char *pend = pin + ZSTR_LEN(ret); | ||
| 18 | |||
| 19 | while (pin < pend) { | ||
| 20 | if (*pin == '\\') { | ||
| 21 | pin++; | ||
| 22 | } | ||
| 23 | *pout = *pin; | ||
| 24 | pin++; pout++; | ||
| 25 | } | ||
| 26 | |||
| 27 | if (pin != pout) { | ||
| 28 | size_t len = pout - ZSTR_VAL(ret); | ||
| 29 | ret = zend_string_truncate(ret, len, 1); | ||
| 30 | ZSTR_VAL(ret)[len] = 0; | ||
| 31 | } | ||
| 32 | |||
| 33 | return ret; | ||
| 34 | } | ||
| 35 | |||
| 36 | zend_string *sp_get_textual_representation(sp_parsed_keyword *parsed_rule) { | ||
| 37 | // a rule is "sp.keyword...keyword(arg);\0" | ||
| 38 | size_t len = 3; // sp + ; | ||
| 39 | sp_parsed_keyword *kw; | ||
| 40 | for (kw = parsed_rule; kw->kw; kw++) { | ||
| 41 | len++; // . | ||
| 42 | len += kw->kwlen; | ||
| 43 | if (kw->argtype == SP_ARGTYPE_EMPTY) { | ||
| 44 | len += 2; // () | ||
| 45 | } else if (kw->argtype == SP_ARGTYPE_STR) { | ||
| 46 | len += 4; | ||
| 47 | len += kw->arglen; | ||
| 48 | } | ||
| 49 | } | ||
| 50 | zend_string *ret = zend_string_alloc(len, 1); | ||
| 51 | char *ptr = ZSTR_VAL(ret); | ||
| 52 | memcpy(ptr, "sp", 2); ptr += 2; | ||
| 53 | for (kw = parsed_rule; kw->kw; kw++) { | ||
| 54 | *ptr++ = '.'; | ||
| 55 | memcpy(ptr, kw->kw, kw->kwlen); ptr += kw->kwlen; | ||
| 56 | if (kw->argtype == SP_ARGTYPE_EMPTY || kw->argtype == SP_ARGTYPE_STR || kw->argtype == SP_ARGTYPE_UNKNOWN) { | ||
| 57 | *ptr++ = '('; | ||
| 58 | } | ||
| 59 | if (kw->argtype == SP_ARGTYPE_STR && kw->arg) { | ||
| 60 | *ptr++ = '"'; | ||
| 61 | memcpy(ptr, kw->arg, kw->arglen); ptr += kw->arglen; | ||
| 62 | *ptr++ = '"'; | ||
| 63 | } | ||
| 64 | if (kw->argtype == SP_ARGTYPE_EMPTY || kw->argtype == SP_ARGTYPE_STR || kw->argtype == SP_ARGTYPE_UNKNOWN) { | ||
| 65 | *ptr++ = ')'; | ||
| 66 | } | ||
| 67 | } | ||
| 68 | *ptr++ = ';'; | ||
| 69 | *ptr = 0; | ||
| 70 | return ret; | ||
| 71 | } | ||
| 72 | |||
| 73 | static void str_dtor(zval *zv) { | ||
| 74 | zend_string_release_ex(Z_STR_P(zv), 1); | ||
| 75 | } | ||
| 76 | |||
| 77 | // sy_ functions and macros are helpers for the shunting yard algorithm | ||
| 78 | #define sy_res_push(val) \ | ||
| 79 | if (cond_res_i >= 100) { cs_log_error("condition too complex on line %d", lineno); goto out; } \ | ||
| 80 | cond_res[cond_res_i++] = val; | ||
| 81 | #define sy_res_pop() cond_res[--cond_res_i] | ||
| 82 | #define sy_op_push(op) \ | ||
| 83 | if (cond_op_i >= 100) { cs_log_error("condition too complex on line %d", lineno); goto out; } \ | ||
| 84 | cond_op[cond_op_i++] = op; | ||
| 85 | #define sy_op_pop() cond_op[--cond_op_i] | ||
| 86 | #define sy_op_peek() cond_op[cond_op_i-1] | ||
| 87 | |||
| 88 | static inline int sy_op_precedence(char op) { | ||
| 89 | switch (op) { | ||
| 90 | case '!': return 120; | ||
| 91 | case '<': | ||
| 92 | case '>': | ||
| 93 | case 'L': // <= | ||
| 94 | case 'G': // >= | ||
| 95 | return 90; | ||
| 96 | case '&': return 70; | ||
| 97 | case '|': return 60; | ||
| 98 | case '=': return 20; | ||
| 99 | } | ||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | static inline int sy_op_is_left_assoc(char op) { | ||
| 103 | switch (op) { | ||
| 104 | case '!': return 0; | ||
| 105 | } | ||
| 106 | return 1; | ||
| 107 | } | ||
| 108 | static int sy_apply_op(char op, int a, int b) { | ||
| 109 | switch (op) { | ||
| 110 | case '!': return !a; | ||
| 111 | case '&': return (b && a); | ||
| 112 | case '|': return (b || a); | ||
| 113 | case '<': return (b < a); | ||
| 114 | case 'L': return (b <= a); | ||
| 115 | case 'G': return (b >= a); | ||
| 116 | case '>': return (b > a); | ||
| 117 | case '=': return (b == a); | ||
| 118 | } | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 122 | #define SY_APPLY_OP_FROM_STACK() \ | ||
| 123 | char op = sy_op_pop(); \ | ||
| 124 | int unary = (op == '!'); \ | ||
| 125 | if (cond_res_i < (2 - unary)) { cs_log_error("not enough input on line %d", lineno); goto out; } \ | ||
| 126 | int a = sy_res_pop(); \ | ||
| 127 | int b = unary ? 0 : sy_res_pop(); \ | ||
| 128 | int res = sy_apply_op(op, a, b); \ | ||
| 129 | sy_res_push(res); | ||
| 130 | |||
| 131 | #define TMPSTR(tmpstr, t2, t1) \ | ||
| 132 | char tmpstr[1024]; \ | ||
| 133 | size_t tmplen = MIN(t2-t1-2, 1023); \ | ||
| 134 | strncpy(tmpstr, t1+1, tmplen); \ | ||
| 135 | tmpstr[tmplen] = 0; | ||
| 136 | |||
| 137 | |||
| 138 | zend_result sp_config_scan(char *data, zend_result (*process_rule)(sp_parsed_keyword*)) | ||
| 139 | { | ||
| 140 | const char *YYCURSOR = data; | ||
| 141 | const char *YYMARKER, *t1, *t2, *t3, *t4; | ||
| 142 | /*!stags:re2c format = 'const char *@@;\n'; */ | ||
| 143 | |||
| 144 | int ret = FAILURE; | ||
| 145 | |||
| 146 | const int max_keywords = 16; | ||
| 147 | sp_parsed_keyword parsed_rule[max_keywords+1]; | ||
| 148 | int kw_i = 0; | ||
| 149 | |||
| 150 | HashTable vars; | ||
| 151 | zend_hash_init(&vars, 10, NULL, str_dtor, 1); | ||
| 152 | zend_hash_str_add_ptr(&vars, ZEND_STRL("PHP_VERSION_ID"), zend_string_init(ZEND_STRL(ZEND_TOSTR(PHP_VERSION_ID)), 1)); | ||
| 153 | |||
| 154 | |||
| 155 | int cond_res[100] = {1}; | ||
| 156 | int cond_res_i = 0; | ||
| 157 | char cond_op[100] = {0}; | ||
| 158 | int cond_op_i = 0; | ||
| 159 | |||
| 160 | int cond = yycinit; | ||
| 161 | long lineno = 1; | ||
| 162 | |||
| 163 | /*!re2c | ||
| 164 | re2c:define:YYCTYPE = "unsigned char"; | ||
| 165 | // re2c:define:YYCURSOR = data; | ||
| 166 | re2c:yyfill:enable = 0; | ||
| 167 | re2c:flags:tags = 1; | ||
| 168 | re2c:api:style = free-form; | ||
| 169 | re2c:define:YYGETCONDITION = "cond"; | ||
| 170 | re2c:define:YYSETCONDITION = "cond = @@;"; | ||
| 171 | |||
| 172 | end = "\x00"; | ||
| 173 | nl = "\r"?"\n"; | ||
| 174 | ws = [ \t]; | ||
| 175 | keyword = [a-zA-Z_][a-zA-Z0-9_]*; | ||
| 176 | string = "\"" ("\\\"" | [^"\r\n])* "\""; | ||
| 177 | |||
| 178 | <init> * { cs_log_error("Parser error on line %d", lineno); goto out; } | ||
| 179 | <init> ws+ { goto yyc_init; } | ||
| 180 | <init> [;#] .* { goto yyc_init; } | ||
| 181 | <init> nl { lineno++; goto yyc_init; } | ||
| 182 | <init> "sp" { kw_i = 0; goto yyc_rule; } | ||
| 183 | <init> end { ret = SUCCESS; goto out; } | ||
| 184 | <init> "@"? "set" ws+ @t1 keyword @t2 ws+ @t3 string @t4 ws* ";"? { | ||
| 185 | if (!cond_res[0]) { goto yyc_init; } | ||
| 186 | char *key = (char*)t1; | ||
| 187 | int keylen = t2-t1; | ||
| 188 | zend_string *tmp = zend_hash_str_find_ptr(&vars, key, keylen); | ||
| 189 | if (tmp) { | ||
| 190 | zend_hash_str_del(&vars, key, keylen); | ||
| 191 | } | ||
| 192 | tmp = zend_string_init(t3+1, t4-t3-2, 1); | ||
| 193 | zend_hash_str_add_ptr(&vars, key, keylen, tmp); | ||
| 194 | goto yyc_init; | ||
| 195 | } | ||
| 196 | <init> "@condition" ws+ { cond_res_i = 0; goto yyc_cond; } | ||
| 197 | <init> "@end_condition" ws* ";" { cond_res[0] = 1; cond_res_i = 0; goto yyc_init; } | ||
| 198 | <init> ( "@log" | "@info" ) ws+ @t1 string @t2 ";"? { | ||
| 199 | if (!cond_res[0]) { goto yyc_init; } | ||
| 200 | TMPSTR(tmpstr, t2, t1); | ||
| 201 | cs_log_info("[line %d]: %s", lineno, tmpstr); | ||
| 202 | goto yyc_init; | ||
| 203 | } | ||
| 204 | <init> ( "@warn" | "@warning" ) ws+ @t1 string @t2 ";"? { | ||
| 205 | if (!cond_res[0]) { goto yyc_init; } | ||
| 206 | TMPSTR(tmpstr, t2, t1); | ||
| 207 | cs_log_warning("[line %d]: %s", lineno, tmpstr); | ||
| 208 | goto yyc_init; | ||
| 209 | } | ||
| 210 | <init> ( "@err" | "@error" ) ws+ @t1 string @t2 ";"? { | ||
| 211 | if (!cond_res[0]) { goto yyc_init; } | ||
| 212 | TMPSTR(tmpstr, t2, t1); | ||
| 213 | cs_log_error("[line %d]: %s", lineno, tmpstr); | ||
| 214 | goto out; | ||
| 215 | } | ||
| 216 | |||
| 217 | |||
| 218 | <cond> ws+ { goto yyc_cond; } | ||
| 219 | <cond> nl { lineno++; goto yyc_cond; } | ||
| 220 | <cond> @t1 keyword @t2 "(" @t3 string? @t4 ")" { | ||
| 221 | if (t4-t3 >= 2 && strlen("extension_loaded") == t2-t1 && strncmp("extension_loaded", t1, t2-t1) == 0) { | ||
| 222 | int is_loaded = (zend_hash_str_find_ptr(&module_registry, t3+1, t4-t3-2) != NULL); | ||
| 223 | sy_res_push(is_loaded); | ||
| 224 | } else { | ||
| 225 | cs_log_error("unknown function in condition on line %d", lineno); | ||
| 226 | goto out; | ||
| 227 | } | ||
| 228 | goto yyc_cond_op; | ||
| 229 | } | ||
| 230 | <cond> @t1 keyword @t2 { | ||
| 231 | zend_string *tmp = zend_hash_str_find_ptr(&vars, t1, t2-t1); | ||
| 232 | if (!tmp) { | ||
| 233 | cs_log_error("unknown variable in condition on line %d", lineno); | ||
| 234 | goto out; | ||
| 235 | } | ||
| 236 | sy_res_push(atoi(ZSTR_VAL(tmp))); | ||
| 237 | goto yyc_cond_op; | ||
| 238 | } | ||
| 239 | <cond> @t1 [0-9]+ @t2 { sy_res_push(atoi(t1)); goto yyc_cond_op; } | ||
| 240 | <cond> @t1 "!" { sy_op_push(*t1); goto yyc_cond; } | ||
| 241 | <cond> @t1 "(" { sy_op_push(*t1); goto yyc_cond; } | ||
| 242 | <cond_op> ws+ { goto yyc_cond_op; } | ||
| 243 | <cond_op> nl { lineno++; goto yyc_cond_op; } | ||
| 244 | <cond_op> @t1 ( "&&" | "||" | "<" | ">" | "==" | "<=" | ">=") @t2 { | ||
| 245 | char op1 = *t1; | ||
| 246 | if (t2-t1 == 2) { | ||
| 247 | switch (op1) { | ||
| 248 | case '<': op1 = 'L'; break; // <= | ||
| 249 | case '>': op1 = 'G'; break; // >= | ||
| 250 | } | ||
| 251 | } | ||
| 252 | while (cond_op_i && sy_op_peek() != '(' && ((sy_op_precedence(sy_op_peek()) > sy_op_precedence(*t1)) || (sy_op_precedence(sy_op_peek()) == sy_op_precedence(*t1) && sy_op_is_left_assoc(*t1)))) { | ||
| 253 | SY_APPLY_OP_FROM_STACK(); | ||
| 254 | } | ||
| 255 | sy_op_push(*t1); | ||
| 256 | goto yyc_cond; | ||
| 257 | } | ||
| 258 | <cond_op> ")" { | ||
| 259 | while (cond_op_i && sy_op_peek() != '(') { | ||
| 260 | SY_APPLY_OP_FROM_STACK(); | ||
| 261 | } | ||
| 262 | if (cond_op_i == 0 || sy_op_peek() != '(') { | ||
| 263 | cs_log_error("unbalanced parathesis on line %d", lineno); goto out; | ||
| 264 | } | ||
| 265 | cond_op_i--; | ||
| 266 | goto yyc_cond_op; | ||
| 267 | } | ||
| 268 | <cond_op> ";" { | ||
| 269 | while (cond_op_i) { | ||
| 270 | if (sy_op_peek() == '(') { cs_log_error("unbalanced parathesis on line %d", lineno); goto out; } | ||
| 271 | SY_APPLY_OP_FROM_STACK(); | ||
| 272 | } | ||
| 273 | if (cond_res_i > 1) { cs_log_error("invalid condition on line %d", lineno); goto out; } | ||
| 274 | goto yyc_init; | ||
| 275 | } | ||
| 276 | <cond, cond_op> * { cs_log_error("Syntax error in condition on line %d", lineno); goto out; } | ||
| 277 | |||
| 278 | <rule> ws+ { goto yyc_rule; } | ||
| 279 | <rule> nl / ( nl | ws )* "." { lineno++; goto yyc_rule; } | ||
| 280 | <rule> "." @t1 keyword @t2 ( "(" @t3 ( string? | keyword ) @t4 ")" )? { | ||
| 281 | if (!cond_res[0]) { goto yyc_rule; } | ||
| 282 | if (kw_i == max_keywords) { | ||
| 283 | cs_log_error("Too many keywords in rule (more than %d) on line %d", max_keywords, lineno); | ||
| 284 | goto out; | ||
| 285 | } | ||
| 286 | sp_parsed_keyword kw = {.kw = (char*)t1, .kwlen = t2-t1, .arg = (char*)t3, .arglen = t4-t3, .argtype = SP_ARGTYPE_UNKNOWN, .lineno = lineno}; | ||
| 287 | if (t3 && t4) { | ||
| 288 | if (t3 == t4) { | ||
| 289 | kw.argtype = SP_ARGTYPE_EMPTY; | ||
| 290 | } else if (t4-t3 >= 2 && *t3 == '"') { | ||
| 291 | kw.arg = (char*)t3 + 1; | ||
| 292 | kw.arglen = t4 - t3 - 2; | ||
| 293 | kw.argtype = SP_ARGTYPE_STR; | ||
| 294 | } else { | ||
| 295 | zend_string *tmp = zend_hash_str_find_ptr(&vars, t3, t4-t3); | ||
| 296 | if (!tmp) { | ||
| 297 | cs_log_error("unknown variable on line %d", lineno); | ||
| 298 | goto out; | ||
| 299 | } | ||
| 300 | kw.arg = ZSTR_VAL(tmp); | ||
| 301 | kw.arglen = ZSTR_LEN(tmp); | ||
| 302 | kw.argtype = SP_ARGTYPE_STR; | ||
| 303 | } | ||
| 304 | } else { | ||
| 305 | kw.argtype = SP_ARGTYPE_NONE; | ||
| 306 | } | ||
| 307 | parsed_rule[kw_i++] = kw; | ||
| 308 | goto yyc_rule; | ||
| 309 | } | ||
| 310 | <rule> ";" { | ||
| 311 | end_of_rule: | ||
| 312 | if (!cond_res[0]) { goto yyc_init; } | ||
| 313 | parsed_rule[kw_i++] = (sp_parsed_keyword){0, 0, 0, 0, 0, 0}; | ||
| 314 | if (process_rule && process_rule(parsed_rule) != SUCCESS) { | ||
| 315 | goto out; | ||
| 316 | } | ||
| 317 | goto yyc_init; | ||
| 318 | } | ||
| 319 | <rule> * { goto end_of_rule; } | ||
| 320 | |||
| 321 | */ | ||
| 322 | out: | ||
| 323 | zend_hash_destroy(&vars); | ||
| 324 | return ret; | ||
| 325 | } \ No newline at end of file | ||
diff --git a/src/sp_config_utils.c b/src/sp_config_utils.c index 18cdf03..e93ef31 100644 --- a/src/sp_config_utils.c +++ b/src/sp_config_utils.c | |||
| @@ -1,110 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | int parse_keywords(sp_config_functions *funcs, char *line) { | ||
| 4 | int value_len = 0; | ||
| 5 | const char *original_line = line; | ||
| 6 | for (size_t i = 0; funcs[i].func; i++) { | ||
| 7 | if (!strncmp(funcs[i].token, line, strlen(funcs[i].token))) { | ||
| 8 | line += strlen(funcs[i].token); | ||
| 9 | value_len = funcs[i].func(line, funcs[i].token, funcs[i].retval) + 1; | ||
| 10 | if (value_len == 0) { // bad parameter | ||
| 11 | return -1; | ||
| 12 | } | ||
| 13 | line += value_len; | ||
| 14 | i = -1; // we start the loop again | ||
| 15 | } | ||
| 16 | } | ||
| 17 | while (*line == ';' || *line == '\t' || *line == ' ') { | ||
| 18 | line++; | ||
| 19 | } | ||
| 20 | |||
| 21 | if (*line == '#') { | ||
| 22 | return 0; | ||
| 23 | } | ||
| 24 | |||
| 25 | if (*line) { | ||
| 26 | sp_log_err("config", "Trailing chars '%s' at the end of '%s' on line %zu", | ||
| 27 | line, original_line, sp_line_no); | ||
| 28 | return -1; | ||
| 29 | } | ||
| 30 | return 0; | ||
| 31 | } | ||
| 32 | |||
| 33 | zend_string *get_param(size_t *consumed, char *restrict line, sp_type type, | ||
| 34 | const char *restrict keyword) { | ||
| 35 | enum { IN_ESCAPE, NONE } state = NONE; | ||
| 36 | char *original_line = line; | ||
| 37 | size_t j = 0; | ||
| 38 | |||
| 39 | zend_string *ret = NULL; | ||
| 40 | if (NULL == line || '\0' == *line) { | ||
| 41 | goto err; | ||
| 42 | } | ||
| 43 | |||
| 44 | ret = zend_string_alloc(strlen(line) + 1, 1); | ||
| 45 | |||
| 46 | /* The first char of a string is always '"', since they MUST be quoted. */ | ||
| 47 | if ('"' == *line) { | ||
| 48 | line++; | ||
| 49 | } else { | ||
| 50 | goto err; | ||
| 51 | } | ||
| 52 | |||
| 53 | for (size_t i = 0; line[i] && j < strlen(original_line) - 2; i++) { | ||
| 54 | switch (line[i]) { | ||
| 55 | case '"': | ||
| 56 | /* A double quote at this point is either: | ||
| 57 | - at the very end of the string. | ||
| 58 | - escaped | ||
| 59 | */ | ||
| 60 | if ((state == NONE) && (line[i + 1] == SP_TOKEN_END_PARAM)) { | ||
| 61 | /* The `+2` if for | ||
| 62 | 1. the terminal double-quote | ||
| 63 | 2. the SP_TOKEN_END_PARAM | ||
| 64 | */ | ||
| 65 | *consumed = i + 2; | ||
| 66 | // Make sure that the string we return is the right size, | ||
| 67 | // as it can be smaller than strlen(line) | ||
| 68 | ret = zend_string_truncate(ret, j, 1); | ||
| 69 | // truncate does not add a \0 | ||
| 70 | ZSTR_VAL(ret)[ZSTR_LEN(ret)] = 0; | ||
| 71 | return ret; | ||
| 72 | } else if (state == IN_ESCAPE) { | ||
| 73 | break; // we're on an escped double quote | ||
| 74 | } else { | ||
| 75 | goto err; | ||
| 76 | } | ||
| 77 | case '\\': | ||
| 78 | if (state == NONE) { | ||
| 79 | state = IN_ESCAPE; | ||
| 80 | continue; | ||
| 81 | } | ||
| 82 | default: | ||
| 83 | break; | ||
| 84 | } | ||
| 85 | if (state == IN_ESCAPE) { | ||
| 86 | state = NONE; | ||
| 87 | } | ||
| 88 | ZSTR_VAL(ret)[j++] = line[i]; | ||
| 89 | } | ||
| 90 | err: | ||
| 91 | if (0 == j) { | ||
| 92 | sp_log_err("error", "A valid string as parameter is expected on line %zu", | ||
| 93 | sp_line_no); | ||
| 94 | } else { | ||
| 95 | sp_log_err("error", | ||
| 96 | "There is an issue with the parsing of '%s': it doesn't look " | ||
| 97 | "like a valid string on line %zu", | ||
| 98 | original_line ? original_line : "NULL", sp_line_no); | ||
| 99 | } | ||
| 100 | line = NULL; | ||
| 101 | if (ret) { | ||
| 102 | zend_string_release(ret); | ||
| 103 | } | ||
| 104 | return NULL; | ||
| 105 | } | ||
| 106 | 3 | ||
| 107 | zend_always_inline sp_list_node *parse_functions_list(char *value) { | 4 | sp_list_node *parse_functions_list(char *value) { |
| 108 | static const char *sep = ">"; | 5 | static const char *sep = ">"; |
| 109 | 6 | ||
| 110 | if (NULL == strchr(value, sep[0])) { | 7 | if (NULL == strchr(value, sep[0])) { |
diff --git a/src/sp_config_utils.h b/src/sp_config_utils.h index a63cadc..64817a0 100644 --- a/src/sp_config_utils.h +++ b/src/sp_config_utils.h | |||
| @@ -1,9 +1,6 @@ | |||
| 1 | #ifndef SP_CONFIG_UTILS | 1 | #ifndef SP_CONFIG_UTILS |
| 2 | #define SP_CONFIG_UTILS | 2 | #define SP_CONFIG_UTILS |
| 3 | 3 | ||
| 4 | int parse_keywords(sp_config_functions *, char *); | ||
| 5 | zend_string *get_param(size_t *, char *restrict, sp_type, const char *restrict); | ||
| 6 | int array_to_list(char **, sp_list_node **); | ||
| 7 | sp_list_node *parse_functions_list(char *value); | 4 | sp_list_node *parse_functions_list(char *value); |
| 8 | 5 | ||
| 9 | #endif /* SP_CONFIG_UTILS */ | 6 | #endif /* SP_CONFIG_UTILS */ |
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c index 7bcedd2..b2cff66 100644 --- a/src/sp_cookie_encryption.c +++ b/src/sp_cookie_encryption.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | static inline const sp_cookie *sp_lookup_cookie_config(const zend_string *key) { | 3 | static inline const sp_cookie *sp_lookup_cookie_config(const zend_string *key) { |
| 4 | const sp_list_node *it = SNUFFLEUPAGUS_G(config).config_cookie->cookies; | 4 | const sp_list_node *it = SPCFG(cookie).cookies; |
| 5 | 5 | ||
| 6 | while (it) { | 6 | while (it) { |
| 7 | const sp_cookie *config = it->data; | 7 | const sp_cookie *config = it->data; |
| @@ -133,11 +133,11 @@ PHP_FUNCTION(sp_setcookie) { | |||
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | /* If the request was issued over HTTPS, the cookie should be "secure" */ | 135 | /* If the request was issued over HTTPS, the cookie should be "secure" */ |
| 136 | if (SNUFFLEUPAGUS_G(config).config_auto_cookie_secure) { | 136 | if (SPCFG(auto_cookie_secure).enable) { |
| 137 | const zval server_vars = PG(http_globals)[TRACK_VARS_SERVER]; | 137 | const zval server_vars = PG(http_globals)[TRACK_VARS_SERVER]; |
| 138 | if (Z_TYPE(server_vars) == IS_ARRAY) { | 138 | if (Z_TYPE(server_vars) == IS_ARRAY) { |
| 139 | const zval *is_https = | 139 | const zval *is_https = |
| 140 | zend_hash_str_find(Z_ARRVAL(server_vars), "HTTPS", strlen("HTTPS")); | 140 | zend_hash_str_find(Z_ARRVAL(server_vars), ZEND_STRL("HTTPS")); |
| 141 | if (NULL != is_https) { | 141 | if (NULL != is_https) { |
| 142 | secure = 1; | 142 | secure = 1; |
| 143 | } | 143 | } |
diff --git a/src/sp_crypt.c b/src/sp_crypt.c index c57ac0b..c1d9403 100644 --- a/src/sp_crypt.c +++ b/src/sp_crypt.c | |||
| @@ -3,13 +3,10 @@ | |||
| 3 | void generate_key(unsigned char *key) { | 3 | void generate_key(unsigned char *key) { |
| 4 | PHP_SHA256_CTX ctx; | 4 | PHP_SHA256_CTX ctx; |
| 5 | const char *user_agent = getenv("HTTP_USER_AGENT"); | 5 | const char *user_agent = getenv("HTTP_USER_AGENT"); |
| 6 | const zend_string *env_var_zend = | 6 | const zend_string *env_var_zend = SPCFG(cookies_env_var); |
| 7 | SNUFFLEUPAGUS_G(config).config_snuffleupagus->cookies_env_var; | 7 | const zend_string *encryption_key_zend = SPCFG(encryption_key); |
| 8 | const zend_string *encryption_key_zend = | ||
| 9 | SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key; | ||
| 10 | const char *env_var = (env_var_zend ? getenv(ZSTR_VAL(env_var_zend)) : NULL); | 8 | const char *env_var = (env_var_zend ? getenv(ZSTR_VAL(env_var_zend)) : NULL); |
| 11 | const char *encryption_key = | 9 | const char *encryption_key = (encryption_key_zend ? ZSTR_VAL(encryption_key_zend) : NULL); |
| 12 | (encryption_key_zend ? ZSTR_VAL(encryption_key_zend) : NULL); | ||
| 13 | 10 | ||
| 14 | assert(32 == crypto_secretbox_KEYBYTES); // 32 is the size of a SHA256. | 11 | assert(32 == crypto_secretbox_KEYBYTES); // 32 is the size of a SHA256. |
| 15 | assert(encryption_key); // Encryption key can't be NULL | 12 | assert(encryption_key); // Encryption key can't be NULL |
| @@ -40,27 +37,25 @@ void generate_key(unsigned char *key) { | |||
| 40 | // This function return 0 upon success , non-zero otherwise | 37 | // This function return 0 upon success , non-zero otherwise |
| 41 | int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | 38 | int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { |
| 42 | unsigned char key[crypto_secretbox_KEYBYTES] = {0}; | 39 | unsigned char key[crypto_secretbox_KEYBYTES] = {0}; |
| 43 | unsigned char *decrypted; | 40 | unsigned char *decrypted = NULL, *backup = NULL; |
| 44 | zend_string *debase64; | ||
| 45 | int ret = 0; | 41 | int ret = 0; |
| 46 | 42 | ||
| 47 | debase64 = php_base64_decode((unsigned char *)(Z_STRVAL_P(pDest)), | 43 | zend_string *debase64 = php_base64_decode((unsigned char *)(Z_STRVAL_P(pDest)), Z_STRLEN_P(pDest)); |
| 48 | Z_STRLEN_P(pDest)); | ||
| 49 | 44 | ||
| 50 | if (ZSTR_LEN(debase64) < crypto_secretbox_NONCEBYTES) { | 45 | if (ZSTR_LEN(debase64) < crypto_secretbox_NONCEBYTES) { |
| 51 | if (true == simulation) { | 46 | if (true == simulation) { |
| 52 | sp_log_simulation( | 47 | sp_log_simulation( |
| 53 | "cookie_encryption", | 48 | "cookie_encryption", |
| 54 | "Buffer underflow tentative detected in cookie encryption handling " | 49 | "Buffer underflow tentative detected in cookie encryption handling " |
| 55 | "for %s. Using the cookie 'as it' instead of decrypting it", | 50 | "for %s. Using the cookie 'as is' instead of decrypting it", |
| 56 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 51 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 57 | return ZEND_HASH_APPLY_KEEP; | 52 | ret = ZEND_HASH_APPLY_KEEP; goto out; |
| 58 | } else { | 53 | } else { |
| 59 | // LCOV_EXCL_START | 54 | // LCOV_EXCL_START |
| 60 | sp_log_drop( | 55 | sp_log_drop( |
| 61 | "cookie_encryption", | 56 | "cookie_encryption", |
| 62 | "Buffer underflow tentative detected in cookie encryption handling"); | 57 | "Buffer underflow (tentative) detected in cookie encryption handling"); |
| 63 | return ZEND_HASH_APPLY_REMOVE; | 58 | ret = ZEND_HASH_APPLY_REMOVE; goto out; |
| 64 | // LCOV_EXCL_STOP | 59 | // LCOV_EXCL_STOP |
| 65 | } | 60 | } |
| 66 | } | 61 | } |
| @@ -71,15 +66,15 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | |||
| 71 | if (true == simulation) { | 66 | if (true == simulation) { |
| 72 | sp_log_simulation( | 67 | sp_log_simulation( |
| 73 | "cookie_encryption", | 68 | "cookie_encryption", |
| 74 | "Integer overflow tentative detected in cookie encryption handling " | 69 | "Integer overflow (tentative) detected in cookie encryption handling " |
| 75 | "for %s. Using the cookie 'as it' instead of decrypting it.", | 70 | "for %s. Using the cookie 'as it' instead of decrypting it.", |
| 76 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 71 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 77 | return ZEND_HASH_APPLY_KEEP; | 72 | ret = ZEND_HASH_APPLY_KEEP; goto out; |
| 78 | } else { | 73 | } else { |
| 79 | sp_log_drop( | 74 | sp_log_drop( |
| 80 | "cookie_encryption", | 75 | "cookie_encryption", |
| 81 | "Integer overflow tentative detected in cookie encryption handling."); | 76 | "Integer overflow (tentative) detected in cookie encryption handling."); |
| 82 | return ZEND_HASH_APPLY_REMOVE; | 77 | ret = ZEND_HASH_APPLY_REMOVE; goto out; |
| 83 | } | 78 | } |
| 84 | } | 79 | } |
| 85 | // LCOV_EXCL_STOP | 80 | // LCOV_EXCL_STOP |
| @@ -87,7 +82,7 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | |||
| 87 | generate_key(key); | 82 | generate_key(key); |
| 88 | 83 | ||
| 89 | decrypted = ecalloc(ZSTR_LEN(debase64) + crypto_secretbox_ZEROBYTES, 1); | 84 | decrypted = ecalloc(ZSTR_LEN(debase64) + crypto_secretbox_ZEROBYTES, 1); |
| 90 | char *backup = ecalloc(ZSTR_LEN(debase64), 1); | 85 | backup = ecalloc(ZSTR_LEN(debase64), 1); |
| 91 | memcpy(backup, ZSTR_VAL(debase64), ZSTR_LEN(debase64)); | 86 | memcpy(backup, ZSTR_VAL(debase64), ZSTR_LEN(debase64)); |
| 92 | 87 | ||
| 93 | ret = crypto_secretbox_open( | 88 | ret = crypto_secretbox_open( |
| @@ -101,28 +96,31 @@ int decrypt_zval(zval *pDest, bool simulation, zend_hash_key *hash_key) { | |||
| 101 | sp_log_simulation( | 96 | sp_log_simulation( |
| 102 | "cookie_encryption", | 97 | "cookie_encryption", |
| 103 | "Something went wrong with the decryption of %s. Using the cookie " | 98 | "Something went wrong with the decryption of %s. Using the cookie " |
| 104 | "'as it' instead of decrypting it", | 99 | "'as is' instead of decrypting it", |
| 105 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 100 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 106 | memcpy(ZSTR_VAL(debase64), backup, ZSTR_LEN(debase64)); | 101 | memcpy(ZSTR_VAL(debase64), backup, ZSTR_LEN(debase64)); |
| 107 | efree(backup); | 102 | ret = ZEND_HASH_APPLY_KEEP; goto out; |
| 108 | return ZEND_HASH_APPLY_KEEP; | ||
| 109 | } else { | 103 | } else { |
| 110 | sp_log_warn("cookie_encryption", | 104 | sp_log_warn("cookie_encryption", |
| 111 | "Something went wrong with the decryption of %s", | 105 | "Something went wrong with the decryption of %s", |
| 112 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); | 106 | hash_key ? ZSTR_VAL(hash_key->key) : "the session"); |
| 113 | efree(backup); | 107 | ret = ZEND_HASH_APPLY_REMOVE; goto out; |
| 114 | return ZEND_HASH_APPLY_REMOVE; | ||
| 115 | } | 108 | } |
| 116 | } | 109 | } |
| 117 | efree(backup); | ||
| 118 | 110 | ||
| 119 | ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES), | 111 | ZVAL_STRINGL(pDest, (char *)(decrypted + crypto_secretbox_ZEROBYTES), |
| 120 | ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES - 1 - | 112 | ZSTR_LEN(debase64) - crypto_secretbox_NONCEBYTES - 1 - |
| 121 | crypto_secretbox_ZEROBYTES); | 113 | crypto_secretbox_ZEROBYTES); |
| 122 | 114 | ||
| 123 | efree(decrypted); | 115 | ret = ZEND_HASH_APPLY_KEEP; |
| 124 | 116 | ||
| 125 | return ZEND_HASH_APPLY_KEEP; | 117 | out: |
| 118 | |||
| 119 | if (debase64) { zend_string_efree(debase64); } | ||
| 120 | if (decrypted) { efree(decrypted); } | ||
| 121 | if (backup) { efree(backup); } | ||
| 122 | |||
| 123 | return ret; | ||
| 126 | } | 124 | } |
| 127 | 125 | ||
| 128 | /* | 126 | /* |
| @@ -156,10 +154,19 @@ zend_string *encrypt_zval(zend_string *data) { | |||
| 156 | 154 | ||
| 157 | memcpy(encrypted_data, nonce, crypto_secretbox_NONCEBYTES); | 155 | memcpy(encrypted_data, nonce, crypto_secretbox_NONCEBYTES); |
| 158 | 156 | ||
| 159 | crypto_secretbox(encrypted_data + crypto_secretbox_NONCEBYTES, | 157 | int err = crypto_secretbox(encrypted_data + crypto_secretbox_NONCEBYTES, |
| 160 | data_to_encrypt, encrypted_msg_len, nonce, key); | 158 | data_to_encrypt, encrypted_msg_len, nonce, key); |
| 161 | 159 | ||
| 162 | zend_string *z = php_base64_encode(encrypted_data, emsg_and_nonce_len); | 160 | zend_string *z = NULL; |
| 161 | if (err) { | ||
| 162 | sp_log_err("cookie_encryption", "something went wrong during encryption"); | ||
| 163 | z = zend_string_init("<sp_encryption_error>", 21, 0); | ||
| 164 | } else { | ||
| 165 | z = php_base64_encode(encrypted_data, emsg_and_nonce_len); | ||
| 166 | } | ||
| 167 | |||
| 168 | efree(data_to_encrypt); | ||
| 169 | efree(encrypted_data); | ||
| 163 | 170 | ||
| 164 | return z; | 171 | return z; |
| 165 | } | 172 | } |
diff --git a/src/sp_disable_xxe.c b/src/sp_disable_xxe.c index f9712b5..44e60ab 100644 --- a/src/sp_disable_xxe.c +++ b/src/sp_disable_xxe.c | |||
| @@ -1,24 +1,25 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | PHP_FUNCTION(sp_libxml_disable_entity_loader) { | 3 | PHP_FUNCTION(sp_libxml_disable_entity_loader) { |
| 4 | sp_log_warn("xxe", | 4 | sp_log_warn("xxe", "A call to libxml_disable_entity_loader was tried and nopped"); |
| 5 | "A call to libxml_disable_entity_loader was tried and nopped"); | ||
| 6 | RETURN_TRUE; | 5 | RETURN_TRUE; |
| 7 | } | 6 | } |
| 8 | 7 | ||
| 9 | PHP_FUNCTION(sp_libxml_set_external_entity_loader) { | 8 | PHP_FUNCTION(sp_libxml_set_external_entity_loader) { |
| 10 | sp_log_warn( | 9 | sp_log_warn("xxe", "A call to libxml_set_external_entity_loader was tried and nopped"); |
| 11 | "xxe", | ||
| 12 | "A call to libxml_set_external_entity_loader was tried and nopped"); | ||
| 13 | RETURN_TRUE; | 10 | RETURN_TRUE; |
| 14 | } | 11 | } |
| 15 | 12 | ||
| 16 | int hook_libxml_disable_entity_loader() { | 13 | int hook_libxml_disable_entity_loader() { |
| 17 | TSRMLS_FETCH(); | 14 | TSRMLS_FETCH(); |
| 18 | 15 | ||
| 16 | if (!zend_hash_str_find_ptr(&module_registry, ZEND_STRL("xml"))) { | ||
| 17 | sp_log_warn("xxe", "Cannot enable XXE protection. XML support is disabled in PHP."); | ||
| 18 | } | ||
| 19 | |||
| 19 | zval func_name; | 20 | zval func_name; |
| 20 | zval retval; | 21 | zval retval; |
| 21 | zval params[1]; | 22 | zval params[1] = {0}; |
| 22 | 23 | ||
| 23 | #if PHP_VERSION_ID < 80000 | 24 | #if PHP_VERSION_ID < 80000 |
| 24 | // This function is deprecated in PHP8, but better safe than sorry for php7. | 25 | // This function is deprecated in PHP8, but better safe than sorry for php7. |
| @@ -32,10 +33,8 @@ int hook_libxml_disable_entity_loader() { | |||
| 32 | ZVAL_NULL(¶ms[0]); | 33 | ZVAL_NULL(¶ms[0]); |
| 33 | call_user_function(CG(function_table), NULL, &func_name, &retval, 1, params); | 34 | call_user_function(CG(function_table), NULL, &func_name, &retval, 1, params); |
| 34 | 35 | ||
| 35 | HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook, | 36 | HOOK_FUNCTION("libxml_disable_entity_loader", sp_internal_functions_hook, PHP_FN(sp_libxml_disable_entity_loader)); |
| 36 | PHP_FN(sp_libxml_disable_entity_loader)); | 37 | HOOK_FUNCTION("libxml_set_external_entity_loader", sp_internal_functions_hook, PHP_FN(sp_libxml_set_external_entity_loader)); |
| 37 | HOOK_FUNCTION("libxml_set_external_entity_loader", sp_internal_functions_hook, | ||
| 38 | PHP_FN(sp_libxml_set_external_entity_loader)); | ||
| 39 | 38 | ||
| 40 | return SUCCESS; | 39 | return SUCCESS; |
| 41 | } | 40 | } |
diff --git a/src/sp_disabled_functions.c b/src/sp_disabled_functions.c index c47b5cb..95e19ad 100644 --- a/src/sp_disabled_functions.c +++ b/src/sp_disabled_functions.c | |||
| @@ -13,26 +13,26 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 13 | zend_execute_data* execute_data); | 13 | zend_execute_data* execute_data); |
| 14 | 14 | ||
| 15 | char* get_complete_function_path(zend_execute_data const* const execute_data) { | 15 | char* get_complete_function_path(zend_execute_data const* const execute_data) { |
| 16 | if (zend_is_executing() && !EG(current_execute_data)->func) { | 16 | if (!execute_data) { |
| 17 | return NULL; // LCOV_EXCL_LINE | 17 | return NULL; // LCOV_EXCL_LINE |
| 18 | } | 18 | } |
| 19 | if (!(execute_data->func->common.function_name)) { | 19 | zend_function *func = execute_data->func; |
| 20 | if (!(func->common.function_name)) { | ||
| 20 | return NULL; | 21 | return NULL; |
| 21 | } | 22 | } |
| 22 | 23 | ||
| 23 | char const* class_name; | 24 | char const* const function_name = ZSTR_VAL(func->common.function_name); |
| 24 | char const* const function_name = | ||
| 25 | ZSTR_VAL(execute_data->func->common.function_name); | ||
| 26 | char* complete_path_function = NULL; | 25 | char* complete_path_function = NULL; |
| 27 | 26 | ||
| 28 | class_name = get_active_class_name(NULL); | 27 | if ((func->type == ZEND_USER_FUNCTION || func->type == ZEND_INTERNAL_FUNCTION) && func->common.scope) { |
| 29 | if (*class_name) { | 28 | char const* class_name = ZSTR_VAL(func->common.scope->name); |
| 30 | const size_t len = strlen(class_name) + 2 + strlen(function_name) + 1; | 29 | const size_t len = strlen(class_name) + 2 + strlen(function_name) + 1; |
| 31 | complete_path_function = emalloc(len); | 30 | complete_path_function = emalloc(len); |
| 32 | snprintf(complete_path_function, len, "%s::%s", class_name, function_name); | 31 | snprintf(complete_path_function, len, "%s::%s", class_name, function_name); |
| 33 | } else { | 32 | } else { |
| 34 | complete_path_function = estrdup(function_name); | 33 | complete_path_function = estrdup(function_name); |
| 35 | } | 34 | } |
| 35 | |||
| 36 | return complete_path_function; | 36 | return complete_path_function; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| @@ -67,28 +67,22 @@ static bool is_functions_list_matching(zend_execute_data* execute_data, | |||
| 67 | return false; | 67 | return false; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | static bool is_local_var_matching( | 70 | static bool is_local_var_matching(zend_execute_data* execute_data, const sp_disabled_function* const config_node) { |
| 71 | zend_execute_data* execute_data, | ||
| 72 | const sp_disabled_function* const config_node) { | ||
| 73 | zval* var_value = {0}; | 71 | zval* var_value = {0}; |
| 74 | 72 | ||
| 75 | var_value = sp_get_var_value(execute_data, config_node->var, false); | 73 | var_value = sp_get_var_value(execute_data, config_node->var, false); |
| 76 | if (var_value) { | 74 | if (var_value) { |
| 77 | if (Z_TYPE_P(var_value) == IS_ARRAY) { | 75 | if (Z_TYPE_P(var_value) == IS_ARRAY) { |
| 78 | if (config_node->key || config_node->r_key) { | 76 | if (config_node->key || config_node->r_key) { |
| 79 | if (sp_match_array_key(var_value, config_node->key, | 77 | if (sp_match_array_key(var_value, config_node->key, config_node->r_key)) { |
| 80 | config_node->r_key)) { | ||
| 81 | return true; | 78 | return true; |
| 82 | } | 79 | } |
| 83 | } else if (sp_match_array_value(var_value, config_node->value, | 80 | } else if (sp_match_array_value(var_value, config_node->value, config_node->r_value)) { |
| 84 | config_node->r_value)) { | ||
| 85 | return true; | 81 | return true; |
| 86 | } | 82 | } |
| 87 | } else { | 83 | } else { |
| 88 | zend_string const* const var_value_str = | 84 | zend_string const* const var_value_str = sp_zval_to_zend_string(var_value); |
| 89 | sp_zval_to_zend_string(var_value); | 85 | bool match = sp_match_value(var_value_str, config_node->value, config_node->r_value); |
| 90 | bool match = sp_match_value(var_value_str, config_node->value, | ||
| 91 | config_node->r_value); | ||
| 92 | 86 | ||
| 93 | if (true == match) { | 87 | if (true == match) { |
| 94 | return true; | 88 | return true; |
| @@ -98,107 +92,105 @@ static bool is_local_var_matching( | |||
| 98 | return false; | 92 | return false; |
| 99 | } | 93 | } |
| 100 | 94 | ||
| 95 | static inline const char* get_fn_arg_name(zend_function *fn, uint32_t i) { | ||
| 96 | if (fn->type == ZEND_USER_FUNCTION || (fn->common.fn_flags & ZEND_ACC_USER_ARG_INFO)) { | ||
| 97 | return ZSTR_VAL(fn->op_array.arg_info[i].name); | ||
| 98 | } else { | ||
| 99 | return fn->internal_function.arg_info[i].name; | ||
| 100 | } | ||
| 101 | } | ||
| 102 | |||
| 101 | static bool is_param_matching(zend_execute_data* execute_data, | 103 | static bool is_param_matching(zend_execute_data* execute_data, |
| 102 | sp_disabled_function const* const config_node, | 104 | sp_disabled_function const* const config_node, |
| 103 | const zend_string* builtin_param, | 105 | const zend_string* builtin_param, |
| 104 | const char* builtin_param_name, | 106 | const char* builtin_param_name, |
| 105 | const char** arg_name, | 107 | const char** arg_name, |
| 106 | const zend_string** arg_value_str) { | 108 | const zend_string** arg_value_str) { |
| 107 | int nb_param = ZEND_CALL_NUM_ARGS(execute_data); | 109 | // builtin functions |
| 108 | int i = 0; | ||
| 109 | zval* arg_value; | ||
| 110 | |||
| 111 | if (config_node->pos != -1) { | ||
| 112 | if (config_node->pos > nb_param - 1) { | ||
| 113 | char* complete_function_path = get_complete_function_path(execute_data); | ||
| 114 | sp_log_warn("config", | ||
| 115 | "It seems that you wrote a rule filtering on the " | ||
| 116 | "%d%s argument of the function '%s', but it takes only %d " | ||
| 117 | "arguments. " | ||
| 118 | "Matching on _all_ arguments instead.", | ||
| 119 | config_node->pos, GET_SUFFIX(config_node->pos), | ||
| 120 | complete_function_path, nb_param); | ||
| 121 | efree(complete_function_path); | ||
| 122 | } else { | ||
| 123 | i = config_node->pos; | ||
| 124 | nb_param = (config_node->pos) + 1; | ||
| 125 | } | ||
| 126 | } | ||
| 127 | |||
| 128 | if (builtin_param) { | 110 | if (builtin_param) { |
| 129 | /* We're matching on a language construct (here named "builtin"), | 111 | /* We're matching on a language construct (here named "builtin"), |
| 130 | * and they can only take a single argument, but PHP considers them | 112 | * and they can only take a single argument, but PHP considers them |
| 131 | * differently than functions arguments. */ | 113 | * differently than functions arguments. */ |
| 132 | *arg_name = builtin_param_name; | 114 | *arg_name = builtin_param_name; |
| 133 | *arg_value_str = builtin_param; | 115 | *arg_value_str = builtin_param; |
| 134 | return sp_match_value(builtin_param, config_node->value, | 116 | return sp_match_value(builtin_param, config_node->value, |
| 135 | config_node->r_value); | 117 | config_node->r_value); |
| 136 | } else if (config_node->r_param || config_node->pos != -1) { | 118 | } |
| 137 | // We're matching on a function (and not a language construct) | ||
| 138 | for (; i < nb_param; i++) { | ||
| 139 | if (ZEND_USER_CODE(execute_data->func->type)) { // yay consistency | ||
| 140 | *arg_name = ZSTR_VAL(execute_data->func->common.arg_info[i].name); | ||
| 141 | } else { | ||
| 142 | *arg_name = execute_data->func->internal_function.arg_info[i].name; | ||
| 143 | } | ||
| 144 | const bool pcre_matching = | ||
| 145 | config_node->r_param && | ||
| 146 | (true == sp_is_regexp_matching(config_node->r_param, *arg_name)); | ||
| 147 | 119 | ||
| 148 | /* This is the parameter name we're looking for. */ | 120 | // safeguards |
| 149 | if (true == pcre_matching || config_node->pos != -1) { | 121 | if (!execute_data || !execute_data->func) { |
| 150 | arg_value = ZEND_CALL_ARG(execute_data, i + 1); | 122 | sp_log_debug("no execute data -> silently ignore parameter matching"); |
| 123 | return false; | ||
| 124 | } | ||
| 151 | 125 | ||
| 152 | if (config_node->param_type) { // Are we matching on the `type`? | 126 | *arg_name = NULL; |
| 153 | if (config_node->param_type == Z_TYPE_P(arg_value)) { | 127 | int call_num_args = EX_NUM_ARGS(); |
| 154 | return true; | 128 | zend_function *fn = execute_data->func; |
| 155 | } | 129 | int fn_num_args = fn->common.num_args; |
| 156 | } else if (Z_TYPE_P(arg_value) == IS_ARRAY) { | 130 | |
| 157 | *arg_value_str = sp_zval_to_zend_string(arg_value); | 131 | if (!call_num_args) { |
| 158 | if (config_node->key || config_node->r_key) { | 132 | sp_log_debug("no call arguments -> return"); |
| 159 | if (sp_match_array_key(arg_value, config_node->key, | 133 | return false; // no arguments to check |
| 160 | config_node->r_key)) { | 134 | } |
| 161 | return true; | 135 | |
| 162 | } | 136 | if (config_node->pos > call_num_args - 1 || config_node->pos > fn_num_args) { |
| 163 | } else if (sp_match_array_value(arg_value, config_node->value, | 137 | // trying to match argument beyond last given argument OR beyond last declared argument. |
| 164 | config_node->r_value)) { | 138 | // this is perfectly normal for functions with |
| 165 | return true; | 139 | // (a) optional arguments |
| 166 | } | 140 | // (b) excess arguments |
| 167 | } else { | 141 | // (c) variadic arguments which are not supported |
| 168 | *arg_value_str = sp_zval_to_zend_string(arg_value); | 142 | return false; |
| 169 | if (sp_match_value(*arg_value_str, config_node->value, | 143 | } |
| 170 | config_node->r_value)) { | 144 | |
| 171 | return true; | 145 | zval* arg_value = NULL; |
| 172 | } | 146 | |
| 173 | } | 147 | if (config_node->pos > -1) { |
| 174 | } | 148 | if (config_node->pos < fn_num_args) { |
| 149 | *arg_name = get_fn_arg_name(fn, config_node->pos); | ||
| 175 | } | 150 | } |
| 151 | arg_value = ZEND_CALL_ARG(execute_data, config_node->pos + 1); | ||
| 176 | } else if (config_node->param) { | 152 | } else if (config_node->param) { |
| 177 | *arg_name = config_node->param->value; | 153 | *arg_name = config_node->param->value; |
| 178 | arg_value = sp_get_var_value(execute_data, config_node->param, true); | 154 | arg_value = sp_get_var_value(execute_data, config_node->param, true); |
| 155 | } else if (config_node->r_param) { | ||
| 156 | for (int i = 0; i < call_num_args; i++) { | ||
| 157 | *arg_name = get_fn_arg_name(fn, i); | ||
| 158 | if (true == sp_is_regexp_matching(config_node->r_param, *arg_name)) { | ||
| 159 | arg_value = ZEND_CALL_ARG(execute_data, i + 1); | ||
| 160 | } | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | if (!arg_value) { | ||
| 165 | sp_log_debug("no argument match -> return"); | ||
| 166 | return false; | ||
| 167 | } | ||
| 179 | 168 | ||
| 180 | if (arg_value) { | 169 | if (config_node->param_type) { |
| 181 | *arg_value_str = sp_zval_to_zend_string(arg_value); | 170 | if (config_node->param_type == Z_TYPE_P(arg_value)) { |
| 182 | if (config_node->param_type) { // Are we matching on the `type`? | 171 | if (!(config_node->key || config_node->r_key || config_node->value || config_node->r_value)) { // Are we matching on the `type` only? |
| 183 | if (config_node->param_type == Z_TYPE_P(arg_value)) { | 172 | sp_log_debug("arg type match only."); |
| 184 | return true; | ||
| 185 | } | ||
| 186 | } else if (Z_TYPE_P(arg_value) == IS_ARRAY) { | ||
| 187 | if (config_node->key || config_node->r_key) { | ||
| 188 | if (sp_match_array_key(arg_value, config_node->key, | ||
| 189 | config_node->r_key)) { | ||
| 190 | return true; | ||
| 191 | } | ||
| 192 | } else if (sp_match_array_value(arg_value, config_node->value, | ||
| 193 | config_node->r_value)) { | ||
| 194 | return true; | ||
| 195 | } | ||
| 196 | } else if (sp_match_value(*arg_value_str, config_node->value, | ||
| 197 | config_node->r_value)) { | ||
| 198 | return true; | 173 | return true; |
| 199 | } | 174 | } |
| 175 | } else { | ||
| 176 | sp_log_debug("arg type mismatch -> return"); | ||
| 177 | return false; | ||
| 200 | } | 178 | } |
| 201 | } | 179 | } |
| 180 | |||
| 181 | *arg_value_str = sp_zval_to_zend_string(arg_value); | ||
| 182 | if (Z_TYPE_P(arg_value) == IS_ARRAY) { | ||
| 183 | if (config_node->key || config_node->r_key) { | ||
| 184 | if (sp_match_array_key(arg_value, config_node->key, config_node->r_key)) { | ||
| 185 | return true; | ||
| 186 | } | ||
| 187 | } else if (sp_match_array_value(arg_value, config_node->value, config_node->r_value)) { | ||
| 188 | return true; | ||
| 189 | } | ||
| 190 | } else if (sp_match_value(*arg_value_str, config_node->value, config_node->r_value)) { | ||
| 191 | return true; | ||
| 192 | } | ||
| 193 | |||
| 202 | return false; | 194 | return false; |
| 203 | } | 195 | } |
| 204 | 196 | ||
| @@ -218,17 +210,15 @@ static zend_execute_data* is_file_matching( | |||
| 218 | return ex; // LCOV_EXCL_LINE | 210 | return ex; // LCOV_EXCL_LINE |
| 219 | } | 211 | } |
| 220 | ITERATE(ex); | 212 | ITERATE(ex); |
| 221 | if (zend_string_equals(ex->func->op_array.filename, | 213 | if (zend_string_equals(ex->func->op_array.filename, config_node->filename)) { |
| 222 | config_node->filename)) { | ||
| 223 | return ex; // LCOV_EXCL_LINE | 214 | return ex; // LCOV_EXCL_LINE |
| 224 | } | 215 | } |
| 225 | } else if (config_node->r_filename) { | 216 | } else if (config_node->r_filename) { |
| 226 | if (sp_is_regexp_matching_zend(config_node->r_filename, current_filename)) { | 217 | if (sp_is_regexp_matching_zstr(config_node->r_filename, current_filename)) { |
| 227 | return ex; | 218 | return ex; |
| 228 | } | 219 | } |
| 229 | ITERATE(ex); | 220 | ITERATE(ex); |
| 230 | if (sp_is_regexp_matching_zend(config_node->r_filename, | 221 | if (sp_is_regexp_matching_zstr(config_node->r_filename, ex->func->op_array.filename)) { |
| 231 | ex->func->op_array.filename)) { | ||
| 232 | return ex; | 222 | return ex; |
| 233 | } | 223 | } |
| 234 | } | 224 | } |
| @@ -267,7 +257,7 @@ void should_disable_ht(zend_execute_data* execute_data, | |||
| 267 | current_filename = zend_string_init(tmp, strlen(tmp), 0); | 257 | current_filename = zend_string_init(tmp, strlen(tmp), 0); |
| 268 | } | 258 | } |
| 269 | 259 | ||
| 270 | ht_entry = zend_hash_str_find_ptr(ht, function_name, strlen(function_name)); | 260 | ht_entry = zend_hash_str_find_ptr(ht, VAR_AND_LEN(function_name)); |
| 271 | 261 | ||
| 272 | if (ht_entry) { | 262 | if (ht_entry) { |
| 273 | should_disable(execute_data, function_name, builtin_param, | 263 | should_disable(execute_data, function_name, builtin_param, |
| @@ -289,26 +279,22 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 289 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; | 279 | char current_file_hash[SHA256_SIZE * 2 + 1] = {0}; |
| 290 | 280 | ||
| 291 | while (config) { | 281 | while (config) { |
| 292 | sp_disabled_function const* const config_node = | 282 | sp_disabled_function const* const config_node = (sp_disabled_function*)(config->data); |
| 293 | (sp_disabled_function*)(config->data); | ||
| 294 | const char* arg_name = NULL; | 283 | const char* arg_name = NULL; |
| 295 | const zend_string* arg_value_str = NULL; | 284 | const zend_string* arg_value_str = NULL; |
| 296 | 285 | ||
| 297 | /* The order matters, since when we have `config_node->functions_list`, | 286 | /* The order matters, since when we have `config_node->functions_list`, |
| 298 | we also do have `config_node->function` */ | 287 | we also do have `config_node->function` */ |
| 299 | if (config_node->functions_list) { | 288 | if (config_node->functions_list) { |
| 300 | if (false == is_functions_list_matching(execute_data, | 289 | if (false == is_functions_list_matching(execute_data, config_node->functions_list)) { |
| 301 | config_node->functions_list)) { | ||
| 302 | goto next; | 290 | goto next; |
| 303 | } | 291 | } |
| 304 | } else if (config_node->function) { | 292 | } else if (config_node->function) { |
| 305 | if (0 != | 293 | if (0 != strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { |
| 306 | strcmp(ZSTR_VAL(config_node->function), complete_function_path)) { | ||
| 307 | goto next; // LCOV_EXCL_LINE | 294 | goto next; // LCOV_EXCL_LINE |
| 308 | } | 295 | } |
| 309 | } else if (config_node->r_function) { | 296 | } else if (config_node->r_function) { |
| 310 | if (false == sp_is_regexp_matching(config_node->r_function, | 297 | if (false == sp_is_regexp_matching(config_node->r_function, complete_function_path)) { |
| 311 | complete_function_path)) { | ||
| 312 | goto next; | 298 | goto next; |
| 313 | } | 299 | } |
| 314 | } | 300 | } |
| @@ -320,8 +306,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 320 | } | 306 | } |
| 321 | 307 | ||
| 322 | if (config_node->filename || config_node->r_filename) { | 308 | if (config_node->filename || config_node->r_filename) { |
| 323 | zend_execute_data* ex = | 309 | zend_execute_data* ex = is_file_matching(execute_data, config_node, current_filename); |
| 324 | is_file_matching(execute_data, config_node, current_filename); | ||
| 325 | if (!ex) { | 310 | if (!ex) { |
| 326 | goto next; | 311 | goto next; |
| 327 | } | 312 | } |
| @@ -344,8 +329,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 344 | if ('\0' == current_file_hash[0]) { | 329 | if ('\0' == current_file_hash[0]) { |
| 345 | compute_hash(ZSTR_VAL(current_filename), current_file_hash); | 330 | compute_hash(ZSTR_VAL(current_filename), current_file_hash); |
| 346 | } | 331 | } |
| 347 | if (0 != strncmp(current_file_hash, ZSTR_VAL(config_node->hash), | 332 | if (0 != strncmp(current_file_hash, ZSTR_VAL(config_node->hash), SHA256_SIZE)) { |
| 348 | SHA256_SIZE)) { | ||
| 349 | goto next; | 333 | goto next; |
| 350 | } | 334 | } |
| 351 | } | 335 | } |
| @@ -366,9 +350,7 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 366 | "Snuffleupagus doesn't support variadic functions yet, sorry. " | 350 | "Snuffleupagus doesn't support variadic functions yet, sorry. " |
| 367 | "Check https://github.com/jvoisin/snuffleupagus/issues/164 for " | 351 | "Check https://github.com/jvoisin/snuffleupagus/issues/164 for " |
| 368 | "details."); | 352 | "details."); |
| 369 | } else if (false == is_param_matching( | 353 | } else if (false == is_param_matching(execute_data, config_node, builtin_param, builtin_param_name, &arg_name, &arg_value_str)) { |
| 370 | execute_data, config_node, builtin_param, builtin_param_name, | ||
| 371 | &arg_name, &arg_value_str)) { | ||
| 372 | goto next; | 354 | goto next; |
| 373 | } | 355 | } |
| 374 | } | 356 | } |
| @@ -379,11 +361,9 @@ static void should_disable(zend_execute_data* execute_data, | |||
| 379 | } | 361 | } |
| 380 | 362 | ||
| 381 | if (config_node->functions_list) { | 363 | if (config_node->functions_list) { |
| 382 | sp_log_disable(ZSTR_VAL(config_node->function), arg_name, arg_value_str, | 364 | sp_log_disable(ZSTR_VAL(config_node->function), arg_name, arg_value_str, config_node); |
| 383 | config_node); | ||
| 384 | } else { | 365 | } else { |
| 385 | sp_log_disable(complete_function_path, arg_name, arg_value_str, | 366 | sp_log_disable(complete_function_path, arg_name, arg_value_str, config_node); |
| 386 | config_node); | ||
| 387 | } | 367 | } |
| 388 | 368 | ||
| 389 | next: | 369 | next: |
| @@ -418,7 +398,6 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 418 | bool match_type = false, match_value = false; | 398 | bool match_type = false, match_value = false; |
| 419 | 399 | ||
| 420 | while (config) { | 400 | while (config) { |
| 421 | const zend_string* ret_value_str = NULL; | ||
| 422 | sp_disabled_function const* const config_node = | 401 | sp_disabled_function const* const config_node = |
| 423 | (sp_disabled_function*)(config->data); | 402 | (sp_disabled_function*)(config->data); |
| 424 | 403 | ||
| @@ -462,13 +441,18 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 462 | } | 441 | } |
| 463 | } | 442 | } |
| 464 | 443 | ||
| 465 | ret_value_str = sp_zval_to_zend_string(return_value); | 444 | const zend_string* ret_value_str = NULL; |
| 445 | sp_php_type ret_type = SP_PHP_TYPE_NULL; | ||
| 446 | |||
| 447 | if (return_value) { | ||
| 448 | ret_value_str = sp_zval_to_zend_string(return_value); | ||
| 449 | ret_type = Z_TYPE_P(return_value); | ||
| 450 | } | ||
| 466 | 451 | ||
| 467 | match_type = (config_node->ret_type) && | 452 | match_type = (config_node->ret_type) && |
| 468 | (config_node->ret_type == Z_TYPE_P(return_value)); | 453 | (config_node->ret_type == ret_type); |
| 469 | match_value = (config_node->ret || config_node->r_ret) && | 454 | match_value = return_value && (config_node->ret || config_node->r_ret) && |
| 470 | (true == sp_match_value(ret_value_str, config_node->ret, | 455 | (true == sp_match_value(ret_value_str, config_node->ret, config_node->r_ret)); |
| 471 | config_node->r_ret)); | ||
| 472 | 456 | ||
| 473 | if (true == match_type || true == match_value) { | 457 | if (true == match_type || true == match_value) { |
| 474 | if (true == config_node->allow) { | 458 | if (true == config_node->allow) { |
| @@ -483,40 +467,28 @@ static void should_drop_on_ret(const zval* return_value, | |||
| 483 | 467 | ||
| 484 | ZEND_FUNCTION(check_disabled_function) { | 468 | ZEND_FUNCTION(check_disabled_function) { |
| 485 | zif_handler orig_handler; | 469 | zif_handler orig_handler; |
| 486 | const char* current_function_name = get_active_function_name(TSRMLS_C); | 470 | const char* current_function_name = get_active_function_name(); |
| 487 | 471 | ||
| 488 | should_disable_ht( | 472 | should_disable_ht(execute_data, current_function_name, NULL, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions_hooked)); |
| 489 | execute_data, current_function_name, NULL, NULL, | ||
| 490 | SNUFFLEUPAGUS_G(config).config_disabled_functions_reg->disabled_functions, | ||
| 491 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); | ||
| 492 | 473 | ||
| 493 | orig_handler = zend_hash_str_find_ptr( | 474 | orig_handler = zend_hash_str_find_ptr(SPG(disabled_functions_hook), VAR_AND_LEN(current_function_name)); |
| 494 | SNUFFLEUPAGUS_G(disabled_functions_hook), current_function_name, | ||
| 495 | strlen(current_function_name)); | ||
| 496 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 475 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 497 | should_drop_on_ret_ht( | 476 | |
| 498 | return_value, current_function_name, | 477 | should_drop_on_ret_ht(return_value, current_function_name, SPCFG(disabled_functions_reg_ret).disabled_functions, SPCFG(disabled_functions_ret_hooked), execute_data); |
| 499 | SNUFFLEUPAGUS_G(config) | ||
| 500 | .config_disabled_functions_reg_ret->disabled_functions, | ||
| 501 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked, | ||
| 502 | execute_data); | ||
| 503 | } | 478 | } |
| 504 | 479 | ||
| 505 | static int hook_functions_regexp(const sp_list_node* config) { | 480 | static int hook_functions_regexp(const sp_list_node* config) { |
| 506 | while (config && config->data) { | 481 | while (config && config->data) { |
| 507 | const zend_string* function_name = | 482 | const zend_string* function_name = ((sp_disabled_function*)config->data)->function; |
| 508 | ((sp_disabled_function*)config->data)->function; | 483 | sp_regexp *function_name_sp_regexp = ((sp_disabled_function*)config->data)->r_function; |
| 509 | const sp_pcre* function_name_regexp = | 484 | const sp_pcre* function_name_regexp = function_name_sp_regexp ? function_name_sp_regexp->re : NULL; |
| 510 | ((sp_disabled_function*)config->data)->r_function; | ||
| 511 | 485 | ||
| 512 | assert(function_name || function_name_regexp); | 486 | assert(function_name || function_name_regexp); |
| 513 | 487 | ||
| 514 | if (function_name) { | 488 | if (function_name) { |
| 515 | HOOK_FUNCTION(ZSTR_VAL(function_name), disabled_functions_hook, | 489 | HOOK_FUNCTION(ZSTR_VAL(function_name), disabled_functions_hook, PHP_FN(check_disabled_function)); |
| 516 | PHP_FN(check_disabled_function)); | ||
| 517 | } else { | 490 | } else { |
| 518 | HOOK_FUNCTION_BY_REGEXP(function_name_regexp, disabled_functions_hook, | 491 | HOOK_FUNCTION_BY_REGEXP(function_name_regexp, disabled_functions_hook, PHP_FN(check_disabled_function)); |
| 519 | PHP_FN(check_disabled_function)); | ||
| 520 | } | 492 | } |
| 521 | 493 | ||
| 522 | config = config->next; | 494 | config = config->next; |
| @@ -529,10 +501,8 @@ static void hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { | |||
| 529 | zval* value; | 501 | zval* value; |
| 530 | 502 | ||
| 531 | ZEND_HASH_FOREACH_STR_KEY_VAL(to_hook_ht, key, value) { | 503 | ZEND_HASH_FOREACH_STR_KEY_VAL(to_hook_ht, key, value) { |
| 532 | bool hooked = HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook, | 504 | bool hooked = HOOK_FUNCTION(ZSTR_VAL(key), disabled_functions_hook, PHP_FN(check_disabled_function)); |
| 533 | PHP_FN(check_disabled_function)); | 505 | bool is_builtin = check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data); |
| 534 | bool is_builtin = | ||
| 535 | check_is_builtin_name(((sp_list_node*)Z_PTR_P(value))->data); | ||
| 536 | if (hooked || is_builtin) { | 506 | if (hooked || is_builtin) { |
| 537 | zend_symtable_add_new(hooked_ht, key, value); | 507 | zend_symtable_add_new(hooked_ht, key, value); |
| 538 | zend_hash_del(to_hook_ht, key); | 508 | zend_hash_del(to_hook_ht, key); |
| @@ -543,41 +513,29 @@ static void hook_functions(HashTable* to_hook_ht, HashTable* hooked_ht) { | |||
| 543 | 513 | ||
| 544 | ZEND_FUNCTION(eval_blacklist_callback) { | 514 | ZEND_FUNCTION(eval_blacklist_callback) { |
| 545 | zif_handler orig_handler; | 515 | zif_handler orig_handler; |
| 546 | const char* current_function_name = get_active_function_name(TSRMLS_C); | 516 | char* current_function_name = get_complete_function_path(EG(current_execute_data)); |
| 547 | zend_string* tmp = | ||
| 548 | zend_string_init(current_function_name, strlen(current_function_name), 0); | ||
| 549 | 517 | ||
| 550 | if (true == check_is_in_eval_whitelist(tmp)) { | 518 | if (!current_function_name || true == check_is_in_eval_whitelist(current_function_name)) { |
| 551 | zend_string_release(tmp); | ||
| 552 | goto whitelisted; | 519 | goto whitelisted; |
| 553 | } | 520 | } |
| 554 | zend_string_release(tmp); | ||
| 555 | 521 | ||
| 556 | if (SNUFFLEUPAGUS_G(in_eval) > 0) { | 522 | if (SPG(in_eval) > 0) { |
| 557 | zend_string* filename = get_eval_filename(zend_get_executed_filename()); | 523 | const sp_config_eval* config_eval = &(SPCFG(eval)); |
| 558 | const int line_number = zend_get_executed_lineno(TSRMLS_C); | ||
| 559 | const sp_config_eval* config_eval = SNUFFLEUPAGUS_G(config).config_eval; | ||
| 560 | 524 | ||
| 561 | if (config_eval->dump) { | 525 | if (config_eval->dump) { |
| 562 | sp_log_request(config_eval->dump, config_eval->textual_representation, | 526 | sp_log_request(config_eval->dump, config_eval->textual_representation); |
| 563 | SP_TOKEN_EVAL_BLACKLIST); | ||
| 564 | } | 527 | } |
| 565 | if (config_eval->simulation) { | 528 | if (config_eval->simulation) { |
| 566 | sp_log_simulation("eval", | 529 | sp_log_simulation("eval", "A call to '%s' was tried in eval. logging it.", current_function_name); |
| 567 | "A call to %s was tried in eval, in %s:%d, logging it.", | ||
| 568 | current_function_name, ZSTR_VAL(filename), line_number); | ||
| 569 | } else { | 530 | } else { |
| 570 | sp_log_drop("eval", | 531 | sp_log_drop("eval", "A call to '%s' was tried in eval. dropping it.", current_function_name); |
| 571 | "A call to %s was tried in eval, in %s:%d, dropping it.", | ||
| 572 | current_function_name, ZSTR_VAL(filename), line_number); | ||
| 573 | } | 532 | } |
| 574 | efree(filename); | ||
| 575 | } | 533 | } |
| 576 | 534 | ||
| 577 | whitelisted: | 535 | whitelisted: |
| 578 | orig_handler = zend_hash_str_find_ptr( | 536 | |
| 579 | SNUFFLEUPAGUS_G(sp_eval_blacklist_functions_hook), current_function_name, | 537 | orig_handler = zend_hash_str_find_ptr(SPG(sp_eval_blacklist_functions_hook), current_function_name, strlen(current_function_name)); |
| 580 | strlen(current_function_name)); | 538 | efree(current_function_name); |
| 581 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 539 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 582 | } | 540 | } |
| 583 | 541 | ||
| @@ -586,26 +544,19 @@ int hook_disabled_functions(void) { | |||
| 586 | 544 | ||
| 587 | int ret = SUCCESS; | 545 | int ret = SUCCESS; |
| 588 | 546 | ||
| 589 | hook_functions(SNUFFLEUPAGUS_G(config).config_disabled_functions, | 547 | hook_functions(SPCFG(disabled_functions), SPCFG(disabled_functions_hooked)); |
| 590 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); | 548 | hook_functions(SPCFG(disabled_functions_ret), SPCFG(disabled_functions_ret_hooked)); |
| 591 | |||
| 592 | hook_functions(SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, | ||
| 593 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret_hooked); | ||
| 594 | 549 | ||
| 595 | ret |= hook_functions_regexp( | 550 | ret |= hook_functions_regexp(SPCFG(disabled_functions_reg).disabled_functions); |
| 596 | SNUFFLEUPAGUS_G(config) | ||
| 597 | .config_disabled_functions_reg->disabled_functions); | ||
| 598 | 551 | ||
| 599 | ret |= hook_functions_regexp( | 552 | ret |= hook_functions_regexp(SPCFG(disabled_functions_reg_ret).disabled_functions); |
| 600 | SNUFFLEUPAGUS_G(config) | ||
| 601 | .config_disabled_functions_reg_ret->disabled_functions); | ||
| 602 | 553 | ||
| 603 | if (NULL != SNUFFLEUPAGUS_G(config).config_eval->blacklist) { | 554 | if (NULL != SPCFG(eval).blacklist) { |
| 604 | sp_list_node* it = SNUFFLEUPAGUS_G(config).config_eval->blacklist; | 555 | sp_list_node* it = SPCFG(eval).blacklist; |
| 605 | 556 | ||
| 606 | while (it) { | 557 | while (it) { |
| 607 | hook_function(ZSTR_VAL((zend_string*)it->data), | 558 | hook_function(ZSTR_VAL((zend_string*)it->data), |
| 608 | SNUFFLEUPAGUS_G(sp_eval_blacklist_functions_hook), | 559 | SPG(sp_eval_blacklist_functions_hook), |
| 609 | PHP_FN(eval_blacklist_callback)); | 560 | PHP_FN(eval_blacklist_callback)); |
| 610 | it = it->next; | 561 | it = it->next; |
| 611 | } | 562 | } |
| @@ -622,10 +573,7 @@ int hook_echo(const char* str, size_t str_length) { | |||
| 622 | #endif | 573 | #endif |
| 623 | zend_string* zs = zend_string_init(str, str_length, 0); | 574 | zend_string* zs = zend_string_init(str, str_length, 0); |
| 624 | 575 | ||
| 625 | should_disable_ht( | 576 | should_disable_ht(EG(current_execute_data), "echo", zs, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions_hooked)); |
| 626 | EG(current_execute_data), "echo", zs, NULL, | ||
| 627 | SNUFFLEUPAGUS_G(config).config_disabled_functions_reg->disabled_functions, | ||
| 628 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked); | ||
| 629 | 577 | ||
| 630 | zend_string_release(zs); | 578 | zend_string_release(zs); |
| 631 | 579 | ||
diff --git a/src/sp_execute.c b/src/sp_execute.c index 7d078b0..f1ed8d0 100644 --- a/src/sp_execute.c +++ b/src/sp_execute.c | |||
| @@ -3,33 +3,28 @@ | |||
| 3 | static void (*orig_execute_ex)(zend_execute_data *execute_data) = NULL; | 3 | static void (*orig_execute_ex)(zend_execute_data *execute_data) = NULL; |
| 4 | static void (*orig_zend_execute_internal)(zend_execute_data *execute_data, | 4 | static void (*orig_zend_execute_internal)(zend_execute_data *execute_data, |
| 5 | zval *return_value) = NULL; | 5 | zval *return_value) = NULL; |
| 6 | static int (*orig_zend_stream_open)(const char *filename, | 6 | #if PHP_VERSION_ID < 80100 |
| 7 | zend_file_handle *handle) = NULL; | 7 | static int (*orig_zend_stream_open)(const char *filename, zend_file_handle *handle) = NULL; |
| 8 | #else | ||
| 9 | static zend_result (*orig_zend_stream_open)(zend_file_handle *handle) = NULL; | ||
| 10 | #endif | ||
| 8 | 11 | ||
| 9 | // FIXME handle symlink | 12 | // FIXME handle symlink |
| 10 | ZEND_COLD static inline void terminate_if_writable(const char *filename) { | 13 | ZEND_COLD static inline void terminate_if_writable(const char *filename) { |
| 11 | const sp_config_readonly_exec *config_ro_exec = | 14 | const sp_config_readonly_exec *config_ro_exec = &(SPCFG(readonly_exec)); |
| 12 | SNUFFLEUPAGUS_G(config).config_readonly_exec; | ||
| 13 | |||
| 14 | if (0 == access(filename, W_OK)) { | 15 | if (0 == access(filename, W_OK)) { |
| 15 | if (config_ro_exec->dump) { | 16 | if (config_ro_exec->dump) { |
| 16 | sp_log_request(config_ro_exec->dump, | 17 | sp_log_request(config_ro_exec->dump, config_ro_exec->textual_representation); |
| 17 | config_ro_exec->textual_representation, | ||
| 18 | SP_TOKEN_READONLY_EXEC); | ||
| 19 | } | 18 | } |
| 20 | if (true == config_ro_exec->simulation) { | 19 | if (true == config_ro_exec->simulation) { |
| 21 | sp_log_simulation("readonly_exec", | 20 | sp_log_simulation("readonly_exec", "Attempted execution of a writable file (%s).", filename); |
| 22 | "Attempted execution of a writable file (%s).", | ||
| 23 | filename); | ||
| 24 | } else { | 21 | } else { |
| 25 | sp_log_drop("readonly_exec", | 22 | sp_log_drop("readonly_exec", "Attempted execution of a writable file (%s).", filename); |
| 26 | "Attempted execution of a writable file (%s).", filename); | ||
| 27 | } | 23 | } |
| 28 | } else { | 24 | } else { |
| 29 | if (EACCES != errno) { | 25 | if (EACCES != errno) { |
| 30 | // LCOV_EXCL_START | 26 | // LCOV_EXCL_START |
| 31 | sp_log_err("Writable execution", "Error while accessing %s: %s", filename, | 27 | sp_log_err("Writable execution", "Error while accessing %s: %s", filename, strerror(errno)); |
| 32 | strerror(errno)); | ||
| 33 | // LCOV_EXCL_STOP | 28 | // LCOV_EXCL_STOP |
| 34 | } | 29 | } |
| 35 | } | 30 | } |
| @@ -44,54 +39,43 @@ inline static void is_builtin_matching( | |||
| 44 | return; | 39 | return; |
| 45 | } | 40 | } |
| 46 | 41 | ||
| 47 | should_disable_ht( | 42 | should_disable_ht(EG(current_execute_data), function_name, param_value, param_name, SPCFG(disabled_functions_reg).disabled_functions, ht); |
| 48 | EG(current_execute_data), function_name, param_value, param_name, | ||
| 49 | SNUFFLEUPAGUS_G(config).config_disabled_functions_reg->disabled_functions, | ||
| 50 | ht); | ||
| 51 | } | 43 | } |
| 52 | 44 | ||
| 53 | static void ZEND_HOT | 45 | static void ZEND_HOT is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { |
| 54 | is_in_eval_and_whitelisted(const zend_execute_data *execute_data) { | 46 | const sp_config_eval *config_eval = &(SPCFG(eval)); |
| 55 | const sp_config_eval *config_eval = SNUFFLEUPAGUS_G(config).config_eval; | ||
| 56 | 47 | ||
| 57 | if (EXPECTED(0 == SNUFFLEUPAGUS_G(in_eval))) { | 48 | if (EXPECTED(0 == SPG(in_eval))) { |
| 58 | return; | 49 | return; |
| 59 | } | 50 | } |
| 60 | 51 | ||
| 61 | if (EXPECTED(NULL == SNUFFLEUPAGUS_G(config).config_eval->whitelist)) { | 52 | if (EXPECTED(NULL == config_eval->whitelist)) { |
| 62 | return; | 53 | return; |
| 63 | } | 54 | } |
| 64 | 55 | ||
| 65 | if (zend_is_executing() && !EG(current_execute_data)->func) { | 56 | if (zend_is_executing() && !EX(func)) { |
| 66 | return; // LCOV_EXCL_LINE | 57 | return; // LCOV_EXCL_LINE |
| 67 | } | 58 | } |
| 68 | 59 | ||
| 69 | if (UNEXPECTED(!(execute_data->func->common.function_name))) { | 60 | char *function_name = get_complete_function_path(execute_data); |
| 61 | if (!function_name) { | ||
| 70 | return; | 62 | return; |
| 71 | } | 63 | } |
| 72 | 64 | ||
| 73 | zend_string const *const current_function = EX(func)->common.function_name; | 65 | if (UNEXPECTED(false == check_is_in_eval_whitelist(function_name))) { |
| 74 | |||
| 75 | if (EXPECTED(NULL != current_function)) { | ||
| 76 | if (UNEXPECTED(false == check_is_in_eval_whitelist(current_function))) { | ||
| 77 | if (config_eval->dump) { | 66 | if (config_eval->dump) { |
| 78 | sp_log_request(config_eval->dump, config_eval->textual_representation, | 67 | sp_log_request(config_eval->dump, config_eval->textual_representation); |
| 79 | SP_TOKEN_EVAL_WHITELIST); | ||
| 80 | } | 68 | } |
| 81 | if (config_eval->simulation) { | 69 | if (config_eval->simulation) { |
| 82 | sp_log_simulation( | 70 | sp_log_simulation("Eval_whitelist", "The function '%s' isn't in the eval whitelist, logging its call.", function_name); |
| 83 | "Eval_whitelist", | 71 | goto out; |
| 84 | "The function '%s' isn't in the eval whitelist, logging its call.", | ||
| 85 | ZSTR_VAL(current_function)); | ||
| 86 | return; | ||
| 87 | } else { | 72 | } else { |
| 88 | sp_log_drop( | 73 | sp_log_drop("Eval_whitelist", "The function '%s' isn't in the eval whitelist, dropping its call.", function_name); |
| 89 | "Eval_whitelist", | ||
| 90 | "The function '%s' isn't in the eval whitelist, dropping its call.", | ||
| 91 | ZSTR_VAL(current_function)); | ||
| 92 | } | 74 | } |
| 93 | } | 75 | } |
| 94 | } | 76 | // } |
| 77 | out: | ||
| 78 | efree(function_name); | ||
| 95 | } | 79 | } |
| 96 | 80 | ||
| 97 | /* This function gets the filename in which `eval()` is called from, | 81 | /* This function gets the filename in which `eval()` is called from, |
| @@ -114,162 +98,194 @@ zend_string *get_eval_filename(const char *const filename) { | |||
| 114 | return clean_filename; | 98 | return clean_filename; |
| 115 | } | 99 | } |
| 116 | 100 | ||
| 117 | static void sp_execute_ex(zend_execute_data *execute_data) { | 101 | static inline void sp_orig_execute(zend_execute_data *execute_data) { |
| 118 | is_in_eval_and_whitelisted(execute_data); | 102 | SPG(execution_depth)++; |
| 119 | const HashTable *config_disabled_functions = | 103 | if (SPCFG(max_execution_depth) > 0 && SPG(execution_depth) > SPCFG(max_execution_depth)) { |
| 120 | SNUFFLEUPAGUS_G(config).config_disabled_functions; | 104 | sp_log_drop("execute", "Maximum recursion limit reached. Script terminated."); |
| 105 | } | ||
| 106 | orig_execute_ex(execute_data); | ||
| 107 | SPG(execution_depth)--; | ||
| 108 | } | ||
| 109 | |||
| 110 | static inline void sp_check_writable(zend_execute_data *execute_data) { | ||
| 111 | if (execute_data && EX(func) && EX(func)->op_array.filename && SPCFG(readonly_exec).enable) { | ||
| 112 | terminate_if_writable(ZSTR_VAL(EX(func)->op_array.filename)); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | |||
| 116 | static inline void sp_call_orig_execute(INTERNAL_FUNCTION_PARAMETERS, bool internal) { | ||
| 117 | if (internal) { | ||
| 118 | if (UNEXPECTED(NULL != orig_zend_execute_internal)) { | ||
| 119 | orig_zend_execute_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
| 120 | } else { | ||
| 121 | EX(func)->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
| 122 | } | ||
| 123 | } else { | ||
| 124 | sp_orig_execute(execute_data); | ||
| 125 | } | ||
| 126 | } | ||
| 121 | 127 | ||
| 128 | static inline void sp_execute_handler(INTERNAL_FUNCTION_PARAMETERS, bool internal) { | ||
| 122 | if (!execute_data) { | 129 | if (!execute_data) { |
| 123 | return; // LCOV_EXCL_LINE | 130 | return; // LCOV_EXCL_LINE |
| 124 | } | 131 | } |
| 125 | 132 | ||
| 126 | if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) { | 133 | is_in_eval_and_whitelisted(execute_data); |
| 127 | const sp_list_node *config = zend_hash_str_find_ptr( | 134 | |
| 128 | config_disabled_functions, "eval", sizeof("eval") - 1); | 135 | if (!internal) { |
| 136 | if (UNEXPECTED(EX(func)->op_array.type == ZEND_EVAL_CODE)) { | ||
| 137 | const sp_list_node *config = zend_hash_str_find_ptr(SPCFG(disabled_functions), ZEND_STRL("eval")); | ||
| 138 | |||
| 139 | zend_string *filename = get_eval_filename(zend_get_executed_filename()); | ||
| 140 | is_builtin_matching(filename, "eval", NULL, config, SPCFG(disabled_functions)); | ||
| 141 | zend_string_release(filename); | ||
| 142 | |||
| 143 | SPG(in_eval)++; | ||
| 144 | sp_orig_execute(execute_data); | ||
| 145 | SPG(in_eval)--; | ||
| 146 | return; | ||
| 147 | } | ||
| 129 | 148 | ||
| 130 | zend_string *filename = get_eval_filename(zend_get_executed_filename()); | 149 | sp_check_writable(execute_data); |
| 131 | is_builtin_matching(filename, "eval", NULL, config, | 150 | } |
| 132 | config_disabled_functions); | ||
| 133 | zend_string_release(filename); | ||
| 134 | 151 | ||
| 135 | SNUFFLEUPAGUS_G(in_eval)++; | 152 | if (!SPG(hook_execute)) { |
| 136 | orig_execute_ex(execute_data); | 153 | sp_call_orig_execute(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal); |
| 137 | SNUFFLEUPAGUS_G(in_eval)--; | ||
| 138 | return; | 154 | return; |
| 139 | } | 155 | } |
| 140 | 156 | ||
| 141 | if (NULL != EX(func)->op_array.filename) { | 157 | char *function_name = get_complete_function_path(execute_data); |
| 142 | if (true == SNUFFLEUPAGUS_G(config).config_readonly_exec->enable) { | 158 | |
| 143 | terminate_if_writable(ZSTR_VAL(EX(func)->op_array.filename)); | 159 | if (!function_name) { |
| 144 | } | 160 | sp_call_orig_execute(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal); |
| 161 | return; | ||
| 145 | } | 162 | } |
| 146 | 163 | ||
| 147 | if (SNUFFLEUPAGUS_G(config).hook_execute) { | 164 | bool is_hooked = (zend_hash_str_find(SPG(disabled_functions_hook), VAR_AND_LEN(function_name)) || zend_hash_str_find(SPG(disabled_functions_hook), VAR_AND_LEN(function_name))); |
| 148 | char *function_name = get_complete_function_path(execute_data); | 165 | if (is_hooked) { |
| 149 | zval ret_val; | 166 | sp_call_orig_execute(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal); |
| 150 | const sp_list_node *config_disabled_functions_reg = | 167 | return; |
| 151 | SNUFFLEUPAGUS_G(config) | 168 | } |
| 152 | .config_disabled_functions_reg->disabled_functions; | ||
| 153 | 169 | ||
| 154 | if (!function_name) { | 170 | // If we're at an internal function |
| 155 | orig_execute_ex(execute_data); | 171 | if (!execute_data->prev_execute_data || |
| 156 | return; | 172 | !execute_data->prev_execute_data->func || |
| 173 | !ZEND_USER_CODE(execute_data->prev_execute_data->func->type) || | ||
| 174 | !execute_data->prev_execute_data->opline) { | ||
| 175 | should_disable_ht(execute_data, function_name, NULL, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions)); | ||
| 176 | } else { // If we're at a userland function call | ||
| 177 | switch (execute_data->prev_execute_data->opline->opcode) { | ||
| 178 | case ZEND_DO_FCALL: | ||
| 179 | case ZEND_DO_FCALL_BY_NAME: | ||
| 180 | case ZEND_DO_ICALL: | ||
| 181 | case ZEND_DO_UCALL: | ||
| 182 | case ZEND_TICKS: | ||
| 183 | should_disable_ht(execute_data, function_name, NULL, NULL, SPCFG(disabled_functions_reg).disabled_functions, SPCFG(disabled_functions)); | ||
| 184 | default: | ||
| 185 | break; | ||
| 157 | } | 186 | } |
| 187 | } | ||
| 158 | 188 | ||
| 159 | // If we're at an internal function | 189 | // When a function's return value isn't used, php doesn't store it in the |
| 160 | if (!execute_data->prev_execute_data || | 190 | // execute_data, so we need to use a local variable to be able to match on |
| 161 | !execute_data->prev_execute_data->func || | 191 | // it later. |
| 162 | !ZEND_USER_CODE(execute_data->prev_execute_data->func->type) || | 192 | zval ret_val; |
| 163 | !execute_data->prev_execute_data->opline) { | 193 | if (EX(return_value) == NULL && return_value == NULL) { |
| 164 | should_disable_ht(execute_data, function_name, NULL, NULL, | 194 | memset(&ret_val, 0, sizeof(ret_val)); |
| 165 | config_disabled_functions_reg, | 195 | return_value = EX(return_value) = &ret_val; |
| 166 | config_disabled_functions); | 196 | } |
| 167 | } else { // If we're at a userland function call | ||
| 168 | switch (execute_data->prev_execute_data->opline->opcode) { | ||
| 169 | case ZEND_DO_FCALL: | ||
| 170 | case ZEND_DO_FCALL_BY_NAME: | ||
| 171 | case ZEND_DO_ICALL: | ||
| 172 | case ZEND_DO_UCALL: | ||
| 173 | should_disable_ht(execute_data, function_name, NULL, NULL, | ||
| 174 | config_disabled_functions_reg, | ||
| 175 | config_disabled_functions); | ||
| 176 | default: | ||
| 177 | break; | ||
| 178 | } | ||
| 179 | } | ||
| 180 | 197 | ||
| 181 | // When a function's return value isn't used, php doesn't store it in the | 198 | sp_call_orig_execute(INTERNAL_FUNCTION_PARAM_PASSTHRU, internal); |
| 182 | // execute_data, so we need to use a local variable to be able to match on | ||
| 183 | // it later. | ||
| 184 | if (EX(return_value) == NULL) { | ||
| 185 | memset(&ret_val, 0, sizeof(ret_val)); | ||
| 186 | EX(return_value) = &ret_val; | ||
| 187 | } | ||
| 188 | 199 | ||
| 189 | orig_execute_ex(execute_data); | 200 | should_drop_on_ret_ht(return_value, function_name, SPCFG(disabled_functions_reg_ret).disabled_functions, SPCFG(disabled_functions_ret), execute_data); |
| 190 | 201 | ||
| 191 | should_drop_on_ret_ht( | 202 | efree(function_name); |
| 192 | EX(return_value), function_name, | ||
| 193 | SNUFFLEUPAGUS_G(config) | ||
| 194 | .config_disabled_functions_reg_ret->disabled_functions, | ||
| 195 | SNUFFLEUPAGUS_G(config).config_disabled_functions_ret, execute_data); | ||
| 196 | efree(function_name); | ||
| 197 | 203 | ||
| 198 | if (EX(return_value) == &ret_val) { | 204 | if (EX(return_value) == &ret_val) { |
| 199 | EX(return_value) = NULL; | 205 | return_value = EX(return_value) = NULL; |
| 200 | } | ||
| 201 | } else { | ||
| 202 | orig_execute_ex(execute_data); | ||
| 203 | } | 206 | } |
| 207 | |||
| 204 | } | 208 | } |
| 205 | 209 | ||
| 206 | static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) { | ||
| 207 | is_in_eval_and_whitelisted(execute_data); | ||
| 208 | 210 | ||
| 209 | if (UNEXPECTED(NULL != orig_zend_execute_internal)) { | 211 | static void sp_execute_ex(zend_execute_data *execute_data) { |
| 210 | // LCOV_EXCL_START | 212 | sp_execute_handler(execute_data, execute_data ? EX(return_value) : NULL, false); |
| 211 | orig_zend_execute_internal(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
| 212 | // LCOV_EXCL_STOP | ||
| 213 | } else { | ||
| 214 | EX(func)->internal_function.handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | ||
| 215 | } | ||
| 216 | } | 213 | } |
| 217 | 214 | ||
| 218 | static int sp_stream_open(const char *filename, zend_file_handle *handle) { | 215 | static void sp_zend_execute_internal(INTERNAL_FUNCTION_PARAMETERS) { |
| 216 | sp_execute_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU, true); | ||
| 217 | } | ||
| 218 | |||
| 219 | static inline void sp_stream_open_checks(zend_string *zend_filename, zend_file_handle *handle) { | ||
| 219 | zend_execute_data const *const data = EG(current_execute_data); | 220 | zend_execute_data const *const data = EG(current_execute_data); |
| 220 | 221 | ||
| 221 | if ((NULL == data) || (NULL == data->opline) || | 222 | if ((NULL == data) || (NULL == data->opline) || |
| 222 | (data->func->type != ZEND_USER_FUNCTION)) { | 223 | (data->func->type != ZEND_USER_FUNCTION)) { |
| 223 | goto end; | 224 | return; |
| 224 | } | 225 | } |
| 225 | 226 | ||
| 226 | zend_string *zend_filename = zend_string_init(filename, strlen(filename), 0); | 227 | // zend_string *zend_filename = zend_string_init(filename, strlen(filename), 0); |
| 227 | const HashTable *disabled_functions_hooked = | 228 | const HashTable *disabled_functions_hooked = SPCFG(disabled_functions_hooked); |
| 228 | SNUFFLEUPAGUS_G(config).config_disabled_functions_hooked; | ||
| 229 | 229 | ||
| 230 | switch (data->opline->opcode) { | 230 | switch (data->opline->opcode) { |
| 231 | case ZEND_INCLUDE_OR_EVAL: | 231 | case ZEND_INCLUDE_OR_EVAL: |
| 232 | if (true == SNUFFLEUPAGUS_G(config).config_readonly_exec->enable) { | 232 | if (SPCFG(readonly_exec).enable) { |
| 233 | terminate_if_writable(filename); | 233 | terminate_if_writable(ZSTR_VAL(zend_filename)); |
| 234 | } | 234 | } |
| 235 | switch (data->opline->extended_value) { | 235 | switch (data->opline->extended_value) { |
| 236 | case ZEND_INCLUDE: | 236 | case ZEND_INCLUDE: |
| 237 | is_builtin_matching( | 237 | is_builtin_matching( |
| 238 | zend_filename, "include", "inclusion path", | 238 | zend_filename, "include", "inclusion path", |
| 239 | zend_hash_str_find_ptr(disabled_functions_hooked, "include", | 239 | zend_hash_str_find_ptr(disabled_functions_hooked, ZEND_STRL("include")), |
| 240 | sizeof("include") - 1), | ||
| 241 | disabled_functions_hooked); | 240 | disabled_functions_hooked); |
| 242 | break; | 241 | break; |
| 243 | case ZEND_REQUIRE: | 242 | case ZEND_REQUIRE: |
| 244 | is_builtin_matching( | 243 | is_builtin_matching( |
| 245 | zend_filename, "require", "inclusion path", | 244 | zend_filename, "require", "inclusion path", |
| 246 | zend_hash_str_find_ptr(disabled_functions_hooked, "require", | 245 | zend_hash_str_find_ptr(disabled_functions_hooked, ZEND_STRL("require")), |
| 247 | sizeof("require") - 1), | ||
| 248 | disabled_functions_hooked); | 246 | disabled_functions_hooked); |
| 249 | break; | 247 | break; |
| 250 | case ZEND_REQUIRE_ONCE: | 248 | case ZEND_REQUIRE_ONCE: |
| 251 | is_builtin_matching( | 249 | is_builtin_matching( |
| 252 | zend_filename, "require_once", "inclusion path", | 250 | zend_filename, "require_once", "inclusion path", |
| 253 | zend_hash_str_find_ptr(disabled_functions_hooked, "require_once", | 251 | zend_hash_str_find_ptr(disabled_functions_hooked, ZEND_STRL("require_once")), |
| 254 | sizeof("require_once") - 1), | ||
| 255 | disabled_functions_hooked); | 252 | disabled_functions_hooked); |
| 256 | break; | 253 | break; |
| 257 | case ZEND_INCLUDE_ONCE: | 254 | case ZEND_INCLUDE_ONCE: |
| 258 | is_builtin_matching( | 255 | is_builtin_matching( |
| 259 | zend_filename, "include_once", "inclusion path", | 256 | zend_filename, "include_once", "inclusion path", |
| 260 | zend_hash_str_find_ptr(disabled_functions_hooked, "include_once", | 257 | zend_hash_str_find_ptr(disabled_functions_hooked, ZEND_STRL("include_once")), |
| 261 | sizeof("include_once") - 1), | ||
| 262 | disabled_functions_hooked); | 258 | disabled_functions_hooked); |
| 263 | break; | 259 | break; |
| 264 | EMPTY_SWITCH_DEFAULT_CASE(); // LCOV_EXCL_LINE | 260 | EMPTY_SWITCH_DEFAULT_CASE(); // LCOV_EXCL_LINE |
| 265 | } | 261 | } |
| 266 | } | 262 | } |
| 267 | efree(zend_filename); | 263 | // efree(zend_filename); |
| 268 | 264 | ||
| 269 | end: | 265 | // end: |
| 266 | // return orig_zend_stream_open(filename, handle); | ||
| 267 | } | ||
| 268 | |||
| 269 | #if PHP_VERSION_ID < 80100 | ||
| 270 | |||
| 271 | static int sp_stream_open(const char *filename, zend_file_handle *handle) { | ||
| 272 | zend_string *zend_filename = zend_string_init(filename, strlen(filename), 0); | ||
| 273 | |||
| 274 | sp_stream_open_checks(zend_filename, handle); | ||
| 275 | |||
| 276 | zend_string_release_ex(zend_filename, 0); | ||
| 270 | return orig_zend_stream_open(filename, handle); | 277 | return orig_zend_stream_open(filename, handle); |
| 271 | } | 278 | } |
| 272 | 279 | ||
| 280 | #else // PHP >= 8.1 | ||
| 281 | |||
| 282 | static zend_result sp_stream_open(zend_file_handle *handle) { | ||
| 283 | sp_stream_open_checks(handle->filename, handle); | ||
| 284 | return orig_zend_stream_open(handle); | ||
| 285 | } | ||
| 286 | |||
| 287 | #endif | ||
| 288 | |||
| 273 | int hook_execute(void) { | 289 | int hook_execute(void) { |
| 274 | TSRMLS_FETCH(); | 290 | TSRMLS_FETCH(); |
| 275 | 291 | ||
diff --git a/src/sp_harden_rand.c b/src/sp_harden_rand.c index 43c2a5b..3e9bcb3 100644 --- a/src/sp_harden_rand.c +++ b/src/sp_harden_rand.c | |||
| @@ -54,8 +54,7 @@ PHP_FUNCTION(sp_rand) { | |||
| 54 | 54 | ||
| 55 | /* call the original `rand` function, | 55 | /* call the original `rand` function, |
| 56 | * since we might no be the only ones to hook it*/ | 56 | * since we might no be the only ones to hook it*/ |
| 57 | orig_handler = zend_hash_str_find_ptr( | 57 | orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("rand")); |
| 58 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), "rand", sizeof("rand") - 1); | ||
| 59 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 58 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 60 | 59 | ||
| 61 | random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 60 | random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| @@ -67,8 +66,7 @@ PHP_FUNCTION(sp_mt_rand) { | |||
| 67 | /* call the original `mt_rand` function, | 66 | /* call the original `mt_rand` function, |
| 68 | * since we might no be the only ones to hook it*/ | 67 | * since we might no be the only ones to hook it*/ |
| 69 | orig_handler = | 68 | orig_handler = |
| 70 | zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), | 69 | zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("mt_rand")); |
| 71 | "mt_rand", sizeof("mt_rand") - 1); | ||
| 72 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 70 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 73 | 71 | ||
| 74 | random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 72 | random_int_wrapper(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
diff --git a/src/sp_ifilter.c b/src/sp_ifilter.c new file mode 100644 index 0000000..8099882 --- /dev/null +++ b/src/sp_ifilter.c | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | static void (*orig_register_server_variables)(zval *track_vars_array) = NULL; | ||
| 4 | |||
| 5 | static const unsigned char sp_hexchars[] = "0123456789ABCDEF"; | ||
| 6 | |||
| 7 | static const char sp_is_dangerous_char[256] = { | ||
| 8 | /* |-> 0 1 2 3 4 5 6 7 8 9 a b c d e f */ | ||
| 9 | /* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, | ||
| 10 | /* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 11 | /* 0x20 */ 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 12 | /* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, | ||
| 13 | /* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 14 | /* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 15 | /* 0x60 */ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 16 | /* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 17 | /* 0x80 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 18 | /* 0x90 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 19 | /* 0xa0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 20 | /* 0xb0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 21 | /* 0xc0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 22 | /* 0xd0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 23 | /* 0xe0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, | ||
| 24 | /* 0xf0 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 | ||
| 25 | }; | ||
| 26 | |||
| 27 | static void sp_server_strip(HashTable *svars, char *key, int keylen) { | ||
| 28 | zval *value = zend_hash_str_find(svars, key, keylen); | ||
| 29 | if (!value || Z_TYPE_P(value) != IS_STRING) { return; } | ||
| 30 | |||
| 31 | zend_string *tmp_zstr = Z_STR_P(value); | ||
| 32 | char *tmp = ZSTR_VAL(tmp_zstr); | ||
| 33 | char *tmpend = tmp + ZSTR_LEN(tmp_zstr); | ||
| 34 | |||
| 35 | for (char *p = tmp; p < tmpend; p++) { | ||
| 36 | if (sp_is_dangerous_char[(int)*p]) { | ||
| 37 | *p = '_'; | ||
| 38 | } | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | static void sp_server_encode(HashTable *svars, char *key, int keylen) { | ||
| 43 | zval *value = zend_hash_str_find(svars, key, keylen); | ||
| 44 | if (!value || Z_TYPE_P(value) != IS_STRING) { return; } | ||
| 45 | |||
| 46 | zend_string *tmp_zstr = Z_STR_P(value); | ||
| 47 | char *tmp = ZSTR_VAL(tmp_zstr); | ||
| 48 | char *tmpend = tmp + ZSTR_LEN(tmp_zstr); | ||
| 49 | int extra = 0; | ||
| 50 | |||
| 51 | for (char *p = tmp; p < tmpend; p++) { | ||
| 52 | extra += sp_is_dangerous_char[(int)*p] * 2; | ||
| 53 | } | ||
| 54 | if (!extra) { return; } | ||
| 55 | |||
| 56 | zend_string *new_zstr = zend_string_alloc(ZSTR_LEN(tmp_zstr) + extra, 0); | ||
| 57 | char *n = ZSTR_VAL(new_zstr); | ||
| 58 | for (char *p = tmp; p < tmpend; p++, n++) { | ||
| 59 | if (sp_is_dangerous_char[(int)*p]) { | ||
| 60 | *n++ = '%'; | ||
| 61 | *n++ = sp_hexchars[*p >> 4]; | ||
| 62 | *n = sp_hexchars[*p & 15]; | ||
| 63 | } else { | ||
| 64 | *n = *p; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | ZSTR_VAL(new_zstr)[ZSTR_LEN(new_zstr)] = 0; | ||
| 68 | Z_STR_P(value) = new_zstr; | ||
| 69 | |||
| 70 | zend_string_release_ex(tmp_zstr, 0); | ||
| 71 | } | ||
| 72 | |||
| 73 | static void sp_register_server_variables(zval *track_vars_array) { | ||
| 74 | orig_register_server_variables(track_vars_array); | ||
| 75 | |||
| 76 | HashTable *svars; | ||
| 77 | svars = Z_ARRVAL_P(track_vars_array); | ||
| 78 | |||
| 79 | |||
| 80 | if (SPCFG(server_encode)) { | ||
| 81 | sp_server_encode(svars, ZEND_STRL("REQUEST_URI")); | ||
| 82 | sp_server_encode(svars, ZEND_STRL("QUERY_STRING")); | ||
| 83 | } | ||
| 84 | |||
| 85 | if (SPCFG(server_strip)) { | ||
| 86 | sp_server_strip(svars, ZEND_STRL("PHP_SELF")); | ||
| 87 | sp_server_strip(svars, ZEND_STRL("HTTP_HOST")); | ||
| 88 | sp_server_strip(svars, ZEND_STRL("HTTP_USER_AGENT")); | ||
| 89 | |||
| 90 | // for cgi + fpm | ||
| 91 | sp_server_strip(svars, ZEND_STRL("PATH_INFO")); | ||
| 92 | sp_server_strip(svars, ZEND_STRL("PATH_TRANSLATED")); | ||
| 93 | sp_server_strip(svars, ZEND_STRL("ORIG_PATH_TRANSLATED")); | ||
| 94 | sp_server_strip(svars, ZEND_STRL("ORIG_PATH_INFO")); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | void sp_hook_register_server_variables() | ||
| 99 | { | ||
| 100 | if (sapi_module.register_server_variables) { | ||
| 101 | orig_register_server_variables = sapi_module.register_server_variables; | ||
| 102 | sapi_module.register_server_variables = sp_register_server_variables; | ||
| 103 | } | ||
| 104 | } | ||
diff --git a/src/sp_ifilter.h b/src/sp_ifilter.h new file mode 100644 index 0000000..527c41d --- /dev/null +++ b/src/sp_ifilter.h | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | void sp_hook_register_server_variables(); | ||
diff --git a/src/sp_ini.c b/src/sp_ini.c new file mode 100644 index 0000000..7fec297 --- /dev/null +++ b/src/sp_ini.c | |||
| @@ -0,0 +1,142 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | #define SP_INI_HAS_CHECKS_COND(entry) (entry->min || entry->max || entry->regexp) | ||
| 4 | #define SP_INI_ACCESS_READONLY_COND(entry, cfg) (entry->access == SP_READONLY || (!entry->access && cfg->policy_readonly)) | ||
| 5 | |||
| 6 | #define sp_log_auto2(feature, is_simulation, drop, ...) \ | ||
| 7 | sp_log_msgf(feature, ((is_simulation || !drop) ? SP_LOG_WARN : SP_LOG_ERROR), \ | ||
| 8 | (is_simulation ? SP_TYPE_SIMULATION : (drop ? SP_TYPE_DROP : SP_TYPE_LOG)), \ | ||
| 9 | __VA_ARGS__) | ||
| 10 | #define sp_log_ini_check_violation(...) if (simulation || cfg->policy_drop || (entry && entry->drop) || !cfg->policy_silent_fail) { \ | ||
| 11 | sp_log_auto2("ini_protection", simulation, (cfg->policy_drop || (entry && entry->drop)), __VA_ARGS__); \ | ||
| 12 | } | ||
| 13 | |||
| 14 | |||
| 15 | static bool /* success */ sp_ini_check(zend_string *varname, zend_string *new_value, sp_ini_entry **sp_entry_p) { | ||
| 16 | if (!varname || ZSTR_LEN(varname) == 0) { | ||
| 17 | return false; | ||
| 18 | } | ||
| 19 | |||
| 20 | sp_config_ini *cfg = &(SPCFG(ini)); | ||
| 21 | sp_ini_entry *entry = zend_hash_find_ptr(cfg->entries, varname); | ||
| 22 | if (sp_entry_p) { | ||
| 23 | *sp_entry_p = entry; | ||
| 24 | } | ||
| 25 | bool simulation = (cfg->simulation || (entry && entry->simulation)); | ||
| 26 | |||
| 27 | if (!entry) { | ||
| 28 | if (cfg->policy_readonly) { | ||
| 29 | if (!cfg->policy_silent_ro) { | ||
| 30 | sp_log_ini_check_violation("INI setting is read-only"); | ||
| 31 | } | ||
| 32 | return simulation; | ||
| 33 | } | ||
| 34 | return true; | ||
| 35 | } | ||
| 36 | |||
| 37 | // we have an entry. | ||
| 38 | |||
| 39 | if (SP_INI_ACCESS_READONLY_COND(entry, cfg)) { | ||
| 40 | if (!cfg->policy_silent_ro) { | ||
| 41 | sp_log_ini_check_violation("%s", (entry->msg ? ZSTR_VAL(entry->msg) : "INI setting is read-only")); | ||
| 42 | } | ||
| 43 | return simulation; | ||
| 44 | } | ||
| 45 | |||
| 46 | if (!new_value || ZSTR_LEN(new_value) == 0) { | ||
| 47 | if (entry->allow_null) { | ||
| 48 | return true; // allow NULL value and skip other tests | ||
| 49 | } | ||
| 50 | if (SP_INI_HAS_CHECKS_COND(entry)) { | ||
| 51 | sp_log_ini_check_violation("new INI value must not be NULL or empty"); | ||
| 52 | return simulation; | ||
| 53 | } | ||
| 54 | return true; // no new_value, but no checks to perform | ||
| 55 | } | ||
| 56 | |||
| 57 | // we have a new_value. | ||
| 58 | |||
| 59 | if (entry->min || entry->max) { | ||
| 60 | zend_long lvalue = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value)); | ||
| 61 | if ((entry->min && zend_atol(ZSTR_VAL(entry->min), ZSTR_LEN(entry->min)) > lvalue) || | ||
| 62 | (entry->max && zend_atol(ZSTR_VAL(entry->max), ZSTR_LEN(entry->max)) < lvalue)) { | ||
| 63 | sp_log_ini_check_violation("%s", (entry->msg ? ZSTR_VAL(entry->msg) : "INI value out of range")); | ||
| 64 | return simulation; | ||
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | if (entry->regexp) { | ||
| 69 | if (!sp_is_regexp_matching_zstr(entry->regexp, new_value)) { | ||
| 70 | sp_log_ini_check_violation("%s", (entry->msg ? ZSTR_VAL(entry->msg) : "INI value does not match regex")); | ||
| 71 | return simulation; | ||
| 72 | } | ||
| 73 | } | ||
| 74 | |||
| 75 | return true; | ||
| 76 | } | ||
| 77 | |||
| 78 | static PHP_INI_MH(sp_ini_onmodify) { | ||
| 79 | zend_ini_entry *ini_entry = entry; | ||
| 80 | sp_ini_entry *sp_entry = NULL; | ||
| 81 | |||
| 82 | if (!sp_ini_check(ini_entry->name, new_value, &sp_entry)) { | ||
| 83 | return FAILURE; | ||
| 84 | } | ||
| 85 | |||
| 86 | if (sp_entry && sp_entry->orig_onmodify) { | ||
| 87 | return sp_entry->orig_onmodify(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); | ||
| 88 | } | ||
| 89 | |||
| 90 | return SUCCESS; | ||
| 91 | } | ||
| 92 | |||
| 93 | void sp_hook_ini() { | ||
| 94 | sp_config_ini *cfg = &(SPCFG(ini)); | ||
| 95 | sp_ini_entry *sp_entry; | ||
| 96 | zend_ini_entry *ini_entry; | ||
| 97 | ZEND_HASH_FOREACH_PTR(cfg->entries, sp_entry) | ||
| 98 | if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), sp_entry->key)) == NULL) { | ||
| 99 | sp_log_warn("ini_protection", "Cannot hook INI var `%s`. Maybe a typo or the PHP extension providing this var is not loaded yet.", ZSTR_VAL(sp_entry->key)); | ||
| 100 | continue; | ||
| 101 | } | ||
| 102 | if (SP_INI_ACCESS_READONLY_COND(sp_entry, cfg) && (cfg->policy_silent_ro || cfg->policy_silent_fail) && !sp_entry->drop && !(sp_entry->simulation || cfg->simulation)) { | ||
| 103 | ini_entry->modifiable = ini_entry->orig_modifiable = 0; | ||
| 104 | } | ||
| 105 | PHP_INI_MH((*orig_onmodify)) = ini_entry->on_modify; | ||
| 106 | |||
| 107 | if (SP_INI_HAS_CHECKS_COND(sp_entry) || SP_INI_ACCESS_READONLY_COND(sp_entry, cfg)) { | ||
| 108 | // only hook on_modify if there is any check to perform | ||
| 109 | sp_entry->orig_onmodify = ini_entry->on_modify; | ||
| 110 | ini_entry->on_modify = sp_ini_onmodify; | ||
| 111 | } | ||
| 112 | |||
| 113 | if (sp_entry->set) { | ||
| 114 | zend_string *duplicate = zend_string_copy(sp_entry->set); | ||
| 115 | |||
| 116 | if (!orig_onmodify || orig_onmodify(ini_entry, duplicate, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, ZEND_INI_STAGE_STARTUP) == SUCCESS) { | ||
| 117 | ini_entry->value = duplicate; | ||
| 118 | } else { | ||
| 119 | zend_string_release(duplicate); | ||
| 120 | sp_log_warn("ini_protection", "Failed to set INI var `%s`.", ZSTR_VAL(sp_entry->key)); | ||
| 121 | continue; | ||
| 122 | } | ||
| 123 | } | ||
| 124 | ZEND_HASH_FOREACH_END(); | ||
| 125 | } | ||
| 126 | |||
| 127 | void sp_unhook_ini() { | ||
| 128 | sp_ini_entry *sp_entry; | ||
| 129 | zend_ini_entry *ini_entry; | ||
| 130 | ZEND_HASH_FOREACH_PTR(SPCFG(ini).entries, sp_entry) | ||
| 131 | if (!sp_entry->orig_onmodify) { | ||
| 132 | // not hooked or no original onmodify | ||
| 133 | continue; | ||
| 134 | } | ||
| 135 | if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), sp_entry->key)) == NULL) { | ||
| 136 | // unusual. ini entry is missing. | ||
| 137 | continue; | ||
| 138 | } | ||
| 139 | ini_entry->on_modify = sp_entry->orig_onmodify; | ||
| 140 | sp_entry->orig_onmodify = NULL; | ||
| 141 | ZEND_HASH_FOREACH_END(); | ||
| 142 | } | ||
diff --git a/src/sp_ini.h b/src/sp_ini.h new file mode 100644 index 0000000..5869539 --- /dev/null +++ b/src/sp_ini.h | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | void sp_hook_ini(); | ||
| 2 | void sp_unhook_ini(); \ No newline at end of file | ||
diff --git a/src/sp_list.c b/src/sp_list.c index 0f00371..ab752f7 100644 --- a/src/sp_list.c +++ b/src/sp_list.c | |||
| @@ -1,8 +1,22 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | void sp_list_free(sp_list_node *node) { | 3 | void sp_list_free(sp_list_node *node, void (*free_data_func)(void *data)) { |
| 4 | while (node) { | 4 | while (node) { |
| 5 | sp_list_node *tmp = node->next; | 5 | sp_list_node *tmp = node->next; |
| 6 | if (free_data_func && node->data) { | ||
| 7 | free_data_func(node->data); | ||
| 8 | } | ||
| 9 | pefree(node, 1); | ||
| 10 | node = tmp; | ||
| 11 | } | ||
| 12 | } | ||
| 13 | |||
| 14 | void sp_list_free2(sp_list_node *node) { | ||
| 15 | while (node) { | ||
| 16 | sp_list_node *tmp = node->next; | ||
| 17 | if (node->data) { | ||
| 18 | pefree(node->data, 1); | ||
| 19 | } | ||
| 6 | pefree(node, 1); | 20 | pefree(node, 1); |
| 7 | node = tmp; | 21 | node = tmp; |
| 8 | } | 22 | } |
| @@ -61,3 +75,9 @@ sp_list_node *sp_list_prepend(sp_list_node *list, void *data) { | |||
| 61 | new->data = data; | 75 | new->data = data; |
| 62 | return new; | 76 | return new; |
| 63 | } | 77 | } |
| 78 | |||
| 79 | size_t sp_list_len(sp_list_node *p) { | ||
| 80 | size_t num = 0; | ||
| 81 | for (; p; p = p->next) { num++; } | ||
| 82 | return num; | ||
| 83 | } | ||
diff --git a/src/sp_list.h b/src/sp_list.h index 2c91995..81bbb29 100644 --- a/src/sp_list.h +++ b/src/sp_list.h | |||
| @@ -11,6 +11,8 @@ sp_list_node *sp_list_sort(sp_list_node *, int (*)(sp_list_node const *const, | |||
| 11 | sp_list_node const *const)); | 11 | sp_list_node const *const)); |
| 12 | sp_list_node *sp_list_insert(sp_list_node *, void *); | 12 | sp_list_node *sp_list_insert(sp_list_node *, void *); |
| 13 | sp_list_node *sp_list_prepend(sp_list_node *, void *); | 13 | sp_list_node *sp_list_prepend(sp_list_node *, void *); |
| 14 | void sp_list_free(sp_list_node *); | 14 | void sp_list_free(sp_list_node *, void (*free_data_func)(void *data)); |
| 15 | void sp_list_free2(sp_list_node *node); | ||
| 16 | size_t sp_list_len(sp_list_node *p); | ||
| 15 | 17 | ||
| 16 | #endif | 18 | #endif |
diff --git a/src/sp_network_utils.c b/src/sp_network_utils.c index 31e8426..943c418 100644 --- a/src/sp_network_utils.c +++ b/src/sp_network_utils.c | |||
| @@ -85,16 +85,17 @@ int get_ip_and_cidr(char *ip, sp_cidr *cidr) { | |||
| 85 | char *mask = strchr(ip, '/'); | 85 | char *mask = strchr(ip, '/'); |
| 86 | 86 | ||
| 87 | if (NULL == mask) { | 87 | if (NULL == mask) { |
| 88 | sp_log_err( | 88 | sp_log_err("config", "'%s' isn't a valid network mask, it seems that you forgot a '/'.", ip); |
| 89 | "config", | ||
| 90 | "'%s' isn't a valid network mask, it seems that you forgot a '/'.", ip); | ||
| 91 | return -1; | 89 | return -1; |
| 92 | } | 90 | } |
| 93 | 91 | ||
| 94 | if (sscanf(mask + 1, "%hhu", &(cidr->mask)) != 1) { | 92 | int masklen = strlen(mask+1); |
| 93 | int imask = atoi(mask+1); | ||
| 94 | if (masklen < 1 || masklen > 3 || !isdigit(*(mask+1)) || (masklen >= 2 && !isdigit(*(mask+2))) || (masklen == 3 && !isdigit(*(mask+3))) || imask < 0 || imask > 128) { | ||
| 95 | sp_log_err("config", "'%s' isn't a valid network mask.", mask + 1); | 95 | sp_log_err("config", "'%s' isn't a valid network mask.", mask + 1); |
| 96 | return -1; | 96 | return -1; |
| 97 | } | 97 | } |
| 98 | cidr->mask = (uint8_t)imask; | ||
| 98 | 99 | ||
| 99 | ip[mask - ip] = '\0'; // NULL the '/' char | 100 | ip[mask - ip] = '\0'; // NULL the '/' char |
| 100 | 101 | ||
| @@ -113,5 +114,37 @@ int get_ip_and_cidr(char *ip, sp_cidr *cidr) { | |||
| 113 | } | 114 | } |
| 114 | 115 | ||
| 115 | ip[mask - ip] = '/'; | 116 | ip[mask - ip] = '/'; |
| 117 | if (cidr->ip_version < 0) { | ||
| 118 | sp_log_err("config", "Weird ip (%s) family", ip); | ||
| 119 | return -1; | ||
| 120 | } | ||
| 121 | |||
| 116 | return 0; | 122 | return 0; |
| 117 | } | 123 | } |
| 124 | |||
| 125 | bool /* success */ get_ip_str(char *dst, size_t dst_len, sp_cidr *cidr) { | ||
| 126 | size_t ipstr_len = 0; | ||
| 127 | void *ip = NULL; | ||
| 128 | switch (cidr->ip_version) { | ||
| 129 | case AF_INET: | ||
| 130 | ipstr_len = INET_ADDRSTRLEN; | ||
| 131 | ip = &cidr->ip.ipv4; | ||
| 132 | break; | ||
| 133 | case AF_INET6: | ||
| 134 | ipstr_len = INET6_ADDRSTRLEN; | ||
| 135 | ip = &cidr->ip.ipv6; | ||
| 136 | break; | ||
| 137 | default: | ||
| 138 | return false; | ||
| 139 | } | ||
| 140 | |||
| 141 | if (dst_len < ipstr_len + 1 + 3 + 1) { | ||
| 142 | return false; | ||
| 143 | } | ||
| 144 | if (!inet_ntop(cidr->ip_version, ip, dst, ipstr_len)) { | ||
| 145 | return false; | ||
| 146 | } | ||
| 147 | ipstr_len = strlen(dst); | ||
| 148 | snprintf(dst + ipstr_len, dst_len - ipstr_len, "/%d", cidr->mask); | ||
| 149 | return true; | ||
| 150 | } \ No newline at end of file | ||
diff --git a/src/sp_network_utils.h b/src/sp_network_utils.h index 2c1062a..69789a6 100644 --- a/src/sp_network_utils.h +++ b/src/sp_network_utils.h | |||
| @@ -3,5 +3,6 @@ | |||
| 3 | 3 | ||
| 4 | int get_ip_and_cidr(char *, sp_cidr *); | 4 | int get_ip_and_cidr(char *, sp_cidr *); |
| 5 | bool cidr_match(const char *, const sp_cidr *); | 5 | bool cidr_match(const char *, const sp_cidr *); |
| 6 | bool /* success */ get_ip_str(char *dst, size_t dst_len, sp_cidr *cidr); | ||
| 6 | 7 | ||
| 7 | #endif /*SP_NETWORK_UTILS_H*/ | 8 | #endif /*SP_NETWORK_UTILS_H*/ |
diff --git a/src/sp_pcre_compat.c b/src/sp_pcre_compat.c index 203fb7a..81c51fd 100644 --- a/src/sp_pcre_compat.c +++ b/src/sp_pcre_compat.c | |||
| @@ -1,13 +1,5 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | inline void sp_pcre_free(sp_pcre* regexp) { | ||
| 4 | #ifdef SP_HAS_PCRE2 | ||
| 5 | pcre2_code_free(regexp); | ||
| 6 | regexp = NULL; | ||
| 7 | #else | ||
| 8 | (void)regexp; | ||
| 9 | #endif | ||
| 10 | } | ||
| 11 | 3 | ||
| 12 | sp_pcre* sp_pcre_compile(const char* const pattern) { | 4 | sp_pcre* sp_pcre_compile(const char* const pattern) { |
| 13 | assert(NULL != pattern); | 5 | assert(NULL != pattern); |
| @@ -17,9 +9,8 @@ sp_pcre* sp_pcre_compile(const char* const pattern) { | |||
| 17 | unsigned char pcre_error[128] = {0}; | 9 | unsigned char pcre_error[128] = {0}; |
| 18 | int errornumber; | 10 | int errornumber; |
| 19 | PCRE2_SIZE erroroffset; | 11 | PCRE2_SIZE erroroffset; |
| 20 | ret = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, | 12 | ret = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, PCRE2_CASELESS, &errornumber, &erroroffset, NULL); |
| 21 | PCRE2_CASELESS, &errornumber, &erroroffset, NULL); | 13 | pcre2_get_error_message(errornumber, pcre_error, sizeof(pcre_error)-1); |
| 22 | pcre2_get_error_message(errornumber, pcre_error, sizeof(pcre_error)); | ||
| 23 | #else | 14 | #else |
| 24 | const char* pcre_error = NULL; | 15 | const char* pcre_error = NULL; |
| 25 | int erroroffset; | 16 | int erroroffset; |
| @@ -27,29 +18,26 @@ sp_pcre* sp_pcre_compile(const char* const pattern) { | |||
| 27 | #endif | 18 | #endif |
| 28 | 19 | ||
| 29 | if (NULL == ret) { | 20 | if (NULL == ret) { |
| 30 | sp_log_err("config", "Failed to compile '%s': %s on line %zu.", pattern, | 21 | sp_log_err("config", "Failed to compile '%s': %s.", pattern, pcre_error); |
| 31 | pcre_error, sp_line_no); | ||
| 32 | } | 22 | } |
| 33 | return ret; | 23 | return ret; |
| 34 | } | 24 | } |
| 35 | 25 | ||
| 36 | bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, | 26 | bool ZEND_HOT sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len) { |
| 37 | size_t len) { | ||
| 38 | int ret = 0; | 27 | int ret = 0; |
| 39 | 28 | ||
| 40 | assert(NULL != regexp); | 29 | assert(NULL != regexp); |
| 41 | assert(NULL != str); | 30 | assert(NULL != str); |
| 42 | 31 | ||
| 43 | #ifdef SP_HAS_PCRE2 | 32 | #ifdef SP_HAS_PCRE2 |
| 44 | pcre2_match_data* match_data = | 33 | pcre2_match_data* match_data = pcre2_match_data_create_from_pattern(regexp, NULL); |
| 45 | pcre2_match_data_create_from_pattern(regexp, NULL); | ||
| 46 | if (NULL == match_data) { | 34 | if (NULL == match_data) { |
| 47 | sp_log_err("regexp", "Unable to get memory for a regxp."); | 35 | sp_log_err("regexp", "Unable to get memory for a regxp."); |
| 48 | } | 36 | } |
| 49 | ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); | 37 | ret = pcre2_match(regexp, (PCRE2_SPTR)str, len, 0, 0, match_data, NULL); |
| 50 | pcre2_match_data_free(match_data); | 38 | pcre2_match_data_free(match_data); |
| 51 | #else | 39 | #else |
| 52 | int vec[30]; | 40 | int vec[30] = {0}; |
| 53 | ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, sizeof(vec) / sizeof(int)); | 41 | ret = pcre_exec(regexp, NULL, str, len, 0, 0, vec, sizeof(vec) / sizeof(int)); |
| 54 | #endif | 42 | #endif |
| 55 | 43 | ||
diff --git a/src/sp_pcre_compat.h b/src/sp_pcre_compat.h index 725004d..6e9d91a 100644 --- a/src/sp_pcre_compat.h +++ b/src/sp_pcre_compat.h | |||
| @@ -17,12 +17,36 @@ | |||
| 17 | #endif | 17 | #endif |
| 18 | 18 | ||
| 19 | sp_pcre* sp_pcre_compile(const char* str); | 19 | sp_pcre* sp_pcre_compile(const char* str); |
| 20 | void sp_pcre_free(sp_pcre* regexp); | 20 | static inline void sp_pcre_free(sp_pcre* regexp) { |
| 21 | #define sp_is_regexp_matching_zend(regexp, zstr) \ | 21 | #ifdef SP_HAS_PCRE2 |
| 22 | sp_is_regexp_matching_len(regexp, ZSTR_VAL(zstr), ZSTR_LEN(zstr)) | 22 | pcre2_code_free(regexp); |
| 23 | #define sp_is_regexp_matching(regexp, str) \ | 23 | #endif |
| 24 | sp_is_regexp_matching_len(regexp, str, strlen(str)) | 24 | } |
| 25 | bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, | 25 | bool sp_is_regexp_matching_len(const sp_pcre* regexp, const char* str, size_t len); |
| 26 | size_t len); | 26 | |
| 27 | |||
| 28 | typedef struct { | ||
| 29 | sp_pcre *re; | ||
| 30 | zend_string *pattern; | ||
| 31 | } sp_regexp; | ||
| 32 | |||
| 33 | #define sp_is_regexp_matching_zstr(regexp, zstr) sp_is_regexp_matching_len(regexp->re, ZSTR_VAL(zstr), ZSTR_LEN(zstr)) | ||
| 34 | #define sp_is_regexp_matching(regexp, str) sp_is_regexp_matching_len(regexp->re, str, strlen(str)) | ||
| 35 | static inline sp_regexp* sp_regexp_compile(zend_string *zstr) { | ||
| 36 | sp_pcre *re = sp_pcre_compile(ZSTR_VAL(zstr)); | ||
| 37 | if (!re) { return NULL; } | ||
| 38 | sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1); | ||
| 39 | ret->re = re; | ||
| 40 | ret->pattern = zstr; | ||
| 41 | return ret; | ||
| 42 | } | ||
| 43 | static inline void sp_regexp_free(sp_regexp *regexp) { | ||
| 44 | if (regexp) { | ||
| 45 | if (regexp->re) { sp_pcre_free(regexp->re); } | ||
| 46 | if (regexp->pattern) { zend_string_release(regexp->pattern); } | ||
| 47 | pefree(regexp, 1); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 27 | 51 | ||
| 28 | #endif // SP_PCRE_COMPAT_H | 52 | #endif // SP_PCRE_COMPAT_H |
diff --git a/src/sp_php_compat.c b/src/sp_php_compat.c new file mode 100644 index 0000000..a0693c3 --- /dev/null +++ b/src/sp_php_compat.c | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | #include "php_snuffleupagus.h" | ||
| 2 | |||
| 3 | /* code in this file is licensed under its original license | ||
| 4 | The PHP License, version 3.01 (https://www.php.net/license/3_01.txt) | ||
| 5 | which is also included with these sources in the file `PHP_LICENSE` */ | ||
| 6 | |||
| 7 | #if PHP_VERSION_ID < 80000 | ||
| 8 | |||
| 9 | // copied from PHP 8.0.9 sources | ||
| 10 | |||
| 11 | ZEND_API zend_string *zend_string_concat2( | ||
| 12 | const char *str1, size_t str1_len, | ||
| 13 | const char *str2, size_t str2_len) | ||
| 14 | { | ||
| 15 | size_t len = str1_len + str2_len; | ||
| 16 | zend_string *res = zend_string_alloc(len, 0); | ||
| 17 | |||
| 18 | memcpy(ZSTR_VAL(res), str1, str1_len); | ||
| 19 | memcpy(ZSTR_VAL(res) + str1_len, str2, str2_len); | ||
| 20 | ZSTR_VAL(res)[len] = '\0'; | ||
| 21 | |||
| 22 | return res; | ||
| 23 | } | ||
| 24 | |||
| 25 | #endif | ||
diff --git a/src/sp_php_compat.h b/src/sp_php_compat.h new file mode 100644 index 0000000..04914b4 --- /dev/null +++ b/src/sp_php_compat.h | |||
| @@ -0,0 +1,139 @@ | |||
| 1 | /* code in this file is licensed under its original license | ||
| 2 | The PHP License, version 3.01 (https://www.php.net/license/3_01.txt) | ||
| 3 | which is also included with these sources in the file `PHP_LICENSE` */ | ||
| 4 | |||
| 5 | #if PHP_VERSION_ID < 80000 | ||
| 6 | |||
| 7 | // copied from PHP 8.0.9 sources | ||
| 8 | ZEND_API zend_string *zend_string_concat2( | ||
| 9 | const char *str1, size_t str1_len, | ||
| 10 | const char *str2, size_t str2_len); | ||
| 11 | |||
| 12 | #define ZEND_HASH_REVERSE_FOREACH_KEY_PTR(ht, _h, _key, _ptr) \ | ||
| 13 | ZEND_HASH_REVERSE_FOREACH(ht, 0); \ | ||
| 14 | _h = _p->h; \ | ||
| 15 | _key = _p->key; \ | ||
| 16 | _ptr = Z_PTR_P(_z); | ||
| 17 | |||
| 18 | // zend_result was introduced to replace ZEND_RESULT_CODE with PHP8 | ||
| 19 | typedef ZEND_RESULT_CODE zend_result; | ||
| 20 | |||
| 21 | #endif | ||
| 22 | |||
| 23 | #if PHP_VERSION_ID < 70300 | ||
| 24 | |||
| 25 | // copied from PHP 7.4.22 sources | ||
| 26 | |||
| 27 | static zend_always_inline uint32_t zend_gc_delref(zend_refcounted_h *p) { | ||
| 28 | ZEND_ASSERT(p->refcount > 0); | ||
| 29 | // ZEND_RC_MOD_CHECK(p); | ||
| 30 | return --(p->refcount); | ||
| 31 | } | ||
| 32 | #define GC_DELREF(p) zend_gc_delref(&(p)->gc) | ||
| 33 | |||
| 34 | static zend_always_inline void zend_string_release_ex(zend_string *s, int persistent) | ||
| 35 | { | ||
| 36 | if (!ZSTR_IS_INTERNED(s)) { | ||
| 37 | if (GC_DELREF(s) == 0) { | ||
| 38 | if (persistent) { | ||
| 39 | ZEND_ASSERT(GC_FLAGS(s) & IS_STR_PERSISTENT); | ||
| 40 | free(s); | ||
| 41 | } else { | ||
| 42 | ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT)); | ||
| 43 | efree(s); | ||
| 44 | } | ||
| 45 | } | ||
| 46 | } | ||
| 47 | } | ||
| 48 | |||
| 49 | static zend_always_inline void zend_string_efree(zend_string *s) | ||
| 50 | { | ||
| 51 | ZEND_ASSERT(!ZSTR_IS_INTERNED(s)); | ||
| 52 | ZEND_ASSERT(GC_REFCOUNT(s) <= 1); | ||
| 53 | ZEND_ASSERT(!(GC_FLAGS(s) & IS_STR_PERSISTENT)); | ||
| 54 | efree(s); | ||
| 55 | } | ||
| 56 | |||
| 57 | #endif | ||
| 58 | |||
| 59 | #if PHP_VERSION_ID < 70200 | ||
| 60 | |||
| 61 | #undef ZEND_HASH_REVERSE_FOREACH | ||
| 62 | |||
| 63 | // copied from PHP 7.4.22 sources | ||
| 64 | |||
| 65 | #define ZEND_HASH_REVERSE_FOREACH(_ht, indirect) do { \ | ||
| 66 | HashTable *__ht = (_ht); \ | ||
| 67 | uint32_t _idx = __ht->nNumUsed; \ | ||
| 68 | Bucket *_p = __ht->arData + _idx; \ | ||
| 69 | zval *_z; \ | ||
| 70 | for (_idx = __ht->nNumUsed; _idx > 0; _idx--) { \ | ||
| 71 | _p--; \ | ||
| 72 | _z = &_p->val; \ | ||
| 73 | if (indirect && Z_TYPE_P(_z) == IS_INDIRECT) { \ | ||
| 74 | _z = Z_INDIRECT_P(_z); \ | ||
| 75 | } \ | ||
| 76 | if (UNEXPECTED(Z_TYPE_P(_z) == IS_UNDEF)) continue; | ||
| 77 | |||
| 78 | |||
| 79 | #define ZEND_HASH_FOREACH_END_DEL() \ | ||
| 80 | __ht->nNumOfElements--; \ | ||
| 81 | do { \ | ||
| 82 | uint32_t j = HT_IDX_TO_HASH(_idx - 1); \ | ||
| 83 | uint32_t nIndex = _p->h | __ht->nTableMask; \ | ||
| 84 | uint32_t i = HT_HASH(__ht, nIndex); \ | ||
| 85 | if (UNEXPECTED(j != i)) { \ | ||
| 86 | Bucket *prev = HT_HASH_TO_BUCKET(__ht, i); \ | ||
| 87 | while (Z_NEXT(prev->val) != j) { \ | ||
| 88 | i = Z_NEXT(prev->val); \ | ||
| 89 | prev = HT_HASH_TO_BUCKET(__ht, i); \ | ||
| 90 | } \ | ||
| 91 | Z_NEXT(prev->val) = Z_NEXT(_p->val); \ | ||
| 92 | } else { \ | ||
| 93 | HT_HASH(__ht, nIndex) = Z_NEXT(_p->val); \ | ||
| 94 | } \ | ||
| 95 | } while (0); \ | ||
| 96 | } \ | ||
| 97 | __ht->nNumUsed = _idx; \ | ||
| 98 | } while (0) | ||
| 99 | |||
| 100 | #endif | ||
| 101 | |||
| 102 | // copied from PHP 8.0.11 sources, ext/hash/hash.c | ||
| 103 | // slightly modified for PHP 8.1 compatibility | ||
| 104 | |||
| 105 | static inline void php_hash_string_xor_char(unsigned char *out, const unsigned char *in, const unsigned char xor_with, const size_t length) { | ||
| 106 | size_t i; | ||
| 107 | for (i=0; i < length; i++) { | ||
| 108 | out[i] = in[i] ^ xor_with; | ||
| 109 | } | ||
| 110 | } | ||
| 111 | |||
| 112 | static inline void php_hash_hmac_prep_key(unsigned char *K, const php_hash_ops *ops, void *context, const unsigned char *key, const size_t key_len) { | ||
| 113 | memset(K, 0, ops->block_size); | ||
| 114 | if (key_len > ops->block_size) { | ||
| 115 | /* Reduce the key first */ | ||
| 116 | #if PHP_VERSION_ID < 80100 | ||
| 117 | ops->hash_init(context); | ||
| 118 | #else | ||
| 119 | ops->hash_init(context, NULL); | ||
| 120 | #endif | ||
| 121 | ops->hash_update(context, key, key_len); | ||
| 122 | ops->hash_final(K, context); | ||
| 123 | } else { | ||
| 124 | memcpy(K, key, key_len); | ||
| 125 | } | ||
| 126 | /* XOR the key with 0x36 to get the ipad) */ | ||
| 127 | php_hash_string_xor_char(K, K, 0x36, ops->block_size); | ||
| 128 | } | ||
| 129 | |||
| 130 | static inline void php_hash_hmac_round(unsigned char *final, const php_hash_ops *ops, void *context, const unsigned char *key, const unsigned char *data, const zend_long data_size) { | ||
| 131 | #if PHP_VERSION_ID < 80100 | ||
| 132 | ops->hash_init(context); | ||
| 133 | #else | ||
| 134 | ops->hash_init(context, NULL); | ||
| 135 | #endif | ||
| 136 | ops->hash_update(context, key, ops->block_size); | ||
| 137 | ops->hash_update(context, data, data_size); | ||
| 138 | ops->hash_final(final, context); | ||
| 139 | } | ||
diff --git a/src/sp_session.c b/src/sp_session.c index b2f4a43..6335838 100644 --- a/src/sp_session.c +++ b/src/sp_session.c | |||
| @@ -1,7 +1,5 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | #if (HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION)) | ||
| 4 | |||
| 5 | #ifdef ZTS | 3 | #ifdef ZTS |
| 6 | static ts_rsrc_id session_globals_id = 0; | 4 | static ts_rsrc_id session_globals_id = 0; |
| 7 | #define SESSION_G(v) ZEND_TSRMG(session_globals_id, php_ps_globals *, v) | 5 | #define SESSION_G(v) ZEND_TSRMG(session_globals_id, php_ps_globals *, v) |
| @@ -10,7 +8,7 @@ ZEND_TSRMLS_CACHE_EXTERN(); | |||
| 10 | #endif | 8 | #endif |
| 11 | #else | 9 | #else |
| 12 | static php_ps_globals *session_globals = NULL; | 10 | static php_ps_globals *session_globals = NULL; |
| 13 | #define SESSION_G(v) (ps_globals.v) | 11 | #define SESSION_G(v) (session_globals->v) |
| 14 | #endif | 12 | #endif |
| 15 | 13 | ||
| 16 | static ps_module *s_module; | 14 | static ps_module *s_module; |
| @@ -24,21 +22,35 @@ static int (*old_s_write)(PS_WRITE_ARGS); | |||
| 24 | static int (*previous_sessionRINIT)(INIT_FUNC_ARGS) = NULL; | 22 | static int (*previous_sessionRINIT)(INIT_FUNC_ARGS) = NULL; |
| 25 | static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL; | 23 | static ZEND_INI_MH((*old_OnUpdateSaveHandler)) = NULL; |
| 26 | 24 | ||
| 25 | static void check_sid_length(zend_string *sid) { | ||
| 26 | const sp_config_session *cfg = &(SPCFG(session)); | ||
| 27 | |||
| 28 | if (sid) { | ||
| 29 | if (cfg->sid_min_length && ZSTR_LEN(sid) < cfg->sid_min_length) { | ||
| 30 | sp_log_auto("session", cfg->simulation, "Session ID is too short"); | ||
| 31 | } | ||
| 32 | if (cfg->sid_max_length && ZSTR_LEN(sid) > cfg->sid_max_length) { | ||
| 33 | sp_log_auto("session", cfg->simulation, "Session ID is too long"); | ||
| 34 | } | ||
| 35 | } | ||
| 36 | } | ||
| 37 | |||
| 27 | static int sp_hook_s_read(PS_READ_ARGS) { | 38 | static int sp_hook_s_read(PS_READ_ARGS) { |
| 39 | const sp_config_session *cfg = &(SPCFG(session)); | ||
| 40 | check_sid_length(key); | ||
| 41 | |||
| 28 | int r = old_s_read(mod_data, key, val, maxlifetime); | 42 | int r = old_s_read(mod_data, key, val, maxlifetime); |
| 29 | const sp_config_session *config_session = | ||
| 30 | SNUFFLEUPAGUS_G(config).config_session; | ||
| 31 | 43 | ||
| 32 | if ((NULL == val) || (NULL == *val) || (0 == ZSTR_LEN(*val))) { | 44 | if ((NULL == val) || (NULL == *val) || (0 == ZSTR_LEN(*val))) { |
| 33 | return r; | 45 | return r; |
| 34 | } | 46 | } |
| 35 | 47 | ||
| 36 | if (r == SUCCESS && config_session->encrypt) { | 48 | if (r == SUCCESS && cfg->encrypt) { |
| 37 | zend_string *orig_val = *val; | 49 | zend_string *orig_val = *val; |
| 38 | zval val_zval; | 50 | zval val_zval; |
| 39 | ZVAL_PSTRINGL(&val_zval, ZSTR_VAL(*val), ZSTR_LEN(*val)); | 51 | ZVAL_PSTRINGL(&val_zval, ZSTR_VAL(*val), ZSTR_LEN(*val)); |
| 40 | 52 | ||
| 41 | int ret = decrypt_zval(&val_zval, config_session->simulation, NULL); | 53 | int ret = decrypt_zval(&val_zval, cfg->simulation, NULL); |
| 42 | if (ZEND_HASH_APPLY_KEEP != ret) { | 54 | if (ZEND_HASH_APPLY_KEEP != ret) { |
| 43 | zend_bailout(); | 55 | zend_bailout(); |
| 44 | } | 56 | } |
| @@ -51,7 +63,10 @@ static int sp_hook_s_read(PS_READ_ARGS) { | |||
| 51 | } | 63 | } |
| 52 | 64 | ||
| 53 | static int sp_hook_s_write(PS_WRITE_ARGS) { | 65 | static int sp_hook_s_write(PS_WRITE_ARGS) { |
| 54 | if (ZSTR_LEN(val) > 0 && SNUFFLEUPAGUS_G(config).config_session->encrypt) { | 66 | const sp_config_session *cfg = &(SPCFG(session)); |
| 67 | check_sid_length(key); | ||
| 68 | |||
| 69 | if (ZSTR_LEN(val) > 0 && cfg->encrypt) { | ||
| 55 | zend_string *new_val = encrypt_zval(val); | 70 | zend_string *new_val = encrypt_zval(val); |
| 56 | return old_s_write(mod_data, key, new_val, maxlifetime); | 71 | return old_s_write(mod_data, key, new_val, maxlifetime); |
| 57 | } | 72 | } |
| @@ -104,8 +119,7 @@ static PHP_INI_MH(sp_OnUpdateSaveHandler) { | |||
| 104 | 119 | ||
| 105 | SESSION_G(mod) = s_original_mod; | 120 | SESSION_G(mod) = s_original_mod; |
| 106 | 121 | ||
| 107 | int r = old_OnUpdateSaveHandler(entry, new_value, mh_arg1, mh_arg2, mh_arg3, | 122 | int r = old_OnUpdateSaveHandler(entry, new_value, mh_arg1, mh_arg2, mh_arg3, stage); |
| 108 | stage); | ||
| 109 | 123 | ||
| 110 | sp_hook_session_module(); | 124 | sp_hook_session_module(); |
| 111 | 125 | ||
| @@ -113,23 +127,16 @@ static PHP_INI_MH(sp_OnUpdateSaveHandler) { | |||
| 113 | } | 127 | } |
| 114 | 128 | ||
| 115 | static int sp_hook_session_RINIT(INIT_FUNC_ARGS) { | 129 | static int sp_hook_session_RINIT(INIT_FUNC_ARGS) { |
| 116 | if (SESSION_G(mod) == NULL) { | 130 | int ret = previous_sessionRINIT(INIT_FUNC_ARGS_PASSTHRU); |
| 117 | zend_ini_entry *ini_entry; | 131 | sp_hook_session_module(); |
| 118 | if ((ini_entry = zend_hash_str_find_ptr( | 132 | return ret; |
| 119 | EG(ini_directives), ZEND_STRL("session.save_handler")))) { | ||
| 120 | if (ini_entry && ini_entry->value) { | ||
| 121 | sp_OnUpdateSaveHandler(NULL, ini_entry->value, NULL, NULL, NULL, 0); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | } | ||
| 125 | return previous_sessionRINIT(INIT_FUNC_ARGS_PASSTHRU); | ||
| 126 | } | 133 | } |
| 127 | 134 | ||
| 128 | void hook_session() { | 135 | void hook_session() { |
| 129 | zend_module_entry *module; | 136 | zend_module_entry *module; |
| 130 | 137 | ||
| 131 | if ((module = zend_hash_str_find_ptr(&module_registry, | 138 | if ((module = zend_hash_str_find_ptr(&module_registry, ZEND_STRL("session"))) == NULL) { |
| 132 | ZEND_STRL("session"))) == NULL) { | 139 | sp_log_err("session", "You are trying to use session encryption or session ID restrictions, but your PHP installation has no session support. Please install the PHP session module or recompile PHP with session support."); |
| 133 | return; // LCOV_EXCL_LINE | 140 | return; // LCOV_EXCL_LINE |
| 134 | } | 141 | } |
| 135 | 142 | ||
| @@ -150,8 +157,7 @@ void hook_session() { | |||
| 150 | module->request_startup_func = sp_hook_session_RINIT; | 157 | module->request_startup_func = sp_hook_session_RINIT; |
| 151 | 158 | ||
| 152 | zend_ini_entry *ini_entry; | 159 | zend_ini_entry *ini_entry; |
| 153 | if ((ini_entry = zend_hash_str_find_ptr( | 160 | if ((ini_entry = zend_hash_str_find_ptr(EG(ini_directives), ZEND_STRL("session.save_handler"))) != NULL) { |
| 154 | EG(ini_directives), ZEND_STRL("session.save_handler"))) != NULL) { | ||
| 155 | old_OnUpdateSaveHandler = ini_entry->on_modify; | 161 | old_OnUpdateSaveHandler = ini_entry->on_modify; |
| 156 | ini_entry->on_modify = sp_OnUpdateSaveHandler; | 162 | ini_entry->on_modify = sp_OnUpdateSaveHandler; |
| 157 | } | 163 | } |
| @@ -159,9 +165,3 @@ void hook_session() { | |||
| 159 | 165 | ||
| 160 | sp_hook_session_module(); | 166 | sp_hook_session_module(); |
| 161 | } | 167 | } |
| 162 | |||
| 163 | #else | ||
| 164 | |||
| 165 | void hook_session() {} | ||
| 166 | |||
| 167 | #endif // HAVE_PHP_SESSION && !defined(COMPILE_DL_SESSION) | ||
diff --git a/src/sp_sloppy.c b/src/sp_sloppy.c index ff2d644..fca4be5 100644 --- a/src/sp_sloppy.c +++ b/src/sp_sloppy.c | |||
| @@ -48,7 +48,7 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, | |||
| 48 | const char* spec) { | 48 | const char* spec) { |
| 49 | zif_handler handler; | 49 | zif_handler handler; |
| 50 | zval func_name; | 50 | zval func_name; |
| 51 | zval params[3]; | 51 | zval params[3] = {0}; |
| 52 | zval *value, *array = NULL; | 52 | zval *value, *array = NULL; |
| 53 | zend_bool strict = 0; | 53 | zend_bool strict = 0; |
| 54 | uint32_t nb_params = ZEND_NUM_ARGS(); | 54 | uint32_t nb_params = ZEND_NUM_ARGS(); |
| @@ -69,7 +69,7 @@ static void array_handler(INTERNAL_FUNCTION_PARAMETERS, const char* name, | |||
| 69 | 69 | ||
| 70 | ZVAL_STRING(&func_name, name); | 70 | ZVAL_STRING(&func_name, name); |
| 71 | 71 | ||
| 72 | handler = zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), | 72 | handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), |
| 73 | name, size); | 73 | name, size); |
| 74 | zend_internal_function* func = | 74 | zend_internal_function* func = |
| 75 | zend_hash_str_find_ptr(CG(function_table), name, size); | 75 | zend_hash_str_find_ptr(CG(function_table), name, size); |
diff --git a/src/sp_unserialize.c b/src/sp_unserialize.c index 8977dd9..c2173d3 100644 --- a/src/sp_unserialize.c +++ b/src/sp_unserialize.c | |||
| @@ -1,28 +1,70 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | // condensed version of PHP's php_hash_do_hash_hmac() in ext/hash/hash.c | ||
| 4 | #if PHP_VERSION_ID < 80000 | ||
| 5 | static inline void *php_hash_alloc_context(const php_hash_ops *ops) { | ||
| 6 | /* Zero out context memory so serialization doesn't expose internals */ | ||
| 7 | return ecalloc(1, ops->context_size); | ||
| 8 | } | ||
| 9 | #endif | ||
| 10 | |||
| 11 | static zend_string *sp_do_hash_hmac_sha256(char *data, size_t data_len, char *key, size_t key_len) | ||
| 12 | { | ||
| 13 | #if PHP_VERSION_ID < 80000 | ||
| 14 | const php_hash_ops *ops = php_hash_fetch_ops(ZEND_STRL("sha256")); | ||
| 15 | #else | ||
| 16 | zend_string *algo = zend_string_init(ZEND_STRL("sha256"), 0); | ||
| 17 | const php_hash_ops *ops = php_hash_fetch_ops(algo); | ||
| 18 | zend_string_release_ex(algo, 0); | ||
| 19 | #endif | ||
| 20 | |||
| 21 | if (!ops || !ops->is_crypto) { | ||
| 22 | sp_log_err("hmac", "unsupported hash algorithm: sha256"); | ||
| 23 | return NULL; | ||
| 24 | } | ||
| 25 | |||
| 26 | void *context = php_hash_alloc_context(ops); | ||
| 27 | |||
| 28 | unsigned char *K = emalloc(ops->block_size); | ||
| 29 | zend_string *digest = zend_string_alloc(ops->digest_size, 0); | ||
| 30 | |||
| 31 | php_hash_hmac_prep_key(K, ops, context, (unsigned char *) key, key_len); | ||
| 32 | php_hash_hmac_round((unsigned char *) ZSTR_VAL(digest), ops, context, K, (unsigned char *) data, data_len); | ||
| 33 | php_hash_string_xor_char(K, K, 0x6A, ops->block_size); | ||
| 34 | php_hash_hmac_round((unsigned char *) ZSTR_VAL(digest), ops, context, K, (unsigned char *) ZSTR_VAL(digest), ops->digest_size); | ||
| 35 | |||
| 36 | /* Zero the key */ | ||
| 37 | ZEND_SECURE_ZERO(K, ops->block_size); | ||
| 38 | efree(K); | ||
| 39 | efree(context); | ||
| 40 | |||
| 41 | zend_string *hex_digest = zend_string_safe_alloc(ops->digest_size, 2, 0, 0); | ||
| 42 | |||
| 43 | php_hash_bin2hex(ZSTR_VAL(hex_digest), (unsigned char *) ZSTR_VAL(digest), ops->digest_size); | ||
| 44 | ZSTR_VAL(hex_digest)[2 * ops->digest_size] = 0; | ||
| 45 | zend_string_release_ex(digest, 0); | ||
| 46 | return hex_digest; | ||
| 47 | } | ||
| 48 | |||
| 49 | // ------------------ | ||
| 50 | |||
| 3 | PHP_FUNCTION(sp_serialize) { | 51 | PHP_FUNCTION(sp_serialize) { |
| 4 | zif_handler orig_handler; | 52 | zif_handler orig_handler; |
| 5 | 53 | ||
| 6 | /* Call the original `serialize` function. */ | 54 | /* Call the original `serialize` function. */ |
| 7 | orig_handler = | 55 | orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("serialize")); |
| 8 | zend_hash_str_find_ptr(SNUFFLEUPAGUS_G(sp_internal_functions_hook), | 56 | if (orig_handler) { |
| 9 | "serialize", sizeof("serialize") - 1); | 57 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 10 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 58 | } |
| 11 | 59 | ||
| 12 | /* Compute the HMAC of the textual representation of the serialized data*/ | 60 | /* Compute the HMAC of the textual representation of the serialized data*/ |
| 13 | zval func_name; | 61 | zend_string *hmac = sp_do_hash_hmac_sha256(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), ZSTR_VAL(SPCFG(encryption_key)), ZSTR_LEN(SPCFG(encryption_key))); |
| 14 | zval hmac; | ||
| 15 | zval params[3]; | ||
| 16 | 62 | ||
| 17 | ZVAL_STRING(&func_name, "hash_hmac"); | 63 | if (!hmac) { |
| 18 | ZVAL_STRING(¶ms[0], "sha256"); | 64 | zend_bailout(); |
| 19 | params[1] = *return_value; | 65 | } |
| 20 | ZVAL_STRING( | ||
| 21 | ¶ms[2], | ||
| 22 | ZSTR_VAL(SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)); | ||
| 23 | call_user_function(CG(function_table), NULL, &func_name, &hmac, 3, params); | ||
| 24 | 66 | ||
| 25 | size_t len = Z_STRLEN_P(return_value) + Z_STRLEN(hmac); | 67 | size_t len = Z_STRLEN_P(return_value) + ZSTR_LEN(hmac); |
| 26 | if (len < Z_STRLEN_P(return_value)) { | 68 | if (len < Z_STRLEN_P(return_value)) { |
| 27 | // LCOV_EXCL_START | 69 | // LCOV_EXCL_START |
| 28 | sp_log_err("overflow_error", | 70 | sp_log_err("overflow_error", |
| @@ -30,15 +72,11 @@ PHP_FUNCTION(sp_serialize) { | |||
| 30 | zend_bailout(); | 72 | zend_bailout(); |
| 31 | // LCOV_EXCL_STOP | 73 | // LCOV_EXCL_STOP |
| 32 | } | 74 | } |
| 33 | zend_string *res = zend_string_alloc(len, 0); | ||
| 34 | |||
| 35 | memcpy(ZSTR_VAL(res), Z_STRVAL_P(return_value), Z_STRLEN_P(return_value)); | ||
| 36 | memcpy(ZSTR_VAL(res) + Z_STRLEN_P(return_value), Z_STRVAL(hmac), | ||
| 37 | Z_STRLEN(hmac)); | ||
| 38 | 75 | ||
| 39 | /* Append the computed HMAC to the serialized data. */ | 76 | /* Append the computed HMAC to the serialized data. */ |
| 40 | return_value->value.str = res; | 77 | zend_string *orig_ret_str = return_value->value.str; |
| 41 | return; | 78 | RETVAL_NEW_STR(zend_string_concat2(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), ZSTR_VAL(hmac), ZSTR_LEN(hmac))); |
| 79 | zend_string_free(orig_ret_str); | ||
| 42 | } | 80 | } |
| 43 | 81 | ||
| 44 | PHP_FUNCTION(sp_unserialize) { | 82 | PHP_FUNCTION(sp_unserialize) { |
| @@ -47,12 +85,10 @@ PHP_FUNCTION(sp_unserialize) { | |||
| 47 | char *buf = NULL; | 85 | char *buf = NULL; |
| 48 | char *serialized_str = NULL; | 86 | char *serialized_str = NULL; |
| 49 | char *hmac = NULL; | 87 | char *hmac = NULL; |
| 50 | zval expected_hmac; | ||
| 51 | size_t buf_len = 0; | 88 | size_t buf_len = 0; |
| 52 | zval *opts = NULL; | 89 | zval *opts = NULL; |
| 53 | 90 | ||
| 54 | const sp_config_unserialize *config_unserialize = | 91 | const sp_config_unserialize *config_unserialize = &(SPCFG(unserialize)); |
| 55 | SNUFFLEUPAGUS_G(config).config_unserialize; | ||
| 56 | 92 | ||
| 57 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|a", &buf, &buf_len, &opts) == | 93 | if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|a", &buf, &buf_len, &opts) == |
| 58 | FAILURE) { | 94 | FAILURE) { |
| @@ -68,40 +104,27 @@ PHP_FUNCTION(sp_unserialize) { | |||
| 68 | serialized_str = ecalloc(buf_len - 64 + 1, 1); | 104 | serialized_str = ecalloc(buf_len - 64 + 1, 1); |
| 69 | memcpy(serialized_str, buf, buf_len - 64); | 105 | memcpy(serialized_str, buf, buf_len - 64); |
| 70 | 106 | ||
| 71 | zval func_name; | 107 | zend_string *expected_hmac = sp_do_hash_hmac_sha256(serialized_str, strlen(serialized_str), ZSTR_VAL(SPCFG(encryption_key)), ZSTR_LEN(SPCFG(encryption_key))); |
| 72 | ZVAL_STRING(&func_name, "hash_hmac"); | ||
| 73 | |||
| 74 | zval params[3]; | ||
| 75 | ZVAL_STRING(¶ms[0], "sha256"); | ||
| 76 | ZVAL_STRING(¶ms[1], serialized_str); | ||
| 77 | ZVAL_STRING( | ||
| 78 | ¶ms[2], | ||
| 79 | ZSTR_VAL(SNUFFLEUPAGUS_G(config).config_snuffleupagus->encryption_key)); | ||
| 80 | call_user_function(CG(function_table), NULL, &func_name, &expected_hmac, 3, | ||
| 81 | params); | ||
| 82 | 108 | ||
| 83 | unsigned int status = 0; | 109 | unsigned int status = 0; |
| 84 | for (uint8_t i = 0; i < 64; i++) { | 110 | if (expected_hmac) { |
| 85 | status |= (hmac[i] ^ (Z_STRVAL(expected_hmac))[i]); | 111 | for (uint8_t i = 0; i < 64; i++) { |
| 86 | } | 112 | status |= (hmac[i] ^ (ZSTR_VAL(expected_hmac))[i]); |
| 113 | } | ||
| 114 | } else { status = 1; } | ||
| 87 | 115 | ||
| 88 | if (0 == status) { | 116 | if (0 == status) { |
| 89 | if ((orig_handler = zend_hash_str_find_ptr( | 117 | if ((orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize")))) { |
| 90 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", | ||
| 91 | sizeof("unserialize") - 1))) { | ||
| 92 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 118 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 93 | } | 119 | } |
| 94 | } else { | 120 | } else { |
| 95 | if (config_unserialize->dump) { | 121 | if (config_unserialize->dump) { |
| 96 | sp_log_request(config_unserialize->dump, | 122 | sp_log_request(config_unserialize->dump, |
| 97 | config_unserialize->textual_representation, | 123 | config_unserialize->textual_representation); |
| 98 | SP_TOKEN_UNSERIALIZE_HMAC); | ||
| 99 | } | 124 | } |
| 100 | if (true == config_unserialize->simulation) { | 125 | if (true == config_unserialize->simulation) { |
| 101 | sp_log_simulation("unserialize", "Invalid HMAC for %s", serialized_str); | 126 | sp_log_simulation("unserialize", "Invalid HMAC for %s", serialized_str); |
| 102 | if ((orig_handler = zend_hash_str_find_ptr( | 127 | if ((orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("unserialize")))) { |
| 103 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), "unserialize", | ||
| 104 | sizeof("unserialize") - 1))) { | ||
| 105 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 128 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 106 | } | 129 | } |
| 107 | } else { | 130 | } else { |
diff --git a/src/sp_upload_validation.c b/src/sp_upload_validation.c index cebab3e..38b4cb3 100644 --- a/src/sp_upload_validation.c +++ b/src/sp_upload_validation.c | |||
| @@ -32,28 +32,21 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) { | |||
| 32 | 32 | ||
| 33 | if (event == MULTIPART_EVENT_END) { | 33 | if (event == MULTIPART_EVENT_END) { |
| 34 | zend_string *file_key __attribute__((unused)) = NULL; | 34 | zend_string *file_key __attribute__((unused)) = NULL; |
| 35 | const sp_config_upload_validation *config_upload = | 35 | const sp_config_upload_validation *config_upload = &(SPCFG(upload_validation)); |
| 36 | SNUFFLEUPAGUS_G(config).config_upload_validation; | ||
| 37 | zval *file; | 36 | zval *file; |
| 38 | pid_t pid; | 37 | pid_t pid; |
| 39 | 38 | ||
| 40 | sp_log_debug( | 39 | sp_log_debug("Got %d files", zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]))); |
| 41 | "Got %d files", | ||
| 42 | zend_hash_num_elements(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]))); | ||
| 43 | 40 | ||
| 44 | ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]), | 41 | ZEND_HASH_FOREACH_STR_KEY_VAL(Z_ARRVAL(PG(http_globals)[TRACK_VARS_FILES]), file_key, file) { // for each uploaded file |
| 45 | file_key, file) { // for each uploaded file | ||
| 46 | 42 | ||
| 47 | char *filename = Z_STRVAL_P( | 43 | char *filename = Z_STRVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("name"))); |
| 48 | zend_hash_str_find(Z_ARRVAL_P(file), "name", sizeof("name") - 1)); | 44 | char *tmp_name = Z_STRVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("tmp_name"))); |
| 49 | char *tmp_name = Z_STRVAL_P(zend_hash_str_find( | 45 | size_t filesize = Z_LVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), ZEND_STRL("size"))); |
| 50 | Z_ARRVAL_P(file), "tmp_name", sizeof("tmp_name") - 1)); | ||
| 51 | size_t filesize = Z_LVAL_P( | ||
| 52 | zend_hash_str_find(Z_ARRVAL_P(file), "size", sizeof("size") - 1)); | ||
| 53 | char *cmd[3] = {0}; | 46 | char *cmd[3] = {0}; |
| 54 | char *env[5] = {0}; | 47 | char *env[5] = {0}; |
| 55 | 48 | ||
| 56 | sp_log_debug("Filename: %s\nTmpname: %s\nSize: %d\nError: %d\nScript: %s", | 49 | sp_log_debug("Filename: %s\nTmpname: %s\nSize: %zd\nError: %lld\nScript: %s", |
| 57 | filename, tmp_name, filesize, | 50 | filename, tmp_name, filesize, |
| 58 | Z_LVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), "error", 5)), | 51 | Z_LVAL_P(zend_hash_str_find(Z_ARRVAL_P(file), "error", 5)), |
| 59 | ZSTR_VAL(config_upload->script)); | 52 | ZSTR_VAL(config_upload->script)); |
| @@ -64,22 +57,19 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) { | |||
| 64 | 57 | ||
| 65 | spprintf(&env[0], 0, "SP_FILENAME=%s", filename); | 58 | spprintf(&env[0], 0, "SP_FILENAME=%s", filename); |
| 66 | spprintf(&env[1], 0, "SP_REMOTE_ADDR=%s", getenv("REMOTE_ADDR")); | 59 | spprintf(&env[1], 0, "SP_REMOTE_ADDR=%s", getenv("REMOTE_ADDR")); |
| 67 | spprintf(&env[2], 0, "SP_CURRENT_FILE=%s", | 60 | spprintf(&env[2], 0, "SP_CURRENT_FILE=%s", zend_get_executed_filename(TSRMLS_C)); |
| 68 | zend_get_executed_filename(TSRMLS_C)); | ||
| 69 | spprintf(&env[3], 0, "SP_FILESIZE=%zu", filesize); | 61 | spprintf(&env[3], 0, "SP_FILESIZE=%zu", filesize); |
| 70 | env[4] = NULL; | 62 | env[4] = NULL; |
| 71 | 63 | ||
| 72 | if ((pid = fork()) == 0) { | 64 | if ((pid = fork()) == 0) { |
| 73 | if (execve(ZSTR_VAL(config_upload->script), cmd, env) == -1) { | 65 | if (execve(ZSTR_VAL(config_upload->script), cmd, env) == -1) { |
| 74 | sp_log_warn("upload_validation", "Could not call '%s' : %s", | 66 | sp_log_warn("upload_validation", "Could not call '%s' : %s", ZSTR_VAL(config_upload->script), strerror(errno)); |
| 75 | ZSTR_VAL(config_upload->script), strerror(errno)); | ||
| 76 | EFREE_3(env); | 67 | EFREE_3(env); |
| 77 | exit(1); | 68 | exit(1); |
| 78 | } | 69 | } |
| 79 | } else if (pid == -1) { | 70 | } else if (pid == -1) { |
| 80 | // LCOV_EXCL_START | 71 | // LCOV_EXCL_START |
| 81 | sp_log_err("upload_validation", "Could not fork process : %s\n", | 72 | sp_log_err("upload_validation", "Could not fork process : %s\n", strerror(errno)); |
| 82 | strerror(errno)); | ||
| 83 | EFREE_3(env); | 73 | EFREE_3(env); |
| 84 | continue; | 74 | continue; |
| 85 | // LCOV_EXCL_STOP | 75 | // LCOV_EXCL_STOP |
| @@ -91,9 +81,7 @@ int sp_rfc1867_callback(unsigned int event, void *event_data, void **extra) { | |||
| 91 | if (WEXITSTATUS(waitstatus) != 0) { // Nope | 81 | if (WEXITSTATUS(waitstatus) != 0) { // Nope |
| 92 | char *uri = getenv("REQUEST_URI"); | 82 | char *uri = getenv("REQUEST_URI"); |
| 93 | int sim = config_upload->simulation; | 83 | int sim = config_upload->simulation; |
| 94 | sp_log_auto("upload_validation", sim, | 84 | sp_log_auto("upload_validation", sim, "The upload of %s on %s was rejected.", filename, uri ? uri : "?"); |
| 95 | "The upload of %s on %s was rejected.", filename, | ||
| 96 | uri ? uri : "?"); | ||
| 97 | } | 85 | } |
| 98 | } | 86 | } |
| 99 | ZEND_HASH_FOREACH_END(); | 87 | ZEND_HASH_FOREACH_END(); |
diff --git a/src/sp_utils.c b/src/sp_utils.c index b78f7b1..6161859 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -1,12 +1,5 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | bool sp_zend_string_equals(const zend_string* s1, const zend_string* s2) { | ||
| 4 | // We can't use `zend_string_equals` here because it doesn't work on | ||
| 5 | // `const` zend_string. | ||
| 6 | return ZSTR_LEN(s1) == ZSTR_LEN(s2) && | ||
| 7 | !memcmp(ZSTR_VAL(s1), ZSTR_VAL(s2), ZSTR_LEN(s1)); | ||
| 8 | } | ||
| 9 | |||
| 10 | static const char* default_ipaddr = "0.0.0.0"; | 3 | static const char* default_ipaddr = "0.0.0.0"; |
| 11 | const char* get_ipaddr() { | 4 | const char* get_ipaddr() { |
| 12 | const char* client_ip = getenv("REMOTE_ADDR"); | 5 | const char* client_ip = getenv("REMOTE_ADDR"); |
| @@ -46,7 +39,7 @@ void sp_log_msgf(char const* restrict feature, int level, int type, | |||
| 46 | break; | 39 | break; |
| 47 | } | 40 | } |
| 48 | 41 | ||
| 49 | switch (SNUFFLEUPAGUS_G(config).log_media) { | 42 | switch (SPCFG(log_media)) { |
| 50 | case SP_SYSLOG: { | 43 | case SP_SYSLOG: { |
| 51 | const char* error_filename = zend_get_executed_filename(); | 44 | const char* error_filename = zend_get_executed_filename(); |
| 52 | int syslog_level = (level == E_ERROR) ? LOG_ERR : LOG_INFO; | 45 | int syslog_level = (level == E_ERROR) ? LOG_ERR : LOG_INFO; |
| @@ -72,8 +65,8 @@ void sp_log_msgf(char const* restrict feature, int level, int type, | |||
| 72 | 65 | ||
| 73 | int compute_hash(const char* const restrict filename, | 66 | int compute_hash(const char* const restrict filename, |
| 74 | char* restrict file_hash) { | 67 | char* restrict file_hash) { |
| 75 | unsigned char buf[1024]; | 68 | unsigned char buf[1024] = {0}; |
| 76 | unsigned char digest[SHA256_SIZE]; | 69 | unsigned char digest[SHA256_SIZE] = {0}; |
| 77 | PHP_SHA256_CTX context; | 70 | PHP_SHA256_CTX context; |
| 78 | size_t n; | 71 | size_t n; |
| 79 | 72 | ||
| @@ -123,9 +116,7 @@ static int construct_filename(char* filename, | |||
| 123 | return 0; | 116 | return 0; |
| 124 | } | 117 | } |
| 125 | 118 | ||
| 126 | int sp_log_request(const zend_string* restrict folder, | 119 | int sp_log_request(const zend_string* restrict folder, const zend_string* restrict text_repr) { |
| 127 | const zend_string* restrict text_repr, | ||
| 128 | char const* const from) { | ||
| 129 | FILE* file; | 120 | FILE* file; |
| 130 | const char* current_filename = zend_get_executed_filename(TSRMLS_C); | 121 | const char* current_filename = zend_get_executed_filename(TSRMLS_C); |
| 131 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 122 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
| @@ -146,7 +137,7 @@ int sp_log_request(const zend_string* restrict folder, | |||
| 146 | return -1; | 137 | return -1; |
| 147 | } | 138 | } |
| 148 | 139 | ||
| 149 | fprintf(file, "RULE: sp%s%s\n", from, ZSTR_VAL(text_repr)); | 140 | fprintf(file, "RULE: %s\n", ZSTR_VAL(text_repr)); |
| 150 | 141 | ||
| 151 | fprintf(file, "FILE: %s:%d\n", current_filename, current_line); | 142 | fprintf(file, "FILE: %s:%d\n", current_filename, current_line); |
| 152 | 143 | ||
| @@ -157,8 +148,8 @@ int sp_log_request(const zend_string* restrict folder, | |||
| 157 | char* const complete_path_function = get_complete_function_path(current); | 148 | char* const complete_path_function = get_complete_function_path(current); |
| 158 | if (complete_path_function) { | 149 | if (complete_path_function) { |
| 159 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 150 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
| 160 | fprintf(file, "STACKTRACE: %s:%d\n", complete_path_function, | 151 | fprintf(file, "STACKTRACE: %s:%d\n", complete_path_function, current_line); |
| 161 | current_line); | 152 | efree(complete_path_function); |
| 162 | } | 153 | } |
| 163 | current = current->prev_execute_data; | 154 | current = current->prev_execute_data; |
| 164 | } | 155 | } |
| @@ -213,6 +204,19 @@ static char* zend_string_to_char(const zend_string* zs) { | |||
| 213 | return copy; | 204 | return copy; |
| 214 | } | 205 | } |
| 215 | 206 | ||
| 207 | static void sp_sanitize_charstring(char* c, size_t maxlen) | ||
| 208 | { | ||
| 209 | for (size_t i = 0; *c; c++, i++) { | ||
| 210 | if (maxlen && i > maxlen - 1) { | ||
| 211 | *c = 0; | ||
| 212 | return; | ||
| 213 | } | ||
| 214 | if (*c < 32 || *c > 126) { | ||
| 215 | *c = '*'; | ||
| 216 | } | ||
| 217 | } | ||
| 218 | } | ||
| 219 | |||
| 216 | const zend_string* sp_zval_to_zend_string(const zval* zv) { | 220 | const zend_string* sp_zval_to_zend_string(const zval* zv) { |
| 217 | switch (Z_TYPE_P(zv)) { | 221 | switch (Z_TYPE_P(zv)) { |
| 218 | case IS_LONG: { | 222 | case IS_LONG: { |
| @@ -233,35 +237,29 @@ const zend_string* sp_zval_to_zend_string(const zval* zv) { | |||
| 233 | return Z_STR_P(zv); | 237 | return Z_STR_P(zv); |
| 234 | } | 238 | } |
| 235 | case IS_FALSE: | 239 | case IS_FALSE: |
| 236 | return zend_string_init("FALSE", sizeof("FALSE") - 1, 0); | 240 | return zend_string_init(ZEND_STRL("FALSE"), 0); |
| 237 | case IS_TRUE: | 241 | case IS_TRUE: |
| 238 | return zend_string_init("TRUE", sizeof("TRUE") - 1, 0); | 242 | return zend_string_init(ZEND_STRL("TRUE"), 0); |
| 239 | case IS_NULL: | 243 | case IS_NULL: |
| 240 | return zend_string_init("NULL", sizeof("NULL") - 1, 0); | 244 | return zend_string_init(ZEND_STRL("NULL"), 0); |
| 241 | case IS_OBJECT: | 245 | case IS_OBJECT: |
| 242 | return zend_string_init("OBJECT", sizeof("OBJECT") - 1, 0); | 246 | return zend_string_init(ZEND_STRL("OBJECT"), 0); |
| 243 | case IS_ARRAY: | 247 | case IS_ARRAY: |
| 244 | return zend_string_init("ARRAY", sizeof("ARRAY") - 1, 0); | 248 | return zend_string_init(ZEND_STRL("ARRAY"), 0); |
| 245 | case IS_RESOURCE: | 249 | case IS_RESOURCE: |
| 246 | return zend_string_init("RESOURCE", sizeof("RESOURCE") - 1, 0); | 250 | return zend_string_init(ZEND_STRL("RESOURCE"), 0); |
| 247 | default: // LCOV_EXCL_LINE | 251 | default: // LCOV_EXCL_LINE |
| 248 | return zend_string_init("", 0, 0); // LCOV_EXCL_LINE | 252 | return zend_string_init("", 0, 0); // LCOV_EXCL_LINE |
| 249 | } | 253 | } |
| 250 | } | 254 | } |
| 251 | 255 | ||
| 252 | bool sp_match_value(const zend_string* value, const zend_string* to_match, | 256 | bool sp_match_value(const zend_string* value, const zend_string* to_match, const sp_regexp* rx) { |
| 253 | const sp_pcre* rx) { | ||
| 254 | if (to_match) { | 257 | if (to_match) { |
| 255 | return (sp_zend_string_equals(to_match, value)); | 258 | return (sp_zend_string_equals(to_match, value)); |
| 256 | } else if (rx) { | 259 | } else if (rx) { |
| 257 | char* tmp = zend_string_to_char(value); | 260 | return sp_is_regexp_matching_zstr(rx, value); |
| 258 | bool ret = sp_is_regexp_matching(rx, tmp); | ||
| 259 | efree(tmp); | ||
| 260 | return ret; | ||
| 261 | } else { | ||
| 262 | return true; | ||
| 263 | } | 261 | } |
| 264 | return false; | 262 | return true; |
| 265 | } | 263 | } |
| 266 | 264 | ||
| 267 | void sp_log_disable(const char* restrict path, const char* restrict arg_name, | 265 | void sp_log_disable(const char* restrict path, const char* restrict arg_name, |
| @@ -272,13 +270,13 @@ void sp_log_disable(const char* restrict path, const char* restrict arg_name, | |||
| 272 | const int sim = config_node->simulation; | 270 | const int sim = config_node->simulation; |
| 273 | 271 | ||
| 274 | if (dump) { | 272 | if (dump) { |
| 275 | sp_log_request(config_node->dump, config_node->textual_representation, | 273 | sp_log_request(config_node->dump, config_node->textual_representation); |
| 276 | SP_TOKEN_DISABLE_FUNC); | ||
| 277 | } | 274 | } |
| 278 | if (arg_name) { | 275 | if (arg_name) { |
| 279 | char* char_repr = NULL; | 276 | char* char_repr = NULL; |
| 280 | if (arg_value) { | 277 | if (arg_value) { |
| 281 | char_repr = zend_string_to_char(arg_value); | 278 | char_repr = zend_string_to_char(arg_value); |
| 279 | sp_sanitize_charstring(char_repr, 255); | ||
| 282 | } | 280 | } |
| 283 | if (alias) { | 281 | if (alias) { |
| 284 | sp_log_auto( | 282 | sp_log_auto( |
| @@ -315,11 +313,11 @@ void sp_log_disable_ret(const char* restrict path, | |||
| 315 | char* char_repr = NULL; | 313 | char* char_repr = NULL; |
| 316 | 314 | ||
| 317 | if (dump) { | 315 | if (dump) { |
| 318 | sp_log_request(dump, config_node->textual_representation, | 316 | sp_log_request(dump, config_node->textual_representation); |
| 319 | SP_TOKEN_DISABLE_FUNC); | ||
| 320 | } | 317 | } |
| 321 | if (ret_value) { | 318 | if (ret_value) { |
| 322 | char_repr = zend_string_to_char(ret_value); | 319 | char_repr = zend_string_to_char(ret_value); |
| 320 | sp_sanitize_charstring(char_repr, 255); | ||
| 323 | } | 321 | } |
| 324 | if (alias) { | 322 | if (alias) { |
| 325 | sp_log_auto( | 323 | sp_log_auto( |
| @@ -336,8 +334,7 @@ void sp_log_disable_ret(const char* restrict path, | |||
| 336 | efree(char_repr); | 334 | efree(char_repr); |
| 337 | } | 335 | } |
| 338 | 336 | ||
| 339 | bool sp_match_array_key(const zval* zv, const zend_string* to_match, | 337 | bool sp_match_array_key(const zval* zv, const zend_string* to_match, const sp_regexp* rx) { |
| 340 | const sp_pcre* rx) { | ||
| 341 | zend_string* key; | 338 | zend_string* key; |
| 342 | zend_ulong idx; | 339 | zend_ulong idx; |
| 343 | 340 | ||
| @@ -361,8 +358,7 @@ bool sp_match_array_key(const zval* zv, const zend_string* to_match, | |||
| 361 | return false; | 358 | return false; |
| 362 | } | 359 | } |
| 363 | 360 | ||
| 364 | bool sp_match_array_value(const zval* arr, const zend_string* to_match, | 361 | bool sp_match_array_value(const zval* arr, const zend_string* to_match, const sp_regexp* rx) { |
| 365 | const sp_pcre* rx) { | ||
| 366 | zval* value; | 362 | zval* value; |
| 367 | 363 | ||
| 368 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), value) { | 364 | ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(arr), value) { |
| @@ -378,61 +374,57 @@ bool sp_match_array_value(const zval* arr, const zend_string* to_match, | |||
| 378 | return false; | 374 | return false; |
| 379 | } | 375 | } |
| 380 | 376 | ||
| 381 | bool hook_function(const char* original_name, HashTable* hook_table, | 377 | bool /* success */ _hook_function(const char* original_name, HashTable* hook_table, zif_handler new_function) { |
| 382 | zif_handler new_function) { | 378 | zend_function* func; |
| 383 | zend_internal_function* func; | 379 | if ((func = zend_hash_str_find_ptr(CG(function_table), VAR_AND_LEN(original_name)))) { |
| 384 | bool ret = false; | 380 | if (func->type != ZEND_INTERNAL_FUNCTION) { |
| 385 | 381 | return false; | |
| 386 | /* The `mb` module likes to hook functions, like strlen->mb_strlen, | ||
| 387 | * so we have to hook both of them. */ | ||
| 388 | |||
| 389 | if ((func = zend_hash_str_find_ptr(CG(function_table), | ||
| 390 | VAR_AND_LEN(original_name)))) { | ||
| 391 | if (func->handler == new_function) { | ||
| 392 | return SUCCESS; // the function is already hooked | ||
| 393 | } else { | ||
| 394 | if (zend_hash_str_add_new_ptr((hook_table), VAR_AND_LEN(original_name), | ||
| 395 | func->handler) == NULL) { | ||
| 396 | // LCOV_EXCL_START | ||
| 397 | sp_log_err("function_pointer_saving", | ||
| 398 | "Could not save function pointer for %s", original_name); | ||
| 399 | return FAILURE; | ||
| 400 | // LCOV_EXCL_STOP | ||
| 401 | } | ||
| 402 | func->handler = new_function; | ||
| 403 | ret = true; | ||
| 404 | } | 382 | } |
| 383 | if (func->internal_function.handler == new_function) { | ||
| 384 | return true; | ||
| 385 | } | ||
| 386 | if (zend_hash_str_add_new_ptr((hook_table), VAR_AND_LEN(original_name), | ||
| 387 | func->internal_function.handler) == NULL) { | ||
| 388 | // LCOV_EXCL_START | ||
| 389 | sp_log_err("function_pointer_saving", "Could not save function pointer for %s", original_name); | ||
| 390 | return false; | ||
| 391 | // LCOV_EXCL_STOP | ||
| 392 | } | ||
| 393 | func->internal_function.handler = new_function; | ||
| 394 | return true; | ||
| 405 | } | 395 | } |
| 396 | return false; | ||
| 397 | } | ||
| 398 | |||
| 399 | bool hook_function(const char* original_name, HashTable* hook_table, zif_handler new_function) { | ||
| 400 | bool ret = _hook_function(original_name, hook_table, new_function); | ||
| 406 | 401 | ||
| 407 | #if PHP_VERSION_ID < 80000 | 402 | #if PHP_VERSION_ID < 80000 |
| 408 | CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN; | 403 | CG(compiler_options) |= ZEND_COMPILE_NO_BUILTIN_STRLEN; |
| 409 | #endif | 404 | #endif |
| 410 | 405 | ||
| 411 | if (0 == strncmp(original_name, "mb_", 3) && !CG(multibyte)) { | 406 | /* The `mb` module likes to hook functions, like strlen->mb_strlen, |
| 412 | if (zend_hash_str_find(CG(function_table), | 407 | * so we have to hook both of them. */ |
| 413 | VAR_AND_LEN(original_name + 3))) { | 408 | |
| 414 | return hook_function(original_name + 3, hook_table, new_function); | 409 | if (!CG(multibyte) && 0 == strncmp(original_name, "mb_", 3)) { |
| 415 | } | 410 | _hook_function(original_name + 3, hook_table, new_function); |
| 416 | } else if (CG(multibyte)) { | 411 | } else if (CG(multibyte)) { |
| 417 | // LCOV_EXCL_START | 412 | // LCOV_EXCL_START |
| 418 | char* mb_name = ecalloc(strlen(original_name) + 3 + 1, 1); | 413 | char* mb_name = ecalloc(strlen(original_name) + 3 + 1, 1); |
| 419 | if (NULL == mb_name) { | 414 | if (NULL == mb_name) { |
| 420 | return FAILURE; | 415 | return FAILURE; |
| 421 | } | 416 | } |
| 422 | memcpy(mb_name, "mb_", sizeof("mb_") - 1); | 417 | memcpy(mb_name, ZEND_STRL("mb_")); |
| 423 | memcpy(mb_name + 3, VAR_AND_LEN(original_name)); | 418 | memcpy(mb_name + 3, VAR_AND_LEN(original_name)); |
| 424 | if (zend_hash_str_find(CG(function_table), VAR_AND_LEN(mb_name))) { | 419 | _hook_function(mb_name, hook_table, new_function); |
| 425 | return hook_function(mb_name, hook_table, new_function); | 420 | efree(mb_name); |
| 426 | } | ||
| 427 | free(mb_name); | ||
| 428 | // LCOV_EXCL_STOP | 421 | // LCOV_EXCL_STOP |
| 429 | } | 422 | } |
| 430 | 423 | ||
| 431 | return ret; | 424 | return ret; |
| 432 | } | 425 | } |
| 433 | 426 | ||
| 434 | int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, | 427 | int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, zif_handler new_function) { |
| 435 | zif_handler new_function) { | ||
| 436 | zend_string* key; | 428 | zend_string* key; |
| 437 | 429 | ||
| 438 | ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key) | 430 | ZEND_HASH_FOREACH_STR_KEY(CG(function_table), key) |
| @@ -446,9 +438,21 @@ int hook_regexp(const sp_pcre* regexp, HashTable* hook_table, | |||
| 446 | return SUCCESS; | 438 | return SUCCESS; |
| 447 | } | 439 | } |
| 448 | 440 | ||
| 449 | bool check_is_in_eval_whitelist(const zend_string* const function_name) { | 441 | void unhook_functions(HashTable *ht) { |
| 450 | const sp_list_node* it = SNUFFLEUPAGUS_G(config).config_eval->whitelist; | 442 | zend_string *fname; |
| 443 | zif_handler orig_handler; | ||
| 444 | zend_ulong idx; | ||
| 445 | |||
| 446 | ZEND_HASH_REVERSE_FOREACH_KEY_PTR(ht, idx, fname, orig_handler) | ||
| 447 | zend_function *func = zend_hash_find_ptr(CG(function_table), fname); | ||
| 448 | if (func && func->type == ZEND_INTERNAL_FUNCTION && orig_handler) { | ||
| 449 | func->internal_function.handler = orig_handler; | ||
| 450 | } | ||
| 451 | ZEND_HASH_FOREACH_END_DEL(); | ||
| 452 | } | ||
| 451 | 453 | ||
| 454 | bool check_is_in_eval_whitelist(const char* function_name) { | ||
| 455 | const sp_list_node* it = SPCFG(eval).whitelist; | ||
| 452 | if (!it) { | 456 | if (!it) { |
| 453 | return false; | 457 | return false; |
| 454 | } | 458 | } |
| @@ -456,7 +460,7 @@ bool check_is_in_eval_whitelist(const zend_string* const function_name) { | |||
| 456 | /* yes, we could use a HashTable instead, but since the list is pretty | 460 | /* yes, we could use a HashTable instead, but since the list is pretty |
| 457 | * small, it doesn't make a difference in practise. */ | 461 | * small, it doesn't make a difference in practise. */ |
| 458 | while (it && it->data) { | 462 | while (it && it->data) { |
| 459 | if (sp_zend_string_equals(function_name, (const zend_string*)(it->data))) { | 463 | if (sp_zend_string_equals_str((const zend_string*)(it->data), VAR_AND_LEN(function_name))) { |
| 460 | /* We've got a match, the function is whiteslited. */ | 464 | /* We've got a match, the function is whiteslited. */ |
| 461 | return true; | 465 | return true; |
| 462 | } | 466 | } |
diff --git a/src/sp_utils.h b/src/sp_utils.h index b5a1691..0e595d8 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -23,16 +23,17 @@ | |||
| 23 | #define SHA256_SIZE 32 | 23 | #define SHA256_SIZE 32 |
| 24 | 24 | ||
| 25 | #define HOOK_FUNCTION(original_name, hook_table, new_function) \ | 25 | #define HOOK_FUNCTION(original_name, hook_table, new_function) \ |
| 26 | hook_function(original_name, SNUFFLEUPAGUS_G(hook_table), new_function) | 26 | hook_function(original_name, SPG(hook_table), new_function) |
| 27 | 27 | ||
| 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ | 28 | #define HOOK_FUNCTION_BY_REGEXP(regexp, hook_table, new_function) \ |
| 29 | hook_regexp(regexp, SNUFFLEUPAGUS_G(hook_table), new_function) | 29 | hook_regexp(regexp, SPG(hook_table), new_function) |
| 30 | 30 | ||
| 31 | #define SP_TYPE_LOG (0) | 31 | #define SP_TYPE_LOG (0) |
| 32 | #define SP_TYPE_DROP (1) | 32 | #define SP_TYPE_DROP (1) |
| 33 | #define SP_TYPE_SIMULATION (2) | 33 | #define SP_TYPE_SIMULATION (2) |
| 34 | 34 | ||
| 35 | #define SP_LOG_DEBUG E_NOTICE | 35 | #define SP_LOG_DEBUG E_NOTICE |
| 36 | #define SP_LOG_INFO E_NOTICE | ||
| 36 | #define SP_LOG_ERROR E_ERROR | 37 | #define SP_LOG_ERROR E_ERROR |
| 37 | #define SP_LOG_WARN E_WARNING | 38 | #define SP_LOG_WARN E_WARNING |
| 38 | 39 | ||
| @@ -57,11 +58,11 @@ | |||
| 57 | #ifdef SP_DEBUG_STDERR | 58 | #ifdef SP_DEBUG_STDERR |
| 58 | extern int sp_debug_stderr; | 59 | extern int sp_debug_stderr; |
| 59 | #define sp_log_debug(fmt, ...) \ | 60 | #define sp_log_debug(fmt, ...) \ |
| 60 | dprintf(sp_debug_stderr, "[snuffleupagus][DEBUG] %s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__); | 61 | if (sp_debug_stderr > 0) dprintf(sp_debug_stderr, "[snuffleupagus][DEBUG] %s(): " fmt "\n", __FUNCTION__, ##__VA_ARGS__); |
| 61 | #else | 62 | #else |
| 62 | #define sp_log_debug(...) \ | 63 | #define sp_log_debug(fmt, ...) \ |
| 63 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, __VA_ARGS__) | 64 | sp_log_msgf("DEBUG", SP_LOG_DEBUG, SP_TYPE_LOG, "%s(): " fmt, __FUNCTION__, ##__VA_ARGS__) |
| 64 | #endif | 65 | #endif |
| 65 | 66 | ||
| 66 | #else | 67 | #else |
| 67 | #define sp_log_debug(...) | 68 | #define sp_log_debug(...) |
| @@ -70,23 +71,21 @@ extern int sp_debug_stderr; | |||
| 70 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") | 71 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") |
| 71 | 72 | ||
| 72 | const char *get_ipaddr(void); | 73 | const char *get_ipaddr(void); |
| 73 | void sp_log_msgf(char const *restrict feature, int level, int type, | 74 | void sp_log_msgf(char const *restrict feature, int level, int type, const char *restrict fmt, ...); |
| 74 | const char *restrict fmt, ...); | ||
| 75 | int compute_hash(const char *const restrict filename, char *restrict file_hash); | 75 | int compute_hash(const char *const restrict filename, char *restrict file_hash); |
| 76 | const zend_string *sp_zval_to_zend_string(const zval *); | 76 | const zend_string *sp_zval_to_zend_string(const zval *); |
| 77 | bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); | 77 | bool sp_match_value(const zend_string* value, const zend_string* to_match, const sp_regexp* rx); |
| 78 | bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); | 78 | bool sp_match_array_key(const zval *, const zend_string *, const sp_regexp *); |
| 79 | bool sp_match_array_value(const zval *, const zend_string *, const sp_pcre *); | 79 | bool sp_match_array_value(const zval *, const zend_string *, const sp_regexp *); |
| 80 | void sp_log_disable(const char *restrict, const char *restrict, | 80 | void sp_log_disable(const char *restrict, const char *restrict, const zend_string *restrict, const sp_disabled_function *); |
| 81 | const zend_string *restrict, const sp_disabled_function *); | 81 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, const sp_disabled_function *); |
| 82 | void sp_log_disable_ret(const char *restrict, const zend_string *restrict, | ||
| 83 | const sp_disabled_function *); | ||
| 84 | bool hook_function(const char *, HashTable *, zif_handler); | 82 | bool hook_function(const char *, HashTable *, zif_handler); |
| 83 | void unhook_functions(HashTable *ht); | ||
| 85 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); | 84 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); |
| 86 | bool check_is_in_eval_whitelist(const zend_string *const function_name); | 85 | bool check_is_in_eval_whitelist(const char* function_name); |
| 87 | int sp_log_request(const zend_string *restrict folder, | 86 | int sp_log_request(const zend_string *restrict folder, const zend_string *restrict text_repr); |
| 88 | const zend_string *restrict text_repr, | 87 | #define sp_zend_string_equals(s1, s2) zend_string_equals((zend_string*)s1, (zend_string*)s2) |
| 89 | char const *const from); | 88 | static inline bool sp_zend_string_equals_str(const zend_string* s1, const char *str, size_t len) { |
| 90 | bool sp_zend_string_equals(const zend_string *s1, const zend_string *s2); | 89 | return (ZSTR_LEN(s1) == len && !memcmp(ZSTR_VAL(s1), str, len)); |
| 91 | 90 | } | |
| 92 | #endif /* SP_UTILS_H */ | 91 | #endif /* SP_UTILS_H */ |
diff --git a/src/sp_var_parser.c b/src/sp_var_parser.c index ea856f6..2639991 100644 --- a/src/sp_var_parser.c +++ b/src/sp_var_parser.c | |||
| @@ -33,8 +33,8 @@ static bool is_var_name_valid(const char *const name) { | |||
| 33 | if (NULL == regexp_var || NULL == regexp_const) { | 33 | if (NULL == regexp_var || NULL == regexp_const) { |
| 34 | return false; // LCOV_EXCL_LINE | 34 | return false; // LCOV_EXCL_LINE |
| 35 | } | 35 | } |
| 36 | if ((false == sp_is_regexp_matching(regexp_var, name)) && | 36 | if ((false == sp_is_regexp_matching_len(regexp_var, VAR_AND_LEN(name))) && |
| 37 | (false == sp_is_regexp_matching(regexp_const, name))) { | 37 | (false == sp_is_regexp_matching_len(regexp_const, VAR_AND_LEN(name)))) { |
| 38 | return false; | 38 | return false; |
| 39 | } | 39 | } |
| 40 | return true; | 40 | return true; |
| @@ -264,7 +264,7 @@ sp_tree *sp_parse_var(const char *line) { | |||
| 264 | } | 264 | } |
| 265 | tokens_list = sp_list_sort(tokens_list, cmp_tokens); | 265 | tokens_list = sp_list_sort(tokens_list, cmp_tokens); |
| 266 | tree = parse_tokens(line, tokens_list); | 266 | tree = parse_tokens(line, tokens_list); |
| 267 | sp_list_free(tokens_list); | 267 | sp_list_free2(tokens_list); |
| 268 | // Check if tree is empty. | 268 | // Check if tree is empty. |
| 269 | if (tree && tree->next == NULL && tree->type == UNDEFINED) { | 269 | if (tree && tree->next == NULL && tree->type == UNDEFINED) { |
| 270 | tree->type = CONSTANT; | 270 | tree->type = CONSTANT; |
diff --git a/src/sp_wrapper.c b/src/sp_wrapper.c index 7610114..9eb5cbc 100644 --- a/src/sp_wrapper.c +++ b/src/sp_wrapper.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #include "php_snuffleupagus.h" | 1 | #include "php_snuffleupagus.h" |
| 2 | 2 | ||
| 3 | static bool wrapper_is_whitelisted(const zend_string *const zs) { | 3 | static bool wrapper_is_whitelisted(const zend_string *const zs) { |
| 4 | const sp_list_node *list = SNUFFLEUPAGUS_G(config).config_wrapper->whitelist; | 4 | const sp_list_node *list = SPCFG(wrapper).whitelist; |
| 5 | 5 | ||
| 6 | if (!zs) { | 6 | if (!zs) { |
| 7 | return false; // LCOV_EXCL_LINE | 7 | return false; // LCOV_EXCL_LINE |
| @@ -38,24 +38,19 @@ void sp_disable_wrapper() { | |||
| 38 | 38 | ||
| 39 | zend_hash_destroy(orig_complete); | 39 | zend_hash_destroy(orig_complete); |
| 40 | pefree(orig_complete, 1); | 40 | pefree(orig_complete, 1); |
| 41 | SNUFFLEUPAGUS_G(config).config_wrapper->num_wrapper = | 41 | SPCFG(wrapper).num_wrapper = zend_hash_num_elements(orig); |
| 42 | zend_hash_num_elements(orig); | ||
| 43 | } | 42 | } |
| 44 | 43 | ||
| 45 | PHP_FUNCTION(sp_stream_wrapper_register) { | 44 | PHP_FUNCTION(sp_stream_wrapper_register) { |
| 46 | zif_handler orig_handler; | 45 | zif_handler orig_handler; |
| 47 | zend_string *protocol_name = NULL; | 46 | zend_string *protocol_name = NULL; |
| 47 | zval *params = NULL; | ||
| 48 | uint32_t param_count = 0; | ||
| 48 | 49 | ||
| 49 | // LCOV_EXCL_BR_START | 50 | zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "S*", &protocol_name, ¶ms, ¶m_count); |
| 50 | ZEND_PARSE_PARAMETERS_START_EX(ZEND_PARSE_PARAMS_QUIET, 2, EX_NUM_ARGS()); | 51 | // ignore proper arguments here and just let the original handler deal with it |
| 51 | Z_PARAM_STR(protocol_name); | 52 | if (!protocol_name || wrapper_is_whitelisted(protocol_name)) { |
| 52 | ZEND_PARSE_PARAMETERS_END_EX((void)0); | 53 | orig_handler = zend_hash_str_find_ptr(SPG(sp_internal_functions_hook), ZEND_STRL("stream_wrapper_register")); |
| 53 | // LCOV_EXCL_BR_END | ||
| 54 | |||
| 55 | if (wrapper_is_whitelisted(protocol_name)) { | ||
| 56 | orig_handler = zend_hash_str_find_ptr( | ||
| 57 | SNUFFLEUPAGUS_G(sp_internal_functions_hook), "stream_wrapper_register", | ||
| 58 | sizeof("stream_wrapper_register") - 1); | ||
| 59 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); | 54 | orig_handler(INTERNAL_FUNCTION_PARAM_PASSTHRU); |
| 60 | } | 55 | } |
| 61 | } | 56 | } |
diff --git a/src/tests/broken_configuration/broken_conf.phpt b/src/tests/broken_configuration/broken_conf.phpt index 477ee64..3500b42 100644 --- a/src/tests/broken_configuration/broken_conf.phpt +++ b/src/tests/broken_configuration/broken_conf.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | 6 | sp.configuration_file={PWD}/config/broken_conf.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Parser error on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf2.phpt b/src/tests/broken_configuration/broken_conf2.phpt index 4e67b9f..a26d5c8 100644 --- a/src/tests/broken_configuration/broken_conf2.phpt +++ b/src/tests/broken_configuration/broken_conf2.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf2.ini | 6 | sp.configuration_file={PWD}/config/broken_conf2.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration section 'sp.wrong' on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Unexpected keyword 'wrong' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration section 'sp.wrong' on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_allow_broken_disabled.phpt b/src/tests/broken_configuration/broken_conf_allow_broken_disabled.phpt index e2ffab0..f43c790 100644 --- a/src/tests/broken_configuration/broken_conf_allow_broken_disabled.phpt +++ b/src/tests/broken_configuration/broken_conf_allow_broken_disabled.phpt | |||
| @@ -2,18 +2,16 @@ | |||
| 2 | Broken configuration with allow broken turned off | 2 | Broken configuration with allow broken turned off |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | 6 | sp.configuration_file={PWD}/config/broken_conf.ini |
| 8 | sp.allow_broken_configuration=Off | 7 | sp.allow_broken_configuration=Off |
| 8 | error_log=/dev/null | ||
| 9 | --FILE-- | 9 | --FILE-- |
| 10 | <?php | 10 | <?php |
| 11 | echo 1337; | 11 | echo 1337; |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECT-- | 13 | --EXPECT-- |
| 14 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Parser error on line 1 in Unknown on line 0 |
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 17 | 15 | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 19 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_allow_broken_enabled.phpt b/src/tests/broken_configuration/broken_conf_allow_broken_enabled.phpt index 68938fe..b999e7e 100644 --- a/src/tests/broken_configuration/broken_conf_allow_broken_enabled.phpt +++ b/src/tests/broken_configuration/broken_conf_allow_broken_enabled.phpt | |||
| @@ -2,16 +2,14 @@ | |||
| 2 | Broken configuration with allow broken turned on | 2 | Broken configuration with allow broken turned on |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | 6 | sp.configuration_file={PWD}/config/broken_conf.ini |
| 8 | sp.allow_broken_configuration=On | 7 | sp.allow_broken_configuration=On |
| 8 | error_log=/dev/null | ||
| 9 | --FILE-- | 9 | --FILE-- |
| 10 | <?php | 10 | <?php |
| 11 | echo 1337; | 11 | echo 1337; |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECT-- | 13 | --EXPECT-- |
| 14 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Parser error on line 1 in Unknown on line 0 |
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 17 | 1337 | 15 | 1337 |
diff --git a/src/tests/broken_configuration/broken_conf_config_regexp.phpt b/src/tests/broken_configuration/broken_conf_config_regexp.phpt index ff6280e..27fff9c 100644 --- a/src/tests/broken_configuration/broken_conf_config_regexp.phpt +++ b/src/tests/broken_configuration/broken_conf_config_regexp.phpt | |||
| @@ -2,17 +2,14 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp.ini | 6 | sp.configuration_file={PWD}/config/broken_config_regexp.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %a. in Unknown on line 0 |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 12 | 11 | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid regexp '*.' for '.filename_r()' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 16 | 13 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 15 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_config_regexp_no_closing_paren.phpt b/src/tests/broken_configuration/broken_conf_config_regexp_no_closing_paren.phpt index 8644dfe..e32ffa8 100644 --- a/src/tests/broken_configuration/broken_conf_config_regexp_no_closing_paren.phpt +++ b/src/tests/broken_configuration/broken_conf_config_regexp_no_closing_paren.phpt | |||
| @@ -2,17 +2,12 @@ | |||
| 2 | Broken configuration - regexp without a closing parenthesis | 2 | Broken configuration - regexp without a closing parenthesis |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp_no_closing_paren.ini | 6 | sp.configuration_file={PWD}/config/broken_config_regexp_no_closing_paren.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"*."': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'filename_r' - it should be 'filename_r("...")' on line 1 in Unknown on line 0 |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"*."': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 16 | 11 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_cookie_encryption_without_encryption_key.phpt b/src/tests/broken_configuration/broken_conf_cookie_encryption_without_encryption_key.phpt index 857c803..90b497c 100644 --- a/src/tests/broken_configuration/broken_conf_cookie_encryption_without_encryption_key.phpt +++ b/src/tests/broken_configuration/broken_conf_cookie_encryption_without_encryption_key.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration - encrypted cookie without encryption key | 2 | Broken configuration - encrypted cookie without encryption key |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_encryption_key.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_encryption_key.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.encryption_key` option in`sp.global`: please set it first in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.secret_key` option in `sp.global`: please set it first in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.encryption_key` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_cookie_encryption_without_env_var.phpt b/src/tests/broken_configuration/broken_conf_cookie_encryption_without_env_var.phpt index de97a9d..adefcab 100644 --- a/src/tests/broken_configuration/broken_conf_cookie_encryption_without_env_var.phpt +++ b/src/tests/broken_configuration/broken_conf_cookie_encryption_without_env_var.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration - encrypted cookie with without cookie env var | 2 | Broken configuration - encrypted cookie with without cookie env var |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_env_var.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_env_var.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_cookie_name_and_regexp.phpt b/src/tests/broken_configuration/broken_conf_cookie_name_and_regexp.phpt index 141cf77..9899912 100644 --- a/src/tests/broken_configuration/broken_conf_cookie_name_and_regexp.phpt +++ b/src/tests/broken_configuration/broken_conf_cookie_name_and_regexp.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration - encrypted cookie with name and regexp | 2 | Broken configuration - encrypted cookie with name and regexp |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_name_and_regexp.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_cookie_name_and_regexp.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] name and name_r are mutually exclusive on line 2 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] name and name_r are mutually exclusive on line 2 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] name and name_r are mutually exclusive on line 2 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_enable_disable.phpt b/src/tests/broken_configuration/broken_conf_enable_disable.phpt index eeba04a..cf80a9d 100644 --- a/src/tests/broken_configuration/broken_conf_enable_disable.phpt +++ b/src/tests/broken_configuration/broken_conf_enable_disable.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Global strict mode | 2 | Global strict mode |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/borken_conf_enable_disable.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_enable_disable.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_enable_disable2.phpt b/src/tests/broken_configuration/broken_conf_enable_disable2.phpt new file mode 100644 index 0000000..21380ce --- /dev/null +++ b/src/tests/broken_configuration/broken_conf_enable_disable2.phpt | |||
| @@ -0,0 +1,9 @@ | |||
| 1 | --TEST-- | ||
| 2 | Global strict mode | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/../broken_configuration/config/broken_conf_enable_disable2.ini | ||
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
diff --git a/src/tests/broken_configuration/broken_conf_eval.phpt b/src/tests/broken_configuration/broken_conf_eval.phpt index 791795a..d09beec 100644 --- a/src/tests/broken_configuration/broken_conf_eval.phpt +++ b/src/tests/broken_configuration/broken_conf_eval.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration for eval | 2 | Broken configuration for eval |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_eval.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_eval.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"cos,sin': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'list' - it should be 'list("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"cos,sin': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_expecting_bool.phpt b/src/tests/broken_configuration/broken_conf_expecting_bool.phpt index 4857ebe..38417b9 100644 --- a/src/tests/broken_configuration/broken_conf_expecting_bool.phpt +++ b/src/tests/broken_configuration/broken_conf_expecting_bool.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Bad boolean value in configuration | 2 | Bad boolean value in configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_expecting_bool.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_expecting_bool.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '337);' at the end of '.enable(1337);' on line 5 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing paranthesis for keyword 'enable' - it should be 'enable()' on line 5 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '337);' at the end of '.enable(1337);' on line 5 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_cidr.phpt b/src/tests/broken_configuration/broken_conf_invalid_cidr.phpt index e618676..74f13ac 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_cidr.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_cidr.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '42' isn't a valid ipv4 mask. in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '42' isn't a valid ipv4 mask. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '42' isn't a valid ipv4 mask. in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_cidr6.phpt b/src/tests/broken_configuration/broken_conf_invalid_cidr6.phpt index 34a0d30..3765c22 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_cidr6.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_cidr6.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] 'ZZZ' isn't a valid network mask. in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] 'ZZZ' isn't a valid network mask. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] 'ZZZ' isn't a valid network mask. in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_cidr6_no_slash.phpt b/src/tests/broken_configuration/broken_conf_invalid_cidr6_no_slash.phpt index 8703dff..a6eea84 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_cidr6_no_slash.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_cidr6_no_slash.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration, invalid cidr for ipv6 because there is no `/` in it | 2 | Broken configuration, invalid cidr for ipv6 because there is no `/` in it |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_no_slash.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_no_slash.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '2001:0db8:0000:0000:0000:ff00:0042:8329' isn't a valid network mask, it seems that you forgot a '/'. in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '2001:0db8:0000:0000:0000:ff00:0042:8329' isn't a valid network mask, it seems that you forgot a '/'. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '2001:0db8:0000:0000:0000:ff00:0042:8329' isn't a valid network mask, it seems that you forgot a '/'. in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_cidr6_too_big.phpt b/src/tests/broken_configuration/broken_conf_invalid_cidr6_too_big.phpt index 47d4a5d..0fa61aa 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_cidr6_too_big.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_cidr6_too_big.phpt | |||
| @@ -5,5 +5,10 @@ Broken configuration, cidr for ipv6 is too big, that will `mod` to 25. | |||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_too_big.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_too_big.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | --EXPECT-- | 10 | --EXPECT-- |
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '13337' isn't a valid network mask. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. \ No newline at end of file | ||
diff --git a/src/tests/broken_configuration/broken_conf_invalid_cidr_value.phpt b/src/tests/broken_configuration/broken_conf_invalid_cidr_value.phpt index 1424853..9894975 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_cidr_value.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_cidr_value.phpt | |||
| @@ -3,17 +3,12 @@ Broken configuration, invalid cidr value | |||
| 3 | (13337%128 = 25) | 3 | (13337%128 = 25) |
| 4 | --SKIPIF-- | 4 | --SKIPIF-- |
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 6 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 7 | --INI-- | 6 | --INI-- |
| 8 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr_value.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr_value.ini |
| 8 | error_log=/dev/null | ||
| 9 | --FILE-- | 9 | --FILE-- |
| 10 | --EXPECT-- | 10 | --EXPECT-- |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'cidr' - it should be 'cidr("...")' on line 1 in Unknown on line 0 |
| 12 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] " doesn't contain a valid cidr on line 1 in Unknown on line 0 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] " doesn't contain a valid cidr on line 1 in Unknown on line 0 | ||
| 17 | 12 | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 19 | Could not startup. | 14 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_filename.phpt b/src/tests/broken_configuration/broken_conf_invalid_filename.phpt index b9a904c..bf74900 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_filename.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_filename.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration filename without absolute path | 2 | Broken configuration filename without absolute path |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_filename.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_filename.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("sprintf").filename("wrong file name").drop();':'.filename' must be an absolute path or a phar archive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions': '.filename' must be an absolute path or a phar archive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("sprintf").filename("wrong file name").drop();':'.filename' must be an absolute path or a phar archive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_log_media.phpt b/src/tests/broken_configuration/broken_conf_invalid_log_media.phpt index c1c2668..af0d61f 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_log_media.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_log_media.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration filename with improper log media | 2 | Broken configuration filename with improper log media |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_log_media.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_log_media.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] .log_media() only supports 'syslog' or 'php', on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] .log_media() only supports 'syslog' or 'php' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] .log_media() only supports 'syslog' or 'php', on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_invalid_type.phpt b/src/tests/broken_configuration/broken_conf_invalid_type.phpt index aeb6b85..acb8fee 100644 --- a/src/tests/broken_configuration/broken_conf_invalid_type.phpt +++ b/src/tests/broken_configuration/broken_conf_invalid_type.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken conf with wrong type | 2 | Broken conf with wrong type |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_type.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_invalid_type.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"totally_wrong"_type")': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'ret_type' - it should be 'ret_type("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"totally_wrong"_type")': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_key_value.phpt b/src/tests/broken_configuration/broken_conf_key_value.phpt index ec87d93..6acb2af 100644 --- a/src/tests/broken_configuration/broken_conf_key_value.phpt +++ b/src/tests/broken_configuration/broken_conf_key_value.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_key_value.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_key_value.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").var("").value("").key("").drop();':`key` and `value` are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.key' and '.value' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").var("").value("").key("").drop();':`key` and `value` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_line_empty_string.phpt b/src/tests/broken_configuration/broken_conf_line_empty_string.phpt index 3790d83..06553d8 100644 --- a/src/tests/broken_configuration/broken_conf_line_empty_string.phpt +++ b/src/tests/broken_configuration/broken_conf_line_empty_string.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Configuration line with an empty string | 2 | Configuration line with an empty string |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_line_empty_string.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_line_empty_string.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'name' - it should be 'name("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_line_no_closing.phpt b/src/tests/broken_configuration/broken_conf_line_no_closing.phpt index 0f51dcf..8b06dc5 100644 --- a/src/tests/broken_configuration/broken_conf_line_no_closing.phpt +++ b/src/tests/broken_configuration/broken_conf_line_no_closing.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Configuration line without closing parenthese | 2 | Configuration line without closing parenthese |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_line_no_closing.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_line_no_closing.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"123"': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'name' - it should be 'name("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"123"': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_1.phpt b/src/tests/broken_configuration/broken_conf_local_var_1.phpt index 851d532..dab3b56 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_1.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_1.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_1.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_1.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ']' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ']' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ']' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_10.phpt b/src/tests/broken_configuration/broken_conf_local_var_10.phpt index 747cc5a..7633107 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_10.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_10.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_10.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_10.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]asd' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]asd' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]asd' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_11.phpt b/src/tests/broken_configuration/broken_conf_local_var_11.phpt index 11ca562..f881df4 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_11.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_11.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_11.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_11.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `::` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd::' for `param` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `::` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `::` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd::' for `param` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd::' for `param` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_12.phpt b/src/tests/broken_configuration/broken_conf_local_var_12.phpt index 962f5ab..43dda8a 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_12.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_12.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_12.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_12.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Empty value in `var` on line 1 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Empty value in `var` on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Empty value in `var` on line 1 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_13.phpt b/src/tests/broken_configuration/broken_conf_local_var_13.phpt index 5c33fdd..d771060 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_13.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_13.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_13.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_13.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd->asd' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd->asd' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd->asd' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_14.phpt b/src/tests/broken_configuration/broken_conf_local_var_14.phpt index a831ef7..38225b6 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_14.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_14.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_14.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_14.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i+valid var name . in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i+valid var name ' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i+valid var name . in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i+valid var name . in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i+valid var name ' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i+valid var name ' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_15.phpt b/src/tests/broken_configuration/broken_conf_local_var_15.phpt index 5d8c6f1..d58bccb 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_15.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_15.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_15.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_15.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i$$!@#. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i$$!@#->qwe' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i$$!@#. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i$$!@#. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i$$!@#->qwe' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i$$!@#->qwe' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_16.phpt b/src/tests/broken_configuration/broken_conf_local_var_16.phpt index 47c1f17..2206c7d 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_16.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_16.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_16.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_16.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing a closing quote. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing a closing quote. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing a closing quote. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_2.phpt b/src/tests/broken_configuration/broken_conf_local_var_2.phpt index ec7ac2c..8eb38d0 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_2.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_2.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_2.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_2.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '""asd' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '""asd' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '""asd' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_3.phpt b/src/tests/broken_configuration/broken_conf_local_var_3.phpt index 776cee0..959ae3f 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_3.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_3.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_3.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_3.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$qwe->::' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$qwe->::' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$qwe->::' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_4.phpt b/src/tests/broken_configuration/broken_conf_local_var_4.phpt index 4390640..eab4e26 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_4.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_4.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_4.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_4.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"asd"asd[]' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"asd"asd[]' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"asd"asd[]' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_5.phpt b/src/tests/broken_configuration/broken_conf_local_var_5.phpt index a73056e..2a87994 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_5.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_5.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_5.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_5.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ''asd'asd[]' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ''asd'asd[]' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ''asd'asd[]' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_6.phpt b/src/tests/broken_configuration/broken_conf_local_var_6.phpt index 19b2915..8e69255 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_6.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_6.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_6.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_6.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '''asd' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '''asd' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '''asd' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_7.phpt b/src/tests/broken_configuration/broken_conf_local_var_7.phpt index 62e983f..4fb6047 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_7.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_7.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_7.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_7.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd-->' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd-->' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd-->' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_8.phpt b/src/tests/broken_configuration/broken_conf_local_var_8.phpt index 1d170d2..11187cc 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_8.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_8.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_8.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_8.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]"asd"' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]"asd"' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]"asd"' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_local_var_9.phpt b/src/tests/broken_configuration/broken_conf_local_var_9.phpt index 5786e02..ec97f5d 100644 --- a/src/tests/broken_configuration/broken_conf_local_var_9.phpt +++ b/src/tests/broken_configuration/broken_conf_local_var_9.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_9.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_local_var_9.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]'asd'' for `var` on line 1 in Unknown on line 0 | ||
| 12 | 10 | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 |
| 14 | 12 | ||
diff --git a/src/tests/broken_configuration/broken_conf_lots_of_quotes.phpt b/src/tests/broken_configuration/broken_conf_lots_of_quotes.phpt index bef62b9..0896868 100644 --- a/src/tests/broken_configuration/broken_conf_lots_of_quotes.phpt +++ b/src/tests/broken_configuration/broken_conf_lots_of_quotes.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Configuration line with too many quotes | 2 | Configuration line with too many quotes |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_lots_of_quotes.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_lots_of_quotes.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"this\"is a weird\"\"\"cookie\"name"");': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'name' - it should be 'name("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"this\"is a weird\"\"\"cookie\"name"");': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_missing_script.phpt b/src/tests/broken_configuration/broken_conf_missing_script.phpt index 9deffc7..0b8a183 100644 --- a/src/tests/broken_configuration/broken_conf_missing_script.phpt +++ b/src/tests/broken_configuration/broken_conf_missing_script.phpt | |||
| @@ -1,18 +1,17 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Invalid configuration file for upload | 2 | Invalid configuration file for upload |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
| 6 | file_uploads=1 | 6 | file_uploads=1 |
| 7 | sp.configuration_file={PWD}/config/broken_conf_missing_script.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_missing_script.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | <?php | 10 | <?php |
| 10 | echo 1; | 11 | echo 1; |
| 11 | ?> | 12 | ?> |
| 12 | --EXPECTF-- | 13 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` directive is mandatory in '.enable();' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` directive is mandatory in '.upload_validation' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` directive is mandatory in '.enable();' on line 1 in Unknown on line 0 | ||
| 16 | 15 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive.phpt index a8036d2..df7085a 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").value_r("^id$").drop();': '.r_value' and '.value' are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.value' and '.value_r' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").value_r("^id$").drop();': '.r_value' and '.value' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive10.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive10.phpt index 932f584..de8f909 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive10.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive10.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration - enabled/disabled readonly | 2 | Broken configuration - enabled/disabled readonly |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive10.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive10.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive11.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive11.phpt index 62ae64e..07f5077 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive11.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive11.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration - ret and var are mutually exclusives | 2 | Broken configuration - ret and var are mutually exclusives |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive11.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive11.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").var("hop");':`ret` and `var` are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.ret' and '.var' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").var("hop");':`ret` and `var` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive12.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive12.phpt index 28b0564..8cf2bf0 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive12.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive12.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration - ret and value are mutually exclusive | 2 | Broken configuration - ret and value are mutually exclusive |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive12.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive12.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").value("hop");':`ret` and `value` are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.ret' and '.value' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").value("hop");':`ret` and `value` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive2.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive2.phpt index cc3a951..9474909 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive2.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive2.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive2.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive2.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").function_r("system").param("id").value("42").drop();': '.r_function' and '.function' are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.function' and '.function_r' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").function_r("system").param("id").value("42").drop();': '.r_function' and '.function' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive3.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive3.phpt index ab50266..2730694 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive3.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive3.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive3.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive3.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop();': '.r_filename' and '.filename' are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.filename' and '.filename_r' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop();': '.r_filename' and '.filename' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive4.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive4.phpt index b848d1a..fd7041f 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive4.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive4.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive4.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive4.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").param_r("^id$").drop();':'.r_param', '.param' and '.pos' are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.param' and '.param_r' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").param_r("^id$").drop();':'.r_param', '.param' and '.pos' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive5.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive5.phpt index c668643..7bf1f88 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive5.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive5.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive5.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive5.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().ret_r("^0$");': '.r_ret' and '.ret' are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.ret' and '.ret_r' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().ret_r("^0$");': '.r_ret' and '.ret' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive6.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive6.phpt index 94ed765..2083894 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive6.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive6.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive6.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive6.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").ret_r("^0$").drop();':`ret` and `param` are mutually exclusive on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line for 'sp.disabled_functions': '.ret' and '.param' are mutually exclusive on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").ret_r("^0$").drop();':`ret` and `param` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive7.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive7.phpt index 2a16d0c..64baefd 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive7.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive7.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive7.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive7.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().allow();': The rule must either be a `drop` or `allow` one on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions': The rule must either be a `drop` or `allow` one on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().allow();': The rule must either be a `drop` or `allow` one on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive8.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive8.phpt index 129707d..f8277eb 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive8.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive8.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive8.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive8.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.ret("0").drop();': must take a function name on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions': must take a function name on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.ret("0").drop();': must take a function name on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_mutually_exclusive9.phpt b/src/tests/broken_configuration/broken_conf_mutually_exclusive9.phpt index b384d77..1a62ef0 100644 --- a/src/tests/broken_configuration/broken_conf_mutually_exclusive9.phpt +++ b/src/tests/broken_configuration/broken_conf_mutually_exclusive9.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration - enabled/disabled unserialize | 2 | Broken configuration - enabled/disabled unserialize |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive9.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive9.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_no_cookie_action.phpt b/src/tests/broken_configuration/broken_conf_no_cookie_action.phpt index 62831d4..668e09c 100644 --- a/src/tests/broken_configuration/broken_conf_no_cookie_action.phpt +++ b/src/tests/broken_configuration/broken_conf_no_cookie_action.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Bad config, invalid action. | 2 | Bad config, invalid action. |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_action.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_cookie_action.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a at least one action to a cookie on line 1 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a at least one action to a cookie on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a at least one action to a cookie on line 1 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_no_cookie_name.phpt b/src/tests/broken_configuration/broken_conf_no_cookie_name.phpt index 51d2980..e074411 100644 --- a/src/tests/broken_configuration/broken_conf_no_cookie_name.phpt +++ b/src/tests/broken_configuration/broken_conf_no_cookie_name.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken configuration - encrypted cookie with no name | 2 | Broken configuration - encrypted cookie with no name |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/config_encrypted_cookies_noname.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies_noname.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a cookie name/regexp on line 2 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a cookie name/regexp on line 2 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a cookie name/regexp on line 2 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_nonexisting_script.phpt b/src/tests/broken_configuration/broken_conf_nonexisting_script.phpt index fa891d8..df0c231 100644 --- a/src/tests/broken_configuration/broken_conf_nonexisting_script.phpt +++ b/src/tests/broken_configuration/broken_conf_nonexisting_script.phpt | |||
| @@ -1,17 +1,16 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Invalid configuration file for upload | 2 | Invalid configuration file for upload |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
| 6 | file_uploads=1 | 6 | file_uploads=1 |
| 7 | sp.configuration_file={PWD}/config/broken_conf_nonexisting_script.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_nonexisting_script.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | <?php | 10 | <?php |
| 10 | echo 1; | 11 | echo 1; |
| 11 | ?> | 12 | ?> |
| 12 | --EXPECTF-- | 13 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (./non_existing_script.sh) doesn't exist on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (./non_existing_script.sh) doesn't exist on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (./non_existing_script.sh) doesn't exist on line 1 in Unknown on line 0 |
| 16 | 15 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_quotes.phpt b/src/tests/broken_configuration/broken_conf_quotes.phpt index 5b7b839..da168ae 100644 --- a/src/tests/broken_configuration/broken_conf_quotes.phpt +++ b/src/tests/broken_configuration/broken_conf_quotes.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration - missing quote | 2 | Broken configuration - missing quote |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_quotes.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_quotes.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You forgot to close a bracket. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '_SERVER[PHP_SELF' for `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You forgot to close a bracket. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You forgot to close a bracket. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '_SERVER[PHP_SELF' for `var` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '_SERVER[PHP_SELF' for `var` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_conf_readonly_exec.phpt b/src/tests/broken_configuration/broken_conf_readonly_exec.phpt index 78b2b9a..a53024e 100644 --- a/src/tests/broken_configuration/broken_conf_readonly_exec.phpt +++ b/src/tests/broken_configuration/broken_conf_readonly_exec.phpt | |||
| @@ -1,18 +1,17 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Invalid configuration file for readonly_exec | 2 | Invalid configuration file for readonly_exec |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
| 6 | file_uploads=1 | 6 | file_uploads=1 |
| 7 | sp.configuration_file={PWD}/config/broken_conf_readonly_exec.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_readonly_exec.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | <?php | 10 | <?php |
| 10 | echo 1; | 11 | echo 1; |
| 11 | ?> | 12 | ?> |
| 12 | --EXPECTF-- | 13 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing paranthesis for keyword 'enable' - it should be 'enable()' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | ||
| 16 | 15 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_samesite.phpt b/src/tests/broken_configuration/broken_conf_samesite.phpt index e4940c9..0a39915 100644 --- a/src/tests/broken_configuration/broken_conf_samesite.phpt +++ b/src/tests/broken_configuration/broken_conf_samesite.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Bad config, invalid samesite type. | 2 | Bad config, invalid samesite type. |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_samesite.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_cookie_samesite.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] nop is an invalid value to samesite (expected Lax or Strict) on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] 'nop' is an invalid value to samesite (expected Lax or Strict) on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] nop is an invalid value to samesite (expected Lax or Strict) on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_session_encryption.phpt b/src/tests/broken_configuration/broken_conf_session_encryption.phpt index 9dbedc1..0a031c8 100644 --- a/src/tests/broken_configuration/broken_conf_session_encryption.phpt +++ b/src/tests/broken_configuration/broken_conf_session_encryption.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Broken config, session encryption | 2 | Broken config, session encryption |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_session_encryption.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars 'nvalid value :/);' at the end of '.encrypt(invalid value :/);' on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing paranthesis for keyword 'encrypt' - it should be 'encrypt()' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars 'nvalid value :/);' at the end of '.encrypt(invalid value :/);' on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_session_encryption_without_encryption_key.phpt b/src/tests/broken_configuration/broken_conf_session_encryption_without_encryption_key.phpt index c638f80..63af9e8 100644 --- a/src/tests/broken_configuration/broken_conf_session_encryption_without_encryption_key.phpt +++ b/src/tests/broken_configuration/broken_conf_session_encryption_without_encryption_key.phpt | |||
| @@ -2,14 +2,15 @@ | |||
| 2 | Broken configuration - encrypted session without encryption key | 2 | Broken configuration - encrypted session without encryption key |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 6 | --INI-- | 8 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_encryption_key.ini | 9 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_encryption_key.ini |
| 10 | error_log=/dev/null | ||
| 8 | --FILE-- | 11 | --FILE-- |
| 9 | --EXPECT-- | 12 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in`sp.global`: please set it first in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in `sp.global`: please set it first in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | 14 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 16 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_session_encryption_without_env_var.phpt b/src/tests/broken_configuration/broken_conf_session_encryption_without_env_var.phpt index d503942..80b3a5f 100644 --- a/src/tests/broken_configuration/broken_conf_session_encryption_without_env_var.phpt +++ b/src/tests/broken_configuration/broken_conf_session_encryption_without_env_var.phpt | |||
| @@ -2,14 +2,15 @@ | |||
| 2 | Broken configuration - encrypted session without env var | 2 | Broken configuration - encrypted session without env var |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 6 | --INI-- | 8 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_env_var.ini | 9 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_env_var.ini |
| 10 | error_log=/dev/null | ||
| 8 | --FILE-- | 11 | --FILE-- |
| 9 | --EXPECT-- | 12 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | 14 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 16 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_shown_in_phpinfo.phpt b/src/tests/broken_configuration/broken_conf_shown_in_phpinfo.phpt index 1ad0afb..616bef8 100644 --- a/src/tests/broken_configuration/broken_conf_shown_in_phpinfo.phpt +++ b/src/tests/broken_configuration/broken_conf_shown_in_phpinfo.phpt | |||
| @@ -2,9 +2,9 @@ | |||
| 2 | Broken configuration | 2 | Broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp.ini | 6 | sp.configuration_file={PWD}/config/broken_config_regexp.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php | 9 | <?php |
| 10 | ob_start(); | 10 | ob_start(); |
| @@ -18,12 +18,9 @@ if (strstr($info, 'Valid config => no') !== FALSE) { | |||
| 18 | } | 18 | } |
| 19 | ?> | 19 | ?> |
| 20 | --EXPECTF-- | 20 | --EXPECTF-- |
| 21 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | 21 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %a. in Unknown on line 0 |
| 22 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 23 | 22 | ||
| 24 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | 23 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid regexp '*.' for '.filename_r()' on line 1 in Unknown on line 0 |
| 25 | |||
| 26 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 27 | 24 | ||
| 28 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 25 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 29 | Could not startup. | 26 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_truncated.phpt b/src/tests/broken_configuration/broken_conf_truncated.phpt index 6deff87..06a53a9 100644 --- a/src/tests/broken_configuration/broken_conf_truncated.phpt +++ b/src/tests/broken_configuration/broken_conf_truncated.phpt | |||
| @@ -1,15 +1,13 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Bad boolean value in configuration | 2 | Bad boolean value in configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/config_broken_conf_truncated.ini | 6 | sp.configuration_file={PWD}/config/config_broken_conf_truncated.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'param' - it should be 'param("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_unserialize.phpt b/src/tests/broken_configuration/broken_conf_unserialize.phpt index a42d8a1..e897388 100644 --- a/src/tests/broken_configuration/broken_conf_unserialize.phpt +++ b/src/tests/broken_configuration/broken_conf_unserialize.phpt | |||
| @@ -1,18 +1,17 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Invalid configuration file for unserialize | 2 | Invalid configuration file for unserialize |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
| 6 | file_uploads=1 | 6 | file_uploads=1 |
| 7 | sp.configuration_file={PWD}/config/broken_conf_unserialize.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_unserialize.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | <?php | 10 | <?php |
| 10 | echo 1; | 11 | echo 1; |
| 11 | ?> | 12 | ?> |
| 12 | --EXPECTF-- | 13 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing paranthesis for keyword 'enable' - it should be 'enable()' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | ||
| 16 | 15 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_upload_validation.phpt b/src/tests/broken_configuration/broken_conf_upload_validation.phpt index 4b65339..7c8f604 100644 --- a/src/tests/broken_configuration/broken_conf_upload_validation.phpt +++ b/src/tests/broken_configuration/broken_conf_upload_validation.phpt | |||
| @@ -1,18 +1,17 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Invalid configuration file for upload validation | 2 | Invalid configuration file for upload validation |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
| 6 | file_uploads=1 | 6 | file_uploads=1 |
| 7 | sp.configuration_file={PWD}/config/borken_conf_upload_validation.ini | 7 | sp.configuration_file={PWD}/config/broken_conf_upload_validation.ini |
| 8 | error_log=/dev/null | ||
| 8 | --FILE-- | 9 | --FILE-- |
| 9 | <?php | 10 | <?php |
| 10 | echo 1; | 11 | echo 1; |
| 11 | ?> | 12 | ?> |
| 12 | --EXPECTF-- | 13 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'script' - it should be 'script("...")' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 16 | 15 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_weird_keyword.phpt b/src/tests/broken_configuration/broken_conf_weird_keyword.phpt index ce568af..663f153 100644 --- a/src/tests/broken_configuration/broken_conf_weird_keyword.phpt +++ b/src/tests/broken_configuration/broken_conf_weird_keyword.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Bad config, unknown keyword | 2 | Bad config, unknown keyword |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_weird_keyword.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_weird_keyword.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.not_a_valid_keyword("test");' at the end of '.enable().not_a_valid_keyword("test");' on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Unexpected keyword 'not_a_valid_keyword' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.not_a_valid_keyword("test");' at the end of '.enable().not_a_valid_keyword("test");' on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_wrapper_whitelist.phpt b/src/tests/broken_configuration/broken_conf_wrapper_whitelist.phpt index 2d1feeb..37d074a 100644 --- a/src/tests/broken_configuration/broken_conf_wrapper_whitelist.phpt +++ b/src/tests/broken_configuration/broken_conf_wrapper_whitelist.phpt | |||
| @@ -2,18 +2,16 @@ | |||
| 2 | Broken configuration with invalid token for wrapper whitelist | 2 | Broken configuration with invalid token for wrapper whitelist |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrapper_whitelist.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_wrapper_whitelist.ini |
| 8 | sp.allow_broken_configuration=Off | 7 | sp.allow_broken_configuration=Off |
| 8 | error_log=/dev/null | ||
| 9 | --FILE-- | 9 | --FILE-- |
| 10 | <?php | 10 | <?php |
| 11 | echo 1337; | 11 | echo 1337; |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECT-- | 13 | --EXPECT-- |
| 14 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.invalid_param();' at the end of '.invalid_param();' on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Unexpected keyword 'invalid_param' on line 1 in Unknown on line 0 |
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.invalid_param();' at the end of '.invalid_param();' on line 1 in Unknown on line 0 | ||
| 17 | 15 | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 19 | Could not startup. | 17 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_wrong_quotes.phpt b/src/tests/broken_configuration/broken_conf_wrong_quotes.phpt index 3753989..cd19eb3 100644 --- a/src/tests/broken_configuration/broken_conf_wrong_quotes.phpt +++ b/src/tests/broken_configuration/broken_conf_wrong_quotes.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Configuration line with too many quotes | 2 | Configuration line with too many quotes |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrong_quotes.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_wrong_quotes.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECT-- | 9 | --EXPECT-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"\)': it doesn't look like a valid string on line 1 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing argument to keyword 'name' - it should be 'name("...")' on line 1 in Unknown on line 0 |
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"\)': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 15 | Could not startup. | 13 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_conf_wrong_type.phpt b/src/tests/broken_configuration/broken_conf_wrong_type.phpt index b204968..a24b415 100644 --- a/src/tests/broken_configuration/broken_conf_wrong_type.phpt +++ b/src/tests/broken_configuration/broken_conf_wrong_type.phpt | |||
| @@ -2,13 +2,11 @@ | |||
| 2 | Broken conf with wrong type | 2 | Broken conf with wrong type |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrong_type.ini | 6 | sp.configuration_file={PWD}/config/broken_conf_wrong_type.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][error][log] .ret_type() is expecting a valid php type ('false', 'true', 'array'. 'object', 'long', 'double', 'null', 'resource', 'reference', 'undef') on line 5 in Unknown on line 0 | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] .ret_type() is expecting a valid php type ('false', 'true', 'array'. 'object', 'long', 'double', 'null', 'resource', 'reference', 'undef') on line 5 in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][error][log] .ret_type() is expecting a valid php type ('false', 'true', 'array'. 'object', 'long', 'double', 'null', 'resource', 'reference', 'undef') on line 5 in Unknown on line 0 |
| 13 | 11 | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/broken_regexp.phpt b/src/tests/broken_configuration/broken_regexp.phpt index 83c7103..f216e9a 100644 --- a/src/tests/broken_configuration/broken_regexp.phpt +++ b/src/tests/broken_configuration/broken_regexp.phpt | |||
| @@ -2,17 +2,14 @@ | |||
| 2 | Broken regexp | 2 | Broken regexp |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/broken_regexp.ini | 6 | sp.configuration_file={PWD}/config/broken_regexp.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '^$[': missing terminating ] for character class on line 1. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '^$[': missing terminating ] for character class. in Unknown on line 0 |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] '.value_r()' is expecting a valid regexp, and not '"^$["' on line 1 in Unknown on line 0 | ||
| 12 | 11 | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '^$[': missing terminating ] for character class on line 1. in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid regexp '^$[' for '.value_r()' on line 1 in Unknown on line 0 |
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.value_r()' is expecting a valid regexp, and not '"^$["' on line 1 in Unknown on line 0 | ||
| 16 | 13 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 18 | Could not startup. | 15 | Could not startup. |
diff --git a/src/tests/broken_configuration/broken_unmatching_brackets.phpt b/src/tests/broken_configuration/broken_unmatching_brackets.phpt index ba14ff3..d900eaa 100644 --- a/src/tests/broken_configuration/broken_unmatching_brackets.phpt +++ b/src/tests/broken_configuration/broken_unmatching_brackets.phpt | |||
| @@ -2,14 +2,11 @@ | |||
| 2 | Broken configuration - unmatching brackets | 2 | Broken configuration - unmatching brackets |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/config_unmatching_brackets.ini | 6 | sp.configuration_file={PWD}/config/config_unmatching_brackets.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | --EXPECTF-- | 9 | --EXPECTF-- |
| 10 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'arr[b]]]]]' for `param` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | 10 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 |
| 14 | 11 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'arr[b]]]]]' for `param` on line 1 in Unknown on line 0 | 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'arr[b]]]]]' for `param` on line 1 in Unknown on line 0 |
diff --git a/src/tests/broken_configuration/config/broken_conf_cookie_name_and_regexp.ini b/src/tests/broken_configuration/config/broken_conf_cookie_name_and_regexp.ini index 503889b..6b43b71 100644 --- a/src/tests/broken_configuration/config/broken_conf_cookie_name_and_regexp.ini +++ b/src/tests/broken_configuration/config/broken_conf_cookie_name_and_regexp.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("my_cookie_name").name_r("my_cookie_regexp").encrypt(); | 2 | sp.cookie.name("my_cookie_name").name_r("my_cookie_regexp").encrypt(); |
diff --git a/src/tests/broken_configuration/config/borken_conf_enable_disable.ini b/src/tests/broken_configuration/config/broken_conf_enable_disable.ini index 4e95294..4e95294 100644 --- a/src/tests/broken_configuration/config/borken_conf_enable_disable.ini +++ b/src/tests/broken_configuration/config/broken_conf_enable_disable.ini | |||
diff --git a/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini b/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini new file mode 100644 index 0000000..7ed0c16 --- /dev/null +++ b/src/tests/broken_configuration/config/broken_conf_enable_disable2.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.global_strict.enable(); | ||
| 2 | sp.global_strict.disable(); | ||
| 3 | ;; this is actually not recognised as broken, as there is no internal third state for 'unset' | ||
diff --git a/src/tests/broken_configuration/config/borken_conf_upload_validation.ini b/src/tests/broken_configuration/config/broken_conf_upload_validation.ini index 7c94185..7c94185 100644 --- a/src/tests/broken_configuration/config/borken_conf_upload_validation.ini +++ b/src/tests/broken_configuration/config/broken_conf_upload_validation.ini | |||
diff --git a/src/tests/broken_configuration/config/config_encrypted_cookies_noname.ini b/src/tests/broken_configuration/config/config_encrypted_cookies_noname.ini index 048e404..43a4284 100644 --- a/src/tests/broken_configuration/config/config_encrypted_cookies_noname.ini +++ b/src/tests/broken_configuration/config/config_encrypted_cookies_noname.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("").encrypt(); | 2 | sp.cookie.name("").encrypt(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/broken_configuration/config/config_encrypted_regexp_cookies_bad_regexp.ini b/src/tests/broken_configuration/config/config_encrypted_regexp_cookies_bad_regexp.ini index 4fe92fd..817de14 100644 --- a/src/tests/broken_configuration/config/config_encrypted_regexp_cookies_bad_regexp.ini +++ b/src/tests/broken_configuration/config/config_encrypted_regexp_cookies_bad_regexp.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name_r("^super_co[a-z+$").encrypt(); | 2 | sp.cookie.name_r("^super_co[a-z+$").encrypt(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/broken_configuration/config/config_encryption_key_short.ini b/src/tests/broken_configuration/config/config_encryption_key_short.ini new file mode 100644 index 0000000..7de4438 --- /dev/null +++ b/src/tests/broken_configuration/config/config_encryption_key_short.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.global.secret_key("abcdef"); | |||
diff --git a/src/tests/broken_configuration/encrypt_key_too_short.phpt b/src/tests/broken_configuration/encrypt_key_too_short.phpt new file mode 100644 index 0000000..a6feb6e --- /dev/null +++ b/src/tests/broken_configuration/encrypt_key_too_short.phpt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie encryption key too short | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encryption_key_short.ini | ||
| 7 | error_log=/dev/null | ||
| 8 | --COOKIE-- | ||
| 9 | --ENV-- | ||
| 10 | return <<<EOF | ||
| 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 13 | HTTPS=1 | ||
| 14 | EOF; | ||
| 15 | --FILE-- | ||
| 16 | <?php | ||
| 17 | ?> | ||
| 18 | --EXPECT-- | ||
| 19 | Fatal error: [snuffleupagus][2001:0db8:0000:0000:0000:fe00:0042:8329][config][log] The encryption key set on line 1 is too short. please use at least 10 bytes in Unknown on line 0 | ||
| 20 | |||
| 21 | Fatal error: [snuffleupagus][2001:0db8:0000:0000:0000:fe00:0042:8329][config][log] Invalid configuration file in Unknown on line 0 | ||
| 22 | Could not startup. \ No newline at end of file | ||
diff --git a/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt b/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt index 7a8c909..f660f28 100644 --- a/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt +++ b/src/tests/broken_configuration/encrypt_regexp_cookies_bad_regexp.phpt | |||
| @@ -6,7 +6,7 @@ Cookie decryption in ipv4 | |||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies_bad_regexp.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies_bad_regexp.ini |
| 7 | error_reporting=1 | 7 | error_reporting=1 |
| 8 | --COOKIE-- | 8 | --COOKIE-- |
| 9 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | 9 | super_cookie=IpRZV4rivSjANrEOSxINd%2FdFe17giJgaAAAAAAAAAAAAAAAAAAAAALnmBVs%2BTILKxauHeGcUyJpR%2BX2UiZ6OamUTaWc=;awful_cookie=awful_cookie_value; |
| 10 | --ENV-- | 10 | --ENV-- |
| 11 | return <<<EOF | 11 | return <<<EOF |
| 12 | REMOTE_ADDR=127.0.0.1 | 12 | REMOTE_ADDR=127.0.0.1 |
| @@ -14,9 +14,7 @@ HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like | |||
| 14 | EOF; | 14 | EOF; |
| 15 | --FILE-- | 15 | --FILE-- |
| 16 | <?php var_dump($_COOKIE); ?> | 16 | <?php var_dump($_COOKIE); ?> |
| 17 | --EXPECT-- | 17 | --EXPECTF-- |
| 18 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | 18 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 |
| 19 | 19 | %A | |
| 20 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Failed to compile '^super_co[a-z+$': missing terminating ] for character class on line 2. in Unknown on line 0 | 20 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid regexp '^super_co[a-z+$' for '.name_r()' on line 2 in Unknown on line 0 |
| 21 | |||
| 22 | Fatal error: [snuffleupagus][127.0.0.1][config][log] '.name_r()' is expecting a valid regexp, and not '"^super_co[a-z+$"' on line 2 in Unknown on line 0 | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf.phpt b/src/tests/broken_configuration_php8/broken_conf.phpt deleted file mode 100644 index 7dde7d6..0000000 --- a/src/tests/broken_configuration_php8/broken_conf.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf2.phpt b/src/tests/broken_configuration_php8/broken_conf2.phpt deleted file mode 100644 index bf337b4..0000000 --- a/src/tests/broken_configuration_php8/broken_conf2.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf2.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration section 'sp.wrong' on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_allow_broken_disabled.phpt b/src/tests/broken_configuration_php8/broken_conf_allow_broken_disabled.phpt deleted file mode 100644 index 9dd0c66..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_allow_broken_disabled.phpt +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration with allow broken turned off | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | ||
| 8 | sp.allow_broken_configuration=Off | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | echo 1337; | ||
| 12 | ?> | ||
| 13 | --EXPECT-- | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 18 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_allow_broken_enabled.phpt b/src/tests/broken_configuration_php8/broken_conf_allow_broken_enabled.phpt deleted file mode 100644 index eccc8a8..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_allow_broken_enabled.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration with allow broken turned on | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf.ini | ||
| 8 | sp.allow_broken_configuration=On | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | echo 1337; | ||
| 12 | ?> | ||
| 13 | --EXPECT-- | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration prefix for 'this is a broken line' on line 1 in Unknown on line 0 | ||
| 16 | 1337 | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_config_regexp.phpt b/src/tests/broken_configuration_php8/broken_conf_config_regexp.phpt deleted file mode 100644 index 76ef208..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_config_regexp.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_config_regexp_no_closing_paren.phpt b/src/tests/broken_configuration_php8/broken_conf_config_regexp_no_closing_paren.phpt deleted file mode 100644 index 5bdca06..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_config_regexp_no_closing_paren.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - regexp without a closing parenthesis | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp_no_closing_paren.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"*."': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_encryption_key.phpt b/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_encryption_key.phpt deleted file mode 100644 index 0447320..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_encryption_key.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted cookie without encryption key | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_encryption_key.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.encryption_key` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt b/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt deleted file mode 100644 index 204430d..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_cookie_encryption_without_env_var.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted cookie with without cookie env var | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_encryption_without_env_var.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_cookie_name_and_regexp.phpt b/src/tests/broken_configuration_php8/broken_conf_cookie_name_and_regexp.phpt deleted file mode 100644 index 8648b4f..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_cookie_name_and_regexp.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted cookie with name and regexp | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_name_and_regexp.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] name and name_r are mutually exclusive on line 2 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_enable_disable.phpt b/src/tests/broken_configuration_php8/broken_conf_enable_disable.phpt deleted file mode 100644 index 54e4d32..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_enable_disable.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Global strict mode | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/borken_conf_enable_disable.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_eval.phpt b/src/tests/broken_configuration_php8/broken_conf_eval.phpt deleted file mode 100644 index 1a6ad4d..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_eval.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration for eval | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_eval.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"cos,sin': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_expecting_bool.phpt b/src/tests/broken_configuration_php8/broken_conf_expecting_bool.phpt deleted file mode 100644 index 682a4f5..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_expecting_bool.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Bad boolean value in configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_expecting_bool.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '337);' at the end of '.enable(1337);' on line 5 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_cidr.phpt deleted file mode 100644 index f66d8b6..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '42' isn't a valid ipv4 mask. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6.phpt deleted file mode 100644 index 91bd4a2..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] 'ZZZ' isn't a valid network mask. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_no_slash.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_no_slash.phpt deleted file mode 100644 index c6c8231..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_no_slash.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration, invalid cidr for ipv6 because there is no `/` in it | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_no_slash.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '2001:0db8:0000:0000:0000:ff00:0042:8329' isn't a valid network mask, it seems that you forgot a '/'. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_too_big.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_too_big.phpt deleted file mode 100644 index 47d4a5d..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr6_too_big.phpt +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration, cidr for ipv6 is too big, that will `mod` to 25. | ||
| 3 | (13337%128 = 25) | ||
| 4 | --SKIPIF-- | ||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr6_too_big.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr_value.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_cidr_value.phpt deleted file mode 100644 index dbe5414..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_cidr_value.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration, invalid cidr value | ||
| 3 | (13337%128 = 25) | ||
| 4 | --SKIPIF-- | ||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 6 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 7 | --INI-- | ||
| 8 | sp.configuration_file={PWD}/config/broken_conf_invalid_cidr_value.ini | ||
| 9 | --FILE-- | ||
| 10 | --EXPECT-- | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] " doesn't contain a valid cidr on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_filename.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_filename.phpt deleted file mode 100644 index cb78f85..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_filename.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration filename without absolute path | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_filename.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("sprintf").filename("wrong file name").drop();':'.filename' must be an absolute path or a phar archive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_log_media.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_log_media.phpt deleted file mode 100644 index 68581b6..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_log_media.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration filename with improper log media | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_log_media.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] .log_media() only supports 'syslog' or 'php', on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_invalid_type.phpt b/src/tests/broken_configuration_php8/broken_conf_invalid_type.phpt deleted file mode 100644 index 188d610..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_invalid_type.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken conf with wrong type | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_invalid_type.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"totally_wrong"_type")': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_key_value.phpt b/src/tests/broken_configuration_php8/broken_conf_key_value.phpt deleted file mode 100644 index 1b51bd7..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_key_value.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_key_value.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").var("").value("").key("").drop();':`key` and `value` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_line_empty_string.phpt b/src/tests/broken_configuration_php8/broken_conf_line_empty_string.phpt deleted file mode 100644 index 2d370ac..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_line_empty_string.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Configuration line with an empty string | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_line_empty_string.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_line_no_closing.phpt b/src/tests/broken_configuration_php8/broken_conf_line_no_closing.phpt deleted file mode 100644 index d3c826f..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_line_no_closing.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Configuration line without closing parenthese | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_line_no_closing.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"123"': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_1.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_1.phpt deleted file mode 100644 index 52cd962..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_1.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_1.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ']' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_10.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_10.phpt deleted file mode 100644 index 7817a19..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_10.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_10.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]asd' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_11.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_11.phpt deleted file mode 100644 index 06099a5..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_11.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_11.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `::` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd::' for `param` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_12.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_12.phpt deleted file mode 100644 index df753df..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_12.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_12.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Empty value in `var` on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_13.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_13.phpt deleted file mode 100644 index 80bc068..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_13.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_13.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd->asd' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_14.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_14.phpt deleted file mode 100644 index 749c317..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_14.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_14.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i+valid var name . in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i+valid var name ' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_15.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_15.phpt deleted file mode 100644 index 97eab54..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_15.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_15.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid var name: $i$$!@#. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$i$$!@#->qwe' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_16.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_16.phpt deleted file mode 100644 index c643144..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_16.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_16.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Missing a closing quote. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_2.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_2.phpt deleted file mode 100644 index 8b769af..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_2.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_2.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '""asd' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_3.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_3.phpt deleted file mode 100644 index 850a977..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_3.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_3.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '$qwe->::' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_4.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_4.phpt deleted file mode 100644 index 5146590..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_4.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_4.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `"` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '"asd"asd[]' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_5.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_5.phpt deleted file mode 100644 index a7f8183..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_5.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_5.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value ''asd'asd[]' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_6.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_6.phpt deleted file mode 100644 index 283cb41..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_6.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_6.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `'` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '''asd' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_7.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_7.phpt deleted file mode 100644 index 223e599..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_7.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_7.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `->` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd-->' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_8.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_8.phpt deleted file mode 100644 index 058b5dd..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_8.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_8.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]"asd"' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_local_var_9.phpt b/src/tests/broken_configuration_php8/broken_conf_local_var_9.phpt deleted file mode 100644 index c1eeae6..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_local_var_9.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_local_var_9.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'asd[asd]'asd'' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_lots_of_quotes.phpt b/src/tests/broken_configuration_php8/broken_conf_lots_of_quotes.phpt deleted file mode 100644 index e599e62..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_lots_of_quotes.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Configuration line with too many quotes | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_lots_of_quotes.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"this\"is a weird\"\"\"cookie\"name"");': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_missing_script.phpt b/src/tests/broken_configuration_php8/broken_conf_missing_script.phpt deleted file mode 100644 index 2ddb70f..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_missing_script.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid configuration file for upload | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | file_uploads=1 | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_missing_script.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo 1; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` directive is mandatory in '.enable();' on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive.phpt deleted file mode 100644 index 800cffa..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").value_r("^id$").drop();': '.r_value' and '.value' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive10.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive10.phpt deleted file mode 100644 index c863bf9..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive10.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - enabled/disabled readonly | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive10.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive11.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive11.phpt deleted file mode 100644 index 6bdb959..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive11.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - ret and var are mutually exclusives | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive11.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").var("hop");':`ret` and `var` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive12.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive12.phpt deleted file mode 100644 index 1855fca..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive12.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - ret and value are mutually exclusive | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive12.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("strcmp").drop().ret("hip").value("hop");':`ret` and `value` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive2.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive2.phpt deleted file mode 100644 index 286ea04..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive2.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive2.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").function_r("system").param("id").value("42").drop();': '.r_function' and '.function' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive3.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive3.phpt deleted file mode 100644 index b377179..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive3.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive3.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop();': '.r_filename' and '.filename' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive4.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive4.phpt deleted file mode 100644 index 5f22a47..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive4.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive4.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").param_r("^id$").drop();':'.r_param', '.param' and '.pos' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive5.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive5.phpt deleted file mode 100644 index 55d0eda..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive5.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive5.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().ret_r("^0$");': '.r_ret' and '.ret' are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive6.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive6.phpt deleted file mode 100644 index 7dc6985..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive6.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive6.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").param("id").value("42").ret_r("^0$").drop();':`ret` and `param` are mutually exclusive on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive7.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive7.phpt deleted file mode 100644 index ff7f415..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive7.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive7.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.function("system").ret("0").drop().allow();': The rule must either be a `drop` or `allow` one on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive8.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive8.phpt deleted file mode 100644 index 6ccd508..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive8.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive8.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration line: 'sp.disabled_functions.ret("0").drop();': must take a function name on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive9.phpt b/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive9.phpt deleted file mode 100644 index e4a2d6f..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_mutually_exclusive9.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - enabled/disabled unserialize | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_mutually_exclusive9.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_no_cookie_action.phpt b/src/tests/broken_configuration_php8/broken_conf_no_cookie_action.phpt deleted file mode 100644 index 5fb3f0b..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_no_cookie_action.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Bad config, invalid action. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_action.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a at least one action to a cookie on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_no_cookie_name.phpt b/src/tests/broken_configuration_php8/broken_conf_no_cookie_name.phpt deleted file mode 100644 index 1b2922b..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_no_cookie_name.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted cookie with no name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/config_encrypted_cookies_noname.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You must specify a cookie name/regexp on line 2 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_no_file_specified.phpt b/src/tests/broken_configuration_php8/broken_conf_no_file_specified.phpt deleted file mode 100644 index cb2d95f..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_no_file_specified.phpt +++ /dev/null | |||
| @@ -1,10 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - No configuration file specified | ||
| 3 | --INI-- | ||
| 4 | --SKIPIF-- | ||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 6 | --FILE-- | ||
| 7 | <?php echo "1\n"; ?> | ||
| 8 | --EXPECT-- | ||
| 9 | Warning: [snuffleupagus][0.0.0.0][config][log] No configuration specificed via sp.configuration_file in Unknown on line 0 | ||
| 10 | 1 | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_nonexisting_script.phpt b/src/tests/broken_configuration_php8/broken_conf_nonexisting_script.phpt deleted file mode 100644 index 21717a8..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_nonexisting_script.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid configuration file for upload | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | file_uploads=1 | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_nonexisting_script.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo 1; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (./non_existing_script.sh) doesn't exist on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_quotes.phpt b/src/tests/broken_configuration_php8/broken_conf_quotes.phpt deleted file mode 100644 index d437669..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_quotes.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - missing quote | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_quotes.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You forgot to close a bracket. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value '_SERVER[PHP_SELF' for `var` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_readonly_exec.phpt b/src/tests/broken_configuration_php8/broken_conf_readonly_exec.phpt deleted file mode 100644 index 7e74683..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_readonly_exec.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid configuration file for readonly_exec | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | file_uploads=1 | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_readonly_exec.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo 1; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_samesite.phpt b/src/tests/broken_configuration_php8/broken_conf_samesite.phpt deleted file mode 100644 index c905fd8..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_samesite.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Bad config, invalid samesite type. | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_cookie_samesite.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] nop is an invalid value to samesite (expected Lax or Strict) on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_session_encryption.phpt b/src/tests/broken_configuration_php8/broken_conf_session_encryption.phpt deleted file mode 100644 index 886eb13..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_session_encryption.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken config, session encryption | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars 'nvalid value :/);' at the end of '.encrypt(invalid value :/);' on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt deleted file mode 100644 index 62ee41e..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_encryption_key.phpt +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted session without encryption key | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_encryption_key.ini | ||
| 8 | --FILE-- | ||
| 9 | --XFAIL-- | ||
| 10 | --EXPECT-- | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.secret_key` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 15 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt b/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt deleted file mode 100644 index 5acc1cd..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_session_encryption_without_env_var.phpt +++ /dev/null | |||
| @@ -1,15 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - encrypted session without env var | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_session_encryption_without_env_var.ini | ||
| 8 | --FILE-- | ||
| 9 | --XFAIL-- | ||
| 10 | --EXPECT-- | ||
| 11 | |||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][config][log] You're trying to use the session cookie encryption feature on line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 15 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_shown_in_phpinfo.phpt b/src/tests/broken_configuration_php8/broken_conf_shown_in_phpinfo.phpt deleted file mode 100644 index 2503943..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_shown_in_phpinfo.phpt +++ /dev/null | |||
| @@ -1,27 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_config_regexp.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | ob_start(); | ||
| 11 | phpinfo(); | ||
| 12 | $info = ob_get_clean(); | ||
| 13 | ob_get_clean(); | ||
| 14 | if (strstr($info, 'Valid config => no') !== FALSE) { | ||
| 15 | echo "win"; | ||
| 16 | } else { | ||
| 17 | echo "lose"; | ||
| 18 | } | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | |||
| 22 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '*.': %s on line 1. in Unknown on line 0 | ||
| 23 | |||
| 24 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.filename_r()' is expecting a valid regexp, and not '"*."' on line 1 in Unknown on line 0 | ||
| 25 | |||
| 26 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 27 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_truncated.phpt b/src/tests/broken_configuration_php8/broken_conf_truncated.phpt deleted file mode 100644 index 059dcac..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_truncated.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Bad boolean value in configuration | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/config_broken_conf_truncated.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_unserialize.phpt b/src/tests/broken_configuration_php8/broken_conf_unserialize.phpt deleted file mode 100644 index 327b622..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_unserialize.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid configuration file for unserialize | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | file_uploads=1 | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_unserialize.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo 1; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '234);' at the end of '.enable(1234);' on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_upload_validation.phpt b/src/tests/broken_configuration_php8/broken_conf_upload_validation.phpt deleted file mode 100644 index 9edede6..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_upload_validation.phpt +++ /dev/null | |||
| @@ -1,17 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid configuration file for upload validation | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | file_uploads=1 | ||
| 7 | sp.configuration_file={PWD}/config/borken_conf_upload_validation.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | echo 1; | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][error][log] A valid string as parameter is expected on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 17 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_weird_keyword.phpt b/src/tests/broken_configuration_php8/broken_conf_weird_keyword.phpt deleted file mode 100644 index 75c2e0e..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_weird_keyword.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Bad config, unknown keyword | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_weird_keyword.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.not_a_valid_keyword("test");' at the end of '.enable().not_a_valid_keyword("test");' on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_wrapper_whitelist.phpt b/src/tests/broken_configuration_php8/broken_conf_wrapper_whitelist.phpt deleted file mode 100644 index 0011a6e..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_wrapper_whitelist.phpt +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration with invalid token for wrapper whitelist | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrapper_whitelist.ini | ||
| 8 | sp.allow_broken_configuration=Off | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | echo 1337; | ||
| 12 | ?> | ||
| 13 | --EXPECT-- | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Trailing chars '.invalid_param();' at the end of '.invalid_param();' on line 1 in Unknown on line 0 | ||
| 16 | |||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 18 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_wrong_quotes.phpt b/src/tests/broken_configuration_php8/broken_conf_wrong_quotes.phpt deleted file mode 100644 index b073369..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_wrong_quotes.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Configuration line with too many quotes | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrong_quotes.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECT-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] There is an issue with the parsing of '"\)': it doesn't look like a valid string on line 1 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_conf_wrong_type.phpt b/src/tests/broken_configuration_php8/broken_conf_wrong_type.phpt deleted file mode 100644 index 1f1cead..0000000 --- a/src/tests/broken_configuration_php8/broken_conf_wrong_type.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken conf with wrong type | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_conf_wrong_type.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][error][log] .ret_type() is expecting a valid php type ('false', 'true', 'array'. 'object', 'long', 'double', 'null', 'resource', 'reference', 'undef') on line 5 in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_invalid_client_ip4.phpt b/src/tests/broken_configuration_php8/broken_invalid_client_ip4.phpt deleted file mode 100644 index a96b059..0000000 --- a/src/tests/broken_configuration_php8/broken_invalid_client_ip4.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Invalid client IP | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --ENV-- | ||
| 6 | return <<<EOF | ||
| 7 | REMOTE_ADDR=xyz | ||
| 8 | EOF; | ||
| 9 | --INI-- | ||
| 10 | sp.configuration_file={PWD}/config/disabled_functions_cidr.ini | ||
| 11 | --FILE-- | ||
| 12 | <?php | ||
| 13 | strpos("1337", "1"); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | Fatal error: [snuffleupagus][xyz][cidr_match][log] Weird ip (xyz) family in %a/broken_invalid_client_ip4.php on line 2 \ No newline at end of file | ||
diff --git a/src/tests/broken_configuration_php8/broken_regexp.phpt b/src/tests/broken_configuration_php8/broken_regexp.phpt deleted file mode 100644 index 877f801..0000000 --- a/src/tests/broken_configuration_php8/broken_regexp.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken regexp | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/broken_regexp.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to compile '^$[': missing terminating ] for character class on line 1. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] '.value_r()' is expecting a valid regexp, and not '"^$["' on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/broken_unmatching_brackets.phpt b/src/tests/broken_configuration_php8/broken_unmatching_brackets.phpt deleted file mode 100644 index d143cbd..0000000 --- a/src/tests/broken_configuration_php8/broken_unmatching_brackets.phpt +++ /dev/null | |||
| @@ -1,16 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Broken configuration - unmatching brackets | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/config_unmatching_brackets.ini | ||
| 8 | --FILE-- | ||
| 9 | --EXPECTF-- | ||
| 10 | |||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid `]` position. in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid value 'arr[b]]]]]' for `param` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 16 | Could not startup. | ||
diff --git a/src/tests/broken_configuration_php8/config/borken_conf_enable_disable.ini b/src/tests/broken_configuration_php8/config/borken_conf_enable_disable.ini deleted file mode 100644 index 4e95294..0000000 --- a/src/tests/broken_configuration_php8/config/borken_conf_enable_disable.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.global_strict.disable().enable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/borken_conf_upload_validation.ini b/src/tests/broken_configuration_php8/config/borken_conf_upload_validation.ini deleted file mode 100644 index 7c94185..0000000 --- a/src/tests/broken_configuration_php8/config/borken_conf_upload_validation.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.upload_validation.script( | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf.ini b/src/tests/broken_configuration_php8/config/broken_conf.ini deleted file mode 100644 index 0595320..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | this is a broken line | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf2.ini b/src/tests/broken_configuration_php8/config/broken_conf2.ini deleted file mode 100644 index fdb6b8f..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf2.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.wrong | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_cookie_action.ini b/src/tests/broken_configuration_php8/config/broken_conf_cookie_action.ini deleted file mode 100644 index 5f07c28..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_cookie_action.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name("my_cookie_name"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_encryption_key.ini b/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_encryption_key.ini deleted file mode 100644 index a100bd8..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_encryption_key.ini +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | sp.global.cookie_env_var("MY_SUPER_ENV_VAR_YAY"); | ||
| 2 | sp.cookie.name("my_cookie_name").encrypt(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_env_var.ini b/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_env_var.ini deleted file mode 100644 index 54cb101..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_cookie_encryption_without_env_var.ini +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | sp.global.secret_key("super secret encryption key"); | ||
| 2 | sp.cookie.name("my_cookie_name").encrypt(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_cookie_name_and_regexp.ini b/src/tests/broken_configuration_php8/config/broken_conf_cookie_name_and_regexp.ini deleted file mode 100644 index 503889b..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_cookie_name_and_regexp.ini +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name("my_cookie_name").name_r("my_cookie_regexp").encrypt(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_cookie_samesite.ini b/src/tests/broken_configuration_php8/config/broken_conf_cookie_samesite.ini deleted file mode 100644 index acc4aa0..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_cookie_samesite.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name("my_cookie_name").samesite("nop"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_eval.ini b/src/tests/broken_configuration_php8/config/broken_conf_eval.ini deleted file mode 100644 index 80ef7e5..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_eval.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.eval_blacklist.list("cos,sin | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_expecting_bool.ini b/src/tests/broken_configuration_php8/config/broken_conf_expecting_bool.ini deleted file mode 100644 index 51c28b2..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_expecting_bool.ini +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | # this is an example of broken conf | ||
| 2 | |||
| 3 | |||
| 4 | ; this is another comment | ||
| 5 | sp.harden_random.enable(1337); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr.ini deleted file mode 100644 index b1929c1..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("127.0.0.1/42"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6.ini deleted file mode 100644 index 5e91faf..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("2001:0db8:0000:0000:0000:ff00:0042:8329/ZZZ"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_no_slash.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_no_slash.ini deleted file mode 100644 index 067209f..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_no_slash.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("2001:0db8:0000:0000:0000:ff00:0042:8329"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_too_big.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_too_big.ini deleted file mode 100644 index f82b18b..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr6_too_big.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("2001:0db8:0000:0000:0000:ff00:0042:8329/13337"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr_value.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr_value.ini deleted file mode 100644 index 06a56bd..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_cidr_value.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr(" | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_filename.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_filename.ini deleted file mode 100644 index 1be3b51..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_filename.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("sprintf").filename("wrong file name").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_log_media.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_log_media.ini deleted file mode 100644 index 9e7cea0..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_log_media.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.log_media("pouet"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_invalid_type.ini b/src/tests/broken_configuration_php8/config/broken_conf_invalid_type.ini deleted file mode 100644 index c52994e..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_invalid_type.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("strpos").ret_type("totally_wrong"_type") | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_key_value.ini b/src/tests/broken_configuration_php8/config/broken_conf_key_value.ini deleted file mode 100644 index a0edaf2..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_key_value.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("").value("").key("").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_line_empty_string.ini b/src/tests/broken_configuration_php8/config/broken_conf_line_empty_string.ini deleted file mode 100644 index dfa5520..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_line_empty_string.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name( | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_line_no_closing.ini b/src/tests/broken_configuration_php8/config/broken_conf_line_no_closing.ini deleted file mode 100644 index 6a8c922..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_line_no_closing.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name("123" | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_1.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_1.ini deleted file mode 100644 index ae5165c..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_1.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("]").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_10.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_10.ini deleted file mode 100644 index 93dd07f..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_10.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("asd[asd]asd").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_11.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_11.ini deleted file mode 100644 index 028b1bd..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_11.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").param("asd::").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_12.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_12.ini deleted file mode 100644 index a151960..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_12.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_13.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_13.ini deleted file mode 100644 index e7c9778..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_13.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("asd->asd").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_14.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_14.ini deleted file mode 100644 index 6c98ec3..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_14.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("$i+valid var name ").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_15.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_15.ini deleted file mode 100644 index a8dc5a4..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_15.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("$i$$!@#->qwe").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_16.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_16.ini deleted file mode 100644 index 550719b..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_16.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("\"").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_2.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_2.ini deleted file mode 100644 index 145a3b5..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_2.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("\"\"asd").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_3.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_3.ini deleted file mode 100644 index 5d89076..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_3.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("\$qwe->::").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_4.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_4.ini deleted file mode 100644 index 3ec073b..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_4.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("\"asd\"asd[]").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_5.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_5.ini deleted file mode 100644 index cd350b6..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_5.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("'asd'asd[]").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_6.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_6.ini deleted file mode 100644 index 02f4f1a..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_6.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("''asd").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_7.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_7.ini deleted file mode 100644 index abbd223..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_7.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("asd-->").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_8.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_8.ini deleted file mode 100644 index fd18487..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_8.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("asd[asd]\"asd\"").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_local_var_9.ini b/src/tests/broken_configuration_php8/config/broken_conf_local_var_9.ini deleted file mode 100644 index a311b86..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_local_var_9.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").var("asd[asd]\'asd\'").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_lots_of_quotes.ini b/src/tests/broken_configuration_php8/config/broken_conf_lots_of_quotes.ini deleted file mode 100644 index 189a10d..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_lots_of_quotes.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name("this\"is a weird\"\"\"cookie\"name""); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_missing_script.ini b/src/tests/broken_configuration_php8/config/broken_conf_missing_script.ini deleted file mode 100644 index a46f590..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_missing_script.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.upload_validation.enable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive.ini deleted file mode 100644 index 7ea483f..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").param("id").value("42").value_r("^id$").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive10.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive10.ini deleted file mode 100644 index da8426e..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive10.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.readonly_exec.enable().disable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive11.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive11.ini deleted file mode 100644 index cab163f..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive11.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("strcmp").drop().ret("hip").var("hop"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive12.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive12.ini deleted file mode 100644 index fe140db..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive12.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("strcmp").drop().ret("hip").value("hop"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive2.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive2.ini deleted file mode 100644 index 3ff3ca7..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive2.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").function_r("system").param("id").value("42").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive3.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive3.ini deleted file mode 100644 index f4f7604..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive3.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").param("id").value("42").filename_r("^id$").filename("pouet.txt").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive4.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive4.ini deleted file mode 100644 index c38a727..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive4.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").param("id").value("42").param_r("^id$").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive5.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive5.ini deleted file mode 100644 index 254b2a3..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive5.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").ret("0").drop().ret_r("^0$"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive6.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive6.ini deleted file mode 100644 index 7c6712c..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive6.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").param("id").value("42").ret_r("^0$").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive7.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive7.ini deleted file mode 100644 index feb3486..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive7.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").ret("0").drop().allow(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive8.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive8.ini deleted file mode 100644 index c9c9ea2..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive8.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.ret("0").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive9.ini b/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive9.ini deleted file mode 100644 index 7bf6a62..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_mutually_exclusive9.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.unserialize_hmac.enable().disable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_nonexisting_script.ini b/src/tests/broken_configuration_php8/config/broken_conf_nonexisting_script.ini deleted file mode 100644 index 8327438..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_nonexisting_script.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.upload_validation.enable().script("./non_existing_script.sh"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_quotes.ini b/src/tests/broken_configuration_php8/config/broken_conf_quotes.ini deleted file mode 100644 index eac8739..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_quotes.ini +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").filename("/static_pages/index.php").var("_SERVER[PHP_SELF").value_r("\"").drop().alias("XSS"); | ||
| 2 | sp.disable_function.filename("include/imageobject_im.class.php").function("exec").var("CONFIG[im_options]).value_r("[^a-z0-9]").drop(); | ||
| 3 | |||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_readonly_exec.ini b/src/tests/broken_configuration_php8/config/broken_conf_readonly_exec.ini deleted file mode 100644 index 9e11313..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_readonly_exec.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.readonly_exec.enable(1234); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption.ini b/src/tests/broken_configuration_php8/config/broken_conf_session_encryption.ini deleted file mode 100644 index 66b7956..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.session.encrypt(invalid value :/); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_encryption_key.ini b/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_encryption_key.ini deleted file mode 100644 index 2b6f674..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_encryption_key.ini +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | sp.global.cookie_env_var("MY_SUPER_ENV_VAR_YAY"); | ||
| 2 | sp.session.encrypt(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_env_var.ini b/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_env_var.ini deleted file mode 100644 index 43caf4a..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_session_encryption_without_env_var.ini +++ /dev/null | |||
| @@ -1,2 +0,0 @@ | |||
| 1 | sp.global.secret_key("super secret key, shhhh"); | ||
| 2 | sp.session.encrypt(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_to_few_args.ini b/src/tests/broken_configuration_php8/config/broken_conf_to_few_args.ini deleted file mode 100644 index 89e19be..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_to_few_args.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.harden_random.enable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_unserialize.ini b/src/tests/broken_configuration_php8/config/broken_conf_unserialize.ini deleted file mode 100644 index 9cdc9a6..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_unserialize.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.unserialize_hmac.enable(1234); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_weird_keyword.ini b/src/tests/broken_configuration_php8/config/broken_conf_weird_keyword.ini deleted file mode 100644 index bf5e7f5..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_weird_keyword.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.harden_random.enable().not_a_valid_keyword("test"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_wrapper_whitelist.ini b/src/tests/broken_configuration_php8/config/broken_conf_wrapper_whitelist.ini deleted file mode 100644 index b8e08a8..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_wrapper_whitelist.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.wrappers_whitelist.invalid_param(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_wrong_quotes.ini b/src/tests/broken_configuration_php8/config/broken_conf_wrong_quotes.ini deleted file mode 100644 index ff41f93..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_wrong_quotes.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.cookie.name("\) | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_conf_wrong_type.ini b/src/tests/broken_configuration_php8/config/broken_conf_wrong_type.ini deleted file mode 100644 index b2943db..0000000 --- a/src/tests/broken_configuration_php8/config/broken_conf_wrong_type.ini +++ /dev/null | |||
| @@ -1,5 +0,0 @@ | |||
| 1 | sp.disable_function.function("strpos").ret_type("undef").drop().alias("Return value is undef"); | ||
| 2 | sp.disable_function.function("strpos").ret_type("null").drop().alias("Return value is null"); | ||
| 3 | sp.disable_function.function("strpos").ret_type("object").drop().alias("Return value is object"); | ||
| 4 | sp.disable_function.function("strpos").ret_type("reference").drop().alias("Return value is reference"); | ||
| 5 | sp.disable_function.function("strpos").ret_type("totally_wrong_type").drop().alias("Return value is FALSE"); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_config_regexp.ini b/src/tests/broken_configuration_php8/config/broken_config_regexp.ini deleted file mode 100644 index 62bed11..0000000 --- a/src/tests/broken_configuration_php8/config/broken_config_regexp.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function_r("^system$").filename_r("*.").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_config_regexp_no_closing_paren.ini b/src/tests/broken_configuration_php8/config/broken_config_regexp_no_closing_paren.ini deleted file mode 100644 index 93e150b..0000000 --- a/src/tests/broken_configuration_php8/config/broken_config_regexp_no_closing_paren.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function_r("^system$").drop().filename_r("*." | ||
diff --git a/src/tests/broken_configuration_php8/config/broken_regexp.ini b/src/tests/broken_configuration_php8/config/broken_regexp.ini deleted file mode 100644 index 8e4bf69..0000000 --- a/src/tests/broken_configuration_php8/config/broken_regexp.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("AwesomeClass::method3").param("a").drop().value_r("^$["); | ||
diff --git a/src/tests/broken_configuration_php8/config/config_broken_conf_truncated.ini b/src/tests/broken_configuration_php8/config/config_broken_conf_truncated.ini deleted file mode 100644 index bf05dfb..0000000 --- a/src/tests/broken_configuration_php8/config/config_broken_conf_truncated.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("").param(no quote, omg! | ||
diff --git a/src/tests/broken_configuration_php8/config/config_encrypted_cookies_noname.ini b/src/tests/broken_configuration_php8/config/config_encrypted_cookies_noname.ini deleted file mode 100644 index 048e404..0000000 --- a/src/tests/broken_configuration_php8/config/config_encrypted_cookies_noname.ini +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name("").encrypt(); | ||
| 3 | sp.auto_cookie_secure.enable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/config_encrypted_regexp_cookies_bad_regexp.ini b/src/tests/broken_configuration_php8/config/config_encrypted_regexp_cookies_bad_regexp.ini deleted file mode 100644 index 4fe92fd..0000000 --- a/src/tests/broken_configuration_php8/config/config_encrypted_regexp_cookies_bad_regexp.ini +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | ||
| 2 | sp.cookie.name_r("^super_co[a-z+$").encrypt(); | ||
| 3 | sp.auto_cookie_secure.enable(); | ||
diff --git a/src/tests/broken_configuration_php8/config/config_unmatching_brackets.ini b/src/tests/broken_configuration_php8/config/config_unmatching_brackets.ini deleted file mode 100644 index 45fa4fe..0000000 --- a/src/tests/broken_configuration_php8/config/config_unmatching_brackets.ini +++ /dev/null | |||
| @@ -1 +0,0 @@ | |||
| 1 | sp.disable_function.function("foo").param("arr[b]]]]]").value("aaa").alias("4").drop(); | ||
diff --git a/src/tests/broken_configuration_php8/config/disabled_functions_cidr.ini b/src/tests/broken_configuration_php8/config/disabled_functions_cidr.ini deleted file mode 100644 index f69ce07..0000000 --- a/src/tests/broken_configuration_php8/config/disabled_functions_cidr.ini +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | sp.disable_function.function("system").drop().cidr("2001:ab9:a::123/64"); | ||
| 2 | sp.disable_function.function("system").drop().cidr("192.168.0.1/16"); | ||
| 3 | sp.disable_function.function("system").drop().cidr("127.0.0.1/8"); | ||
| 4 | sp.disable_function.function("printf").drop().cidr("10.0.0.1/8"); | ||
| 5 | sp.disable_function.function("strpos").drop().cidr("127.0.0.2/4"); | ||
| 6 | sp.disable_function.function("strpos").drop().cidr("::ffff:192.0.2.128/128"); | ||
| 7 | sp.disable_function.function("strpos").drop().cidr("2001:ab9:a::123/64"); | ||
| 8 | sp.disable_function.function("strpos").drop().cidr("2001:0db8:f000:f000:f000:ff00:0042:8329/124"); | ||
| 9 | sp.disable_function.function("printf").drop().cidr("2002:0db8:0000:0000:0000:ff00:0042:8329/24"); | ||
diff --git a/src/tests/broken_configuration_php8/encrypt_regexp_cookies_bad_regexp.phpt b/src/tests/broken_configuration_php8/encrypt_regexp_cookies_bad_regexp.phpt deleted file mode 100644 index 7a8c909..0000000 --- a/src/tests/broken_configuration_php8/encrypt_regexp_cookies_bad_regexp.phpt +++ /dev/null | |||
| @@ -1,22 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Cookie decryption in ipv4 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies_bad_regexp.ini | ||
| 7 | error_reporting=1 | ||
| 8 | --COOKIE-- | ||
| 9 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | ||
| 10 | --ENV-- | ||
| 11 | return <<<EOF | ||
| 12 | REMOTE_ADDR=127.0.0.1 | ||
| 13 | HTTP_USER_AGENT=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/59.0.3071.109 Chrome/59.0.3071.109 Safari/537.36 | ||
| 14 | EOF; | ||
| 15 | --FILE-- | ||
| 16 | <?php var_dump($_COOKIE); ?> | ||
| 17 | --EXPECT-- | ||
| 18 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | ||
| 19 | |||
| 20 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Failed to compile '^super_co[a-z+$': missing terminating ] for character class on line 2. in Unknown on line 0 | ||
| 21 | |||
| 22 | Fatal error: [snuffleupagus][127.0.0.1][config][log] '.name_r()' is expecting a valid regexp, and not '"^super_co[a-z+$"' on line 2 in Unknown on line 0 | ||
diff --git a/src/tests/config/config_samesite_cookies.ini b/src/tests/config/config_samesite_cookies.ini index 1ca498a..627ff3e 100644 --- a/src/tests/config/config_samesite_cookies.ini +++ b/src/tests/config/config_samesite_cookies.ini | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("super_cookie").samesite("Lax"); | 2 | sp.cookie.name("super_cookie").samesite("Lax"); |
| 3 | sp.cookie.name("awful_cookie").samesite("strict").encrypt(); | 3 | sp.cookie.name("awful_cookie").samesite("strict").encrypt(); |
| 4 | sp.cookie.name("nice_cookie").samesite("STRICT").encrypt(); | 4 | sp.cookie.name("nice_cookie").samesite("STRICT").encrypt(); |
diff --git a/src/tests/config/phplog.ini b/src/tests/config/phplog.ini index 4eaa287..7126996 100644 --- a/src/tests/config/phplog.ini +++ b/src/tests/config/phplog.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable(); | 2 | sp.unserialize_hmac.enable(); |
| 3 | sp.log_media("php"); | 3 | sp.log_media("php"); |
diff --git a/src/tests/config/sid_length_limit.ini b/src/tests/config/sid_length_limit.ini new file mode 100644 index 0000000..f6ef335 --- /dev/null +++ b/src/tests/config/sid_length_limit.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.session.sid_min_length("10").sid_max_length("32"); \ No newline at end of file | |||
diff --git a/src/tests/config/syslog.ini b/src/tests/config/syslog.ini index 17dce05..2210975 100644 --- a/src/tests/config/syslog.ini +++ b/src/tests/config/syslog.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable(); | 2 | sp.unserialize_hmac.enable(); |
| 3 | sp.log_media("syslog"); | 3 | sp.log_media("syslog"); |
diff --git a/src/tests/config/syslog_simulation.ini b/src/tests/config/syslog_simulation.ini index bb52850..4100444 100644 --- a/src/tests/config/syslog_simulation.ini +++ b/src/tests/config/syslog_simulation.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable().simulation(); | 2 | sp.unserialize_hmac.enable().simulation(); |
| 3 | sp.log_media("syslog"); | 3 | sp.log_media("syslog"); |
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies.ini index 4b50440..2d82478 100644 --- a/src/tests/cookies_encryption/config/config_encrypted_cookies.ini +++ b/src/tests/cookies_encryption/config/config_encrypted_cookies.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("super_cookie").encrypt(); | 2 | sp.cookie.name("super_cookie").encrypt(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini index 8368d65..311e0ca 100644 --- a/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini +++ b/src/tests/cookies_encryption/config/config_encrypted_cookies_empty_env.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("SUPER_ENV_VAR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("SUPER_ENV_VAR"); |
| 2 | sp.cookie.name("super_cookie").encrypt(); | 2 | sp.cookie.name("super_cookie").encrypt(); |
diff --git a/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini b/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini index 32e24a1..f4f9acc 100644 --- a/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini +++ b/src/tests/cookies_encryption/config/config_encrypted_cookies_simulation.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("super_cookie").encrypt().simulation(); | 2 | sp.cookie.name("super_cookie").encrypt().simulation(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini index 8ea77f7..b6fc8b7 100644 --- a/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini +++ b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name_r("^super_co[a-z]+$").encrypt(); | 2 | sp.cookie.name_r("^super_co[a-z]+$").encrypt(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini index da84df7..43f6f94 100644 --- a/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini +++ b/src/tests/cookies_encryption/config/config_encrypted_regexp_cookies_empty_env.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name_r("^super_coo[a-z]+$").encrypt(); | 2 | sp.cookie.name_r("^super_coo[a-z]+$").encrypt(); |
diff --git a/src/tests/cookies_encryption/config/encryption_key_only.ini b/src/tests/cookies_encryption/config/encryption_key_only.ini index 7de4438..e107f15 100644 --- a/src/tests/cookies_encryption/config/encryption_key_only.ini +++ b/src/tests/cookies_encryption/config/encryption_key_only.ini | |||
| @@ -1 +1 @@ | |||
| sp.global.secret_key("abcdef"); | sp.global.secret_key("abcdefGHIJ"); | ||
diff --git a/src/tests/cookies_encryption/encrypt_cookies.phpt b/src/tests/cookies_encryption/encrypt_cookies.phpt index 49587b7..21ec0ed 100644 --- a/src/tests/cookies_encryption/encrypt_cookies.phpt +++ b/src/tests/cookies_encryption/encrypt_cookies.phpt | |||
| @@ -5,7 +5,7 @@ Cookie decryption in ipv4 | |||
| 5 | --INI-- | 5 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_cookies.ini |
| 7 | --COOKIE-- | 7 | --COOKIE-- |
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | 8 | super_cookie=IpRZV4rivSjANrEOSxINd%2FdFe17giJgaAAAAAAAAAAAAAAAAAAAAALnmBVs%2BTILKxauHeGcUyJpR%2BX2UiZ6OamUTaWc=;awful_cookie=awful_cookie_value; |
| 9 | --ENV-- | 9 | --ENV-- |
| 10 | return <<<EOF | 10 | return <<<EOF |
| 11 | REMOTE_ADDR=127.0.0.1 | 11 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/cookies_encryption/encrypt_cookies3.phpt b/src/tests/cookies_encryption/encrypt_cookies3.phpt index beb4efb..f5cadcb 100644 --- a/src/tests/cookies_encryption/encrypt_cookies3.phpt +++ b/src/tests/cookies_encryption/encrypt_cookies3.phpt | |||
| @@ -5,7 +5,7 @@ Cookie decryption with ipv6 | |||
| 5 | --INI-- | 5 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini |
| 7 | --COOKIE-- | 7 | --COOKIE-- |
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABM84SCotZTpP6b27Lr5lavORPMvqaKpcUahvxw=;awful_cookie=awful_cookie_value; | 8 | super_cookie=eFXrR4GCQtT4Q7%2FLRVtDBH44aMC4hI33AAAAAAAAAAAAAAAAAAAAAGrtoM2Mltxj8%2B9dELwitKN42C8ZE1kYX%2BKWwjM%3D;awful_cookie=awful_cookie_value; |
| 9 | --ENV-- | 9 | --ENV-- |
| 10 | return <<<EOF | 10 | return <<<EOF |
| 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 |
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt index 5ec6af5..0c8d024 100644 --- a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption2.phpt | |||
| @@ -16,4 +16,4 @@ EOF; | |||
| 16 | --FILE-- | 16 | --FILE-- |
| 17 | <?php var_dump($_COOKIE); ?> | 17 | <?php var_dump($_COOKIE); ?> |
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | 19 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file |
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt index 00a2cec..53f4f3f 100644 --- a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_short_cookie.phpt | |||
| @@ -16,7 +16,7 @@ EOF; | |||
| 16 | --FILE-- | 16 | --FILE-- |
| 17 | <?php var_dump($_COOKIE); ?> | 17 | <?php var_dump($_COOKIE); ?> |
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for super_cookie. Using the cookie 'as it' instead of decrypting it in Unknown on line 0 | 19 | Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for super_cookie. Using the cookie 'as is' instead of decrypting it in Unknown on line 0 |
| 20 | array(2) { | 20 | array(2) { |
| 21 | ["super_cookie"]=> | 21 | ["super_cookie"]=> |
| 22 | string(3) "AAA" | 22 | string(3) "AAA" |
diff --git a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt index 4d8e18d..eefa507 100644 --- a/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt +++ b/src/tests/cookies_encryption/encrypt_cookies_invalid_decryption_simulation.phpt | |||
| @@ -18,7 +18,7 @@ EOF; | |||
| 18 | echo "1337\n"; | 18 | echo "1337\n"; |
| 19 | var_dump($_COOKIE); ?> | 19 | var_dump($_COOKIE); ?> |
| 20 | --EXPECT-- | 20 | --EXPECT-- |
| 21 | Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Something went wrong with the decryption of super_cookie. Using the cookie 'as it' instead of decrypting it in Unknown on line 0 | 21 | Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Something went wrong with the decryption of super_cookie. Using the cookie 'as is' instead of decrypting it in Unknown on line 0 |
| 22 | 1337 | 22 | 1337 |
| 23 | array(2) { | 23 | array(2) { |
| 24 | ["super_cookie"]=> | 24 | ["super_cookie"]=> |
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt index da44855..41c4f2a 100644 --- a/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies.phpt | |||
| @@ -5,7 +5,7 @@ Cookie decryption in ipv4 | |||
| 5 | --INI-- | 5 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini |
| 7 | --COOKIE-- | 7 | --COOKIE-- |
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP3gV9YJZL/pUeNAjCKFW0U2ywmf1CwHzwd2pWM=;awful_cookie=awful_cookie_value; | 8 | super_cookie=IpRZV4rivSjANrEOSxINd%2FdFe17giJgaAAAAAAAAAAAAAAAAAAAAALnmBVs%2BTILKxauHeGcUyJpR%2BX2UiZ6OamUTaWc=;awful_cookie=awful_cookie_value; |
| 9 | --ENV-- | 9 | --ENV-- |
| 10 | return <<<EOF | 10 | return <<<EOF |
| 11 | REMOTE_ADDR=127.0.0.1 | 11 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt index beb4efb..09f0a75 100644 --- a/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies3.phpt | |||
| @@ -5,7 +5,7 @@ Cookie decryption with ipv6 | |||
| 5 | --INI-- | 5 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini | 6 | sp.configuration_file={PWD}/config/config_encrypted_regexp_cookies.ini |
| 7 | --COOKIE-- | 7 | --COOKIE-- |
| 8 | super_cookie=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABM84SCotZTpP6b27Lr5lavORPMvqaKpcUahvxw=;awful_cookie=awful_cookie_value; | 8 | super_cookie=mzOxoJ9o9Y83iYX15DkJmYrW%2FrJfyB2SAAAAAAAAAAAAAAAAAAAAAKe5DegjtjwoFZirOY4LO6jSlqtZdF%2FUMriwn8w=;awful_cookie=awful_cookie_value; |
| 9 | --ENV-- | 9 | --ENV-- |
| 10 | return <<<EOF | 10 | return <<<EOF |
| 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 | 11 | REMOTE_ADDR=2001:0db8:0000:0000:0000:fe00:0042:8329 |
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt index 53f2eba..1886cfc 100644 --- a/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies_empty_env.phpt | |||
| @@ -16,4 +16,4 @@ EOF; | |||
| 16 | --FILE-- | 16 | --FILE-- |
| 17 | <?php echo "1\n\n\n\n\n"; ?> | 17 | <?php echo "1\n\n\n\n\n"; ?> |
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][0.0.0.0][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | 19 | Fatal error: [snuffleupagus][0.0.0.0][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file |
diff --git a/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt index 29444dc..d86433e 100644 --- a/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt +++ b/src/tests/cookies_encryption/encrypt_regexp_cookies_invalid_decryption2.phpt | |||
| @@ -16,4 +16,4 @@ EOF; | |||
| 16 | --FILE-- | 16 | --FILE-- |
| 17 | <?php var_dump($_COOKIE); ?> | 17 | <?php var_dump($_COOKIE); ?> |
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file | 19 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in Unknown on line 0 \ No newline at end of file |
diff --git a/src/tests/cookies_encryption_warning/config/encrypt_cookies_no_env.ini b/src/tests/cookies_encryption_warning/config/encrypt_cookies_no_env.ini index 845bd02..b72b311 100644 --- a/src/tests/cookies_encryption_warning/config/encrypt_cookies_no_env.ini +++ b/src/tests/cookies_encryption_warning/config/encrypt_cookies_no_env.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.cookie.name("super_cookie").encrypt(); | 2 | sp.cookie.name("super_cookie").encrypt(); |
diff --git a/src/tests/cookies_encryption_warning/config/encrypt_regexp_cookies_no_env.ini b/src/tests/cookies_encryption_warning/config/encrypt_regexp_cookies_no_env.ini index 0e1fa30..d4c4535 100644 --- a/src/tests/cookies_encryption_warning/config/encrypt_regexp_cookies_no_env.ini +++ b/src/tests/cookies_encryption_warning/config/encrypt_regexp_cookies_no_env.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.cookie.name_r("^super_co[a-z]+$").encrypt(); | 2 | sp.cookie.name_r("^super_co[a-z]+$").encrypt(); |
diff --git a/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt b/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt index 015c159..b31bf78 100644 --- a/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_cookies_no_env.phpt | |||
| @@ -18,4 +18,4 @@ EOF; | |||
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 |
| 20 | 20 | ||
| 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/cookies_encryption_warning/encrypt_cookies_no_key.phpt b/src/tests/cookies_encryption_warning/encrypt_cookies_no_key.phpt index 42f5509..c47389c 100644 --- a/src/tests/cookies_encryption_warning/encrypt_cookies_no_key.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_cookies_no_key.phpt | |||
| @@ -18,4 +18,4 @@ EOF; | |||
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 |
| 20 | 20 | ||
| 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.encryption_key` option in`sp.global`: please set it first in Unknown on line 0 | 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.secret_key` option in `sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt index 163cb26..d4b7e6a 100644 --- a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_env.phpt | |||
| @@ -18,4 +18,4 @@ EOF; | |||
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 |
| 20 | 20 | ||
| 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.cookie_env_var` option in`sp.global`: please set it first in Unknown on line 0 | 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.cookie_env_var` option in `sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_key.phpt b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_key.phpt index df31f2e..0da0dbe 100644 --- a/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_key.phpt +++ b/src/tests/cookies_encryption_warning/encrypt_regexp_cookies_no_key.phpt | |||
| @@ -18,4 +18,4 @@ EOF; | |||
| 18 | --EXPECT-- | 18 | --EXPECT-- |
| 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 | 19 | Fatal error: [snuffleupagus][127.0.0.1][config][log] Invalid configuration file in Unknown on line 0 |
| 20 | 20 | ||
| 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption featureon line 2 without having set the `.encryption_key` option in`sp.global`: please set it first in Unknown on line 0 | 21 | Fatal error: [snuffleupagus][127.0.0.1][config][log] You're trying to use the cookie encryption feature on line 2 without having set the `.secret_key` option in `sp.global`: please set it first in Unknown on line 0 |
diff --git a/src/tests/cookies_php8/config/config_encrypted_cookies.ini b/src/tests/cookies_php8/config/config_encrypted_cookies.ini index 4b50440..2d82478 100644 --- a/src/tests/cookies_php8/config/config_encrypted_cookies.ini +++ b/src/tests/cookies_php8/config/config_encrypted_cookies.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.cookie.name("super_cookie").encrypt(); | 2 | sp.cookie.name("super_cookie").encrypt(); |
| 3 | sp.auto_cookie_secure.enable(); | 3 | sp.auto_cookie_secure.enable(); |
diff --git a/src/tests/deny_writable/deny_writable_execution_simulation.phpt b/src/tests/deny_writable/deny_writable_execution_simulation.phpt index d4b8efc..1118dc0 100644 --- a/src/tests/deny_writable/deny_writable_execution_simulation.phpt +++ b/src/tests/deny_writable/deny_writable_execution_simulation.phpt | |||
| @@ -18,7 +18,6 @@ if (TRUE == function_exists("posix_getuid")) { | |||
| 18 | ?> | 18 | ?> |
| 19 | --INI-- | 19 | --INI-- |
| 20 | sp.configuration_file={PWD}/config/config_disable_writable_simulation.ini | 20 | sp.configuration_file={PWD}/config/config_disable_writable_simulation.ini |
| 21 | --XFAIL-- | ||
| 22 | --FILE-- | 21 | --FILE-- |
| 23 | <?php | 22 | <?php |
| 24 | $dir = __DIR__; | 23 | $dir = __DIR__; |
diff --git a/src/tests/disable_function/config/disabled_function_excess_args.ini b/src/tests/disable_function/config/disabled_function_excess_args.ini new file mode 100644 index 0000000..289dc33 --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_excess_args.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foo_excess_args").pos("3").value("blubb").drop() | |||
diff --git a/src/tests/disable_function/config/disabled_function_log_forging.ini b/src/tests/disable_function/config/disabled_function_log_forging.ini new file mode 100644 index 0000000..05e9b4b --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_log_forging.ini | |||
| @@ -0,0 +1 @@ | |||
| sp.disable_function.function("foo_log_forging").pos("0").value_r("^x").drop() | |||
diff --git a/src/tests/disable_function/config/disabled_function_named_args.ini b/src/tests/disable_function/config/disabled_function_named_args.ini new file mode 100644 index 0000000..094bc0d --- /dev/null +++ b/src/tests/disable_function/config/disabled_function_named_args.ini | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | sp.disable_function.function("foo_named_args_pos").pos("0").value("bob").drop() | ||
| 2 | sp.disable_function.function("foo_named_args_param").param("name").value("bob").drop() | ||
| 3 | |||
| 4 | sp.disable_function.function("foo_named_args_ooo_pos").pos("0").value("bob").drop() | ||
| 5 | sp.disable_function.function("foo_named_args_ooo_param").param("name").value("bob").drop() | ||
| 6 | |||
| 7 | sp.disable_function.function("foo_named_args_ooo_opt_pos").pos("2").value("green").drop() | ||
| 8 | sp.disable_function.function("foo_named_args_ooo_opt_param").param("color").value("green").drop() | ||
| 9 | |||
| 10 | sp.disable_function.function("foo_named_args_skip_pos").pos("2").value("green").drop() | ||
| 11 | sp.disable_function.function("foo_named_args_skip_param").param("color").value("green").drop() | ||
| 12 | |||
diff --git a/src/tests/disable_function/config/disabled_functions_chmod.ini b/src/tests/disable_function/config/disabled_functions_chmod.ini index e601900..22b0af2 100644 --- a/src/tests/disable_function/config/disabled_functions_chmod.ini +++ b/src/tests/disable_function/config/disabled_functions_chmod.ini | |||
| @@ -1,4 +1,2 @@ | |||
| 1 | # PHP7 and below | 1 | # PHP7 and below |
| 2 | sp.disable_function.function("chmod").param("mode").value("511").drop(); | 2 | sp.disable_function.function("chmod").param("mode").value("511").drop(); |
| 3 | # PHP8 | ||
| 4 | sp.disable_function.function("chmod").param("permissions").value("511").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_chmod_php8.ini b/src/tests/disable_function/config/disabled_functions_chmod_php8.ini new file mode 100644 index 0000000..d07dd31 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_chmod_php8.ini | |||
| @@ -0,0 +1,2 @@ | |||
| 1 | # PHP8 | ||
| 2 | sp.disable_function.function("chmod").param("permissions").value("511").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_extra.ini b/src/tests/disable_function/config/disabled_functions_extra.ini new file mode 100644 index 0000000..305c4b3 --- /dev/null +++ b/src/tests/disable_function/config/disabled_functions_extra.ini | |||
| @@ -0,0 +1,7 @@ | |||
| 1 | sp.disable_function.function("shell_exec").pos("0").value("ls").drop(); | ||
| 2 | sp.disable_function.function("exec").drop(); | ||
| 3 | sp.disable_function.function("passthru").drop(); | ||
| 4 | #sp.disable_function.function("system").drop(); | ||
| 5 | sp.disable_function.function("proc_open").drop(); | ||
| 6 | sp.disable_function.function("popen").drop(); | ||
| 7 | sp.disable_function.function("phpinfo").drop(); | ||
diff --git a/src/tests/disable_function/config/disabled_functions_pos.ini b/src/tests/disable_function/config/disabled_functions_pos.ini index f4c1e05..8b12fc6 100644 --- a/src/tests/disable_function/config/disabled_functions_pos.ini +++ b/src/tests/disable_function/config/disabled_functions_pos.ini | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | sp.disable_function.function("system").pos("1337").value("id").drop(); | 1 | sp.disable_function.function("system").pos("1337").value("id").drop(); |
| 2 | sp.disable_function.function("system").pos("0").value("id").drop(); | 2 | sp.disable_function.function("system").pos("0").value("id").drop(); |
| 3 | sp.disable_function.function("system").pos("1").param_type("ARRAY").alias("1").drop(); | 3 | sp.disable_function.function("system").pos("0").param_type("ARRAY").alias("1").drop(); |
| 4 | sp.disable_function.function("strtoupper").pos("0").value("id").alias("strlen array").drop(); | 4 | sp.disable_function.function("strtoupper").pos("0").value("id").alias("strlen array").drop(); |
diff --git a/src/tests/disable_function/disabled_function_excess_args.phpt b/src/tests/disable_function/disabled_function_excess_args.phpt new file mode 100644 index 0000000..31b3f33 --- /dev/null +++ b/src/tests/disable_function/disabled_function_excess_args.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with excess arguments | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_excess_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_excess_args($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_excess_args("bob", "hi", "green", "blubb"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_excess_args' in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_log_forging.phpt b/src/tests/disable_function/disabled_function_log_forging.phpt new file mode 100644 index 0000000..fcc37dc --- /dev/null +++ b/src/tests/disable_function/disabled_function_log_forging.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions log forging test | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_log_forging.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_log_forging($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_log_forging("x' matched a rule in /etc/passwd on line 1\nFatal error: [snuffleupagus][0.0.0.0][silly_error][drop] secondary problem '<script>alert('0wned!');</script>"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_log_forging', because its argument 'name' %s on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt new file mode 100644 index 0000000..6ca49d4 --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_ooo_opt_param.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with out-of-order named optional arguments by matching argument name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_ooo_opt_param($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_ooo_opt_param("bob", color: "green", greeting: "xxx"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_opt_param', because its argument '$color'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt new file mode 100644 index 0000000..86abbee --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_ooo_opt_pos.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with out-of-order named optional arguments by matching argument position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_ooo_opt_pos($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_ooo_opt_pos("bob", color: "green", greeting: "xxx"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_opt_pos', because its argument 'color'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt new file mode 100644 index 0000000..a77fc09 --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_ooo_param.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with out-of-order named arguments by matching argument name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_ooo_param($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_ooo_param(greeting: "hello!", name: "bob"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_param', because its argument '$name'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt b/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt new file mode 100644 index 0000000..ab7cc00 --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_ooo_pos.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with out-of-order named arguments by matching argument position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_ooo_pos($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_ooo_pos(greeting: "hello!", name: "bob"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_ooo_pos', because its argument 'name'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_param.phpt b/src/tests/disable_function/disabled_function_named_args_param.phpt new file mode 100644 index 0000000..f07e736 --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_param.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with named arguments by matching argument name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_param($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_param(name: "bob", greeting: "hello!"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_param', because its argument '$name'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_pos.phpt b/src/tests/disable_function/disabled_function_named_args_pos.phpt new file mode 100644 index 0000000..c0189fe --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_pos.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with named arguments by matching argument position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_pos($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_pos(name: "bob", greeting: "hello!"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_pos', because its argument 'name'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_skip_param.phpt b/src/tests/disable_function/disabled_function_named_args_skip_param.phpt new file mode 100644 index 0000000..86b1a5e --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_skip_param.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with named arguments (skipping opt. args) by matching argument name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_skip_param($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_skip_param("bob", color: "green"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_skip_param', because its argument '$color'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt b/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt new file mode 100644 index 0000000..ce85241 --- /dev/null +++ b/src/tests/disable_function/disabled_function_named_args_skip_pos.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions with named arguments (skipping opt. args) by matching argument position | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_function_named_args.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | function foo_named_args_skip_pos($name, $greeting='HI!', $color='red') { | ||
| 10 | echo "boo\n"; | ||
| 11 | } | ||
| 12 | foo_named_args_skip_pos("bob", color: "green"); | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'foo_named_args_skip_pos', because its argument 'color'%s matched a rule in %s.php on line %d \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_chmod.phpt b/src/tests/disable_function/disabled_functions_chmod.phpt index 28f948d..834bc31 100644 --- a/src/tests/disable_function/disabled_functions_chmod.phpt +++ b/src/tests/disable_function/disabled_functions_chmod.phpt | |||
| @@ -11,4 +11,4 @@ chmod( 'foo', 0777 ); | |||
| 11 | ?> | 11 | ?> |
| 12 | --XFAIL-- | 12 | --XFAIL-- |
| 13 | --EXPECTF-- | 13 | --EXPECTF-- |
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$mode' content (511) matched a rule in %a/disabled_function_chmod.php on line %d | 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$mode' content (511) matched a rule in %a.php on line %d |
diff --git a/src/tests/disable_function/disabled_functions_chmod_php8.phpt b/src/tests/disable_function/disabled_functions_chmod_php8.phpt index 71bb034..c947ba7 100644 --- a/src/tests/disable_function/disabled_functions_chmod_php8.phpt +++ b/src/tests/disable_function/disabled_functions_chmod_php8.phpt | |||
| @@ -4,11 +4,10 @@ Disable functions - chmod, in php8 | |||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> |
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/disabled_functions_chmod.ini | 7 | sp.configuration_file={PWD}/config/disabled_functions_chmod_php8.ini |
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php | 9 | <?php |
| 10 | chmod( 'foo', 0777 ); | 10 | chmod( 'foo', 0777 ); |
| 11 | ?> | 11 | ?> |
| 12 | --XFAIL-- | ||
| 13 | --EXPECTF-- | 12 | --EXPECTF-- |
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$permissions' content (511) matched a rule in %a/disabled_function_chmod_php8.php on line %d | 13 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'chmod', because its argument '$permissions' content (511) matched a rule in %a.php on line %d |
diff --git a/src/tests/disable_function/disabled_functions_exec.phpt b/src/tests/disable_function/disabled_functions_exec.phpt new file mode 100644 index 0000000..d49ea58 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_exec.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - exec | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo exec('ls -l'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'exec' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_name_type.phpt b/src/tests/disable_function/disabled_functions_name_type.phpt index 8d70eaa..62a6328 100644 --- a/src/tests/disable_function/disabled_functions_name_type.phpt +++ b/src/tests/disable_function/disabled_functions_name_type.phpt | |||
| @@ -13,4 +13,4 @@ echo strcmp([1,23], "pouet") . "\n"; | |||
| 13 | --EXPECTF-- | 13 | --EXPECTF-- |
| 14 | 0 | 14 | 0 |
| 15 | 15 | ||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'strcmp', because its argument '$str1' content (ARRAY) matched a rule in %a/disabled_functions_name_type.php on line 3 | 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'strcmp', because its argument '$str1'%smatched a rule in %s/disabled_functions_name_type.php on line 3 |
diff --git a/src/tests/disable_function/disabled_functions_param_broken_line.phpt b/src/tests/disable_function/disabled_functions_param_broken_line.phpt index 806816d..5251e4c 100644 --- a/src/tests/disable_function/disabled_functions_param_broken_line.phpt +++ b/src/tests/disable_function/disabled_functions_param_broken_line.phpt | |||
| @@ -2,17 +2,15 @@ | |||
| 2 | Disable functions - match on a specific line - broken configuration | 2 | Disable functions - match on a specific line - broken configuration |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/disabled_functions_broken_line.ini | 6 | sp.configuration_file={PWD}/config/disabled_functions_broken_line.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php | 9 | <?php |
| 10 | system("echo 1337"); | 10 | system("echo 1337"); |
| 11 | system("echo 1338"); | 11 | system("echo 1338"); |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECTF-- | 13 | --EXPECTF-- |
| 14 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0 | 14 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `line` on line 1 in Unknown on line 0 |
| 17 | 15 | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt b/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt index e409300..235d3f7 100644 --- a/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt +++ b/src/tests/disable_function/disabled_functions_param_invalid_pos.phpt | |||
| @@ -2,16 +2,14 @@ | |||
| 2 | Disable functions - match on argument's position | 2 | Disable functions - match on argument's position |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/disabled_functions_invalid_pos.ini | 6 | sp.configuration_file={PWD}/config/disabled_functions_invalid_pos.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php | 9 | <?php |
| 10 | system("echo 1"); | 10 | system("echo 1"); |
| 11 | ?> | 11 | ?> |
| 12 | --EXPECTF-- | 12 | --EXPECTF-- |
| 13 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0 | ||
| 14 | |||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Failed to parse arg 'qwe' of `pos` on line 1 in Unknown on line 0 |
| 16 | 14 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/disable_function/disabled_functions_param_pos.phpt b/src/tests/disable_function/disabled_functions_param_pos.phpt index bacca62..4204548 100644 --- a/src/tests/disable_function/disabled_functions_param_pos.phpt +++ b/src/tests/disable_function/disabled_functions_param_pos.phpt | |||
| @@ -9,6 +9,4 @@ sp.configuration_file={PWD}/config/disabled_functions_pos.ini | |||
| 9 | system("id"); | 9 | system("id"); |
| 10 | ?> | 10 | ?> |
| 11 | --EXPECTF-- | 11 | --EXPECTF-- |
| 12 | Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1337th argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_param_pos.php on line 2 | ||
| 13 | |||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (id) matched a rule in %a/disabled_functions_param_pos.php on line %d | 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (id) matched a rule in %a/disabled_functions_param_pos.php on line %d |
diff --git a/src/tests/disable_function/disabled_functions_passthru.phpt b/src/tests/disable_function/disabled_functions_passthru.phpt new file mode 100644 index 0000000..27eb8f8 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_passthru.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - passthru | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo passthru('ls -l'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'passthru' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt b/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt new file mode 100644 index 0000000..347101e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_phpinfo_header_callback.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - phpinfo via header_register_callback | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | header_register_callback('phpinfo'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'phpinfo' in Unknown on line 0 | ||
diff --git a/src/tests/disable_function/disabled_functions_popen.phpt b/src/tests/disable_function/disabled_functions_popen.phpt new file mode 100644 index 0000000..d027aed --- /dev/null +++ b/src/tests/disable_function/disabled_functions_popen.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - popen | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo popen('ls -l', 'r'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'popen' in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_pos_type.phpt b/src/tests/disable_function/disabled_functions_pos_type.phpt index ba134ad..29944c0 100644 --- a/src/tests/disable_function/disabled_functions_pos_type.phpt +++ b/src/tests/disable_function/disabled_functions_pos_type.phpt | |||
| @@ -9,8 +9,4 @@ sp.configuration_file={PWD}/config/disabled_functions_pos.ini | |||
| 9 | system([123, 456]); | 9 | system([123, 456]); |
| 10 | ?> | 10 | ?> |
| 11 | --EXPECTF-- | 11 | --EXPECTF-- |
| 12 | Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1337th argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_pos_type.php on line %d | ||
| 13 | |||
| 14 | Warning: [snuffleupagus][0.0.0.0][config][log] It seems that you wrote a rule filtering on the 1st argument of the function 'system', but it takes only 1 arguments. Matching on _all_ arguments instead. in %a/disabled_functions_pos_type.php on line %d | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (?) matched the rule '1' in %a/disabled_functions_pos_type.php on line %d | 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'system', because its argument 'command' content (?) matched the rule '1' in %a/disabled_functions_pos_type.php on line %d |
diff --git a/src/tests/disable_function/disabled_functions_proc_open.phpt b/src/tests/disable_function/disabled_functions_proc_open.phpt new file mode 100644 index 0000000..7c8c7eb --- /dev/null +++ b/src/tests/disable_function/disabled_functions_proc_open.phpt | |||
| @@ -0,0 +1,17 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - proc_open | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $descriptorspec = array( | ||
| 10 | 0 => array("pipe", "r"), | ||
| 11 | 1 => array("pipe", "w"), | ||
| 12 | 2 => array("pipe", "w") | ||
| 13 | ); | ||
| 14 | echo proc_open('ls', $descriptorspec, $pipes); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'proc_open' in %a.php on line 7 | ||
diff --git a/src/tests/disable_function/disabled_functions_runtime.phpt b/src/tests/disable_function/disabled_functions_runtime.phpt index 3d74b40..16ecfdb 100644 --- a/src/tests/disable_function/disabled_functions_runtime.phpt +++ b/src/tests/disable_function/disabled_functions_runtime.phpt | |||
| @@ -29,4 +29,4 @@ unlink("file_to_include2.php"); | |||
| 29 | --EXPECTF-- | 29 | --EXPECTF-- |
| 30 | 1338 | 30 | 1338 |
| 31 | 31 | ||
| 32 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'test', because its argument '$param' content (1337) matched a rule in %a/src/file_to_include%d.php on line 1 | 32 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'test', because its argument '$param' content (1337) matched a rule in %a/file_to_include%d.php on line 1 |
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt new file mode 100644 index 0000000..aeb64c2 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo `ls`; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt new file mode 100644 index 0000000..a312acf --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator in context of a var name | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo ${`ls`}; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt new file mode 100644 index 0000000..ea77a7d --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_backtick_var_string.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via backtick operator in context of a var name in a string | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | echo "{${`ls`}}"; | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt new file mode 100644 index 0000000..fd9343b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_closure.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via closure | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $x = Closure::fromCallable('shell_exec'); | ||
| 10 | echo $x('ls'); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt b/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt new file mode 100644 index 0000000..fac6031 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_closure2.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via 1st class closure | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80100) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php | ||
| 10 | $x = shell_exec(...); | ||
| 11 | echo $x('ls'); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt b/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt new file mode 100644 index 0000000..8a18d9b --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_filter_input.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via filter_input callback | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --GET-- | ||
| 8 | cmd=ls | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | echo filter_input(INPUT_GET, 'cmd', FILTER_CALLBACK, array('options' => 'shell_exec')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 2 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt b/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt new file mode 100644 index 0000000..4c13db6 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_include_data.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via include(data://) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | allow_url_include=1 | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | include('data://text/plain,'.urlencode('<?php shell_exec("ls");')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in data%a line 1 \ No newline at end of file | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt b/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt new file mode 100644 index 0000000..941d168 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_include_phpfilter.phpt | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via include(php://filter) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 8 | allow_url_include=1 | ||
| 9 | --FILE-- | ||
| 10 | <?php | ||
| 11 | include('php://filter//resource=data://text/plain,'.urlencode('<?php shell_exec("ls");')); | ||
| 12 | ?> | ||
| 13 | --EXPECTF-- | ||
| 14 | Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0 | ||
| 15 | |||
| 16 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in php%a line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt b/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt new file mode 100644 index 0000000..7e076ae --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_opcache_preload.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via opcache.preload | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("opcache")) print "skip"; ?> | ||
| 6 | <?php if (PHP_VERSION_ID < 70400) print "skip"; ?> | ||
| 7 | --EXTENSIONS-- | ||
| 8 | opcache | ||
| 9 | --XFAIL-- | ||
| 10 | --INI-- | ||
| 11 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 12 | allow_url_include=1 | ||
| 13 | opcache.enable=1 | ||
| 14 | opcache.enable_cli=1 | ||
| 15 | opcache.preload=data://text/plain,%3C%3Fphp+shell_exec%28%22ls%22%29%3B | ||
| 16 | opcache.preload_user=nobody | ||
| 17 | --FILE-- | ||
| 18 | <?php | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in data%a line 1 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt b/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt new file mode 100644 index 0000000..8dcc40e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_shutdown_function.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via register_shutdown_function | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | register_shutdown_function('shell_exec', 'ls'); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in Unknown on line 0 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt b/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt new file mode 100644 index 0000000..c0b5103 --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_signal.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via signal handler | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("pcntl")) print "skip"; ?> | ||
| 6 | <?php if (PHP_VERSION_ID < 70100) print "skip"; ?> | ||
| 7 | --EXTENSIONS-- | ||
| 8 | pcntl | ||
| 9 | --INI-- | ||
| 10 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 11 | pcntl.async_signals=1 | ||
| 12 | --FILE-- | ||
| 13 | <?php | ||
| 14 | declare(ticks=1); | ||
| 15 | ini_set("pcntl.async_signals", "1"); | ||
| 16 | pcntl_signal(SIGALRM, function($signo) { shell_exec("ls"); }); | ||
| 17 | system("kill -14 " . getmypid()); | ||
| 18 | sleep(5); | ||
| 19 | ?> | ||
| 20 | --EXPECTF-- | ||
| 21 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 4 | ||
diff --git a/src/tests/disable_function/disabled_functions_shell_exec_var.phpt b/src/tests/disable_function/disabled_functions_shell_exec_var.phpt new file mode 100644 index 0000000..e5a6a4e --- /dev/null +++ b/src/tests/disable_function/disabled_functions_shell_exec_var.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable functions - shell_exec via var call | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/disabled_functions_extra.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | $x = 'shell_exec'; | ||
| 10 | echo $x('ls'); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][disabled_function][drop] Aborted execution on call of the function 'shell_exec', %a matched a rule in %a.php on line 3 | ||
diff --git a/src/tests/dump_request/dump_eval_blacklist.phpt b/src/tests/dump_request/dump_eval_blacklist.phpt index 07c17f2..c9f48e4 100644 --- a/src/tests/dump_request/dump_eval_blacklist.phpt +++ b/src/tests/dump_request/dump_eval_blacklist.phpt | |||
| @@ -4,6 +4,13 @@ Dump eval blacklist | |||
| 4 | <?php | 4 | <?php |
| 5 | if (!extension_loaded("snuffleupagus")) print "skip"; | 5 | if (!extension_loaded("snuffleupagus")) print "skip"; |
| 6 | ?> | 6 | ?> |
| 7 | --CLEAN-- | ||
| 8 | <?php | ||
| 9 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | ||
| 10 | @unlink($dump); | ||
| 11 | } | ||
| 12 | @rmdir("/tmp/dump_result/"); | ||
| 13 | ?> | ||
| 7 | --POST-- | 14 | --POST-- |
| 8 | post_a=data_post_a&post_b=data_post_b | 15 | post_a=data_post_a&post_b=data_post_b |
| 9 | --GET-- | 16 | --GET-- |
| @@ -36,5 +43,5 @@ if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' \n") { | |||
| 36 | --EXPECTF-- | 43 | --EXPECTF-- |
| 37 | Outside of eval: 1337 1337 1337 | 44 | Outside of eval: 1337 1337 1337 |
| 38 | 45 | ||
| 39 | Warning: [snuffleupagus][0.0.0.0][eval][simulation] A call to strtoupper was tried in eval, in %a/dump_eval_blacklist.php:1, logging it. in %a/dump_eval_blacklist.php(9) : eval()'d code on line 1 | 46 | Warning: [snuffleupagus][0.0.0.0][eval][simulation] A call to 'strtoupper' was tried in eval. logging it. in %a(9) : eval()'d code on line 1 |
| 40 | After eval: 1234 | 47 | After eval: 1234 |
diff --git a/src/tests/dump_request/dump_eval_whitelist.phpt b/src/tests/dump_request/dump_eval_whitelist.phpt index 09f5523..cc5a824 100644 --- a/src/tests/dump_request/dump_eval_whitelist.phpt +++ b/src/tests/dump_request/dump_eval_whitelist.phpt | |||
| @@ -4,6 +4,13 @@ Dump eval whitelist | |||
| 4 | <?php | 4 | <?php |
| 5 | if (!extension_loaded("snuffleupagus")) print "skip"; | 5 | if (!extension_loaded("snuffleupagus")) print "skip"; |
| 6 | ?> | 6 | ?> |
| 7 | --CLEAN-- | ||
| 8 | <?php | ||
| 9 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | ||
| 10 | @unlink($dump); | ||
| 11 | } | ||
| 12 | @rmdir("/tmp/dump_result/"); | ||
| 13 | ?> | ||
| 7 | --POST-- | 14 | --POST-- |
| 8 | post_a=data_post_a&post_b=data_post_b | 15 | post_a=data_post_a&post_b=data_post_b |
| 9 | --GET-- | 16 | --GET-- |
diff --git a/src/tests/dump_request/dump_request.phpt b/src/tests/dump_request/dump_request.phpt index d18580b..f8dee11 100644 --- a/src/tests/dump_request/dump_request.phpt +++ b/src/tests/dump_request/dump_request.phpt | |||
| @@ -5,7 +5,9 @@ Dump request | |||
| 5 | if (!extension_loaded("snuffleupagus")) { | 5 | if (!extension_loaded("snuffleupagus")) { |
| 6 | print "skip"; | 6 | print "skip"; |
| 7 | } | 7 | } |
| 8 | 8 | ?> | |
| 9 | --CLEAN-- | ||
| 10 | <?php | ||
| 9 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | 11 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { |
| 10 | @unlink($dump); | 12 | @unlink($dump); |
| 11 | } | 13 | } |
| @@ -21,10 +23,6 @@ cookie_a=data_cookie_a&cookie_b=data_cookie_b | |||
| 21 | sp.configuration_file={PWD}/config/dump_request.ini | 23 | sp.configuration_file={PWD}/config/dump_request.ini |
| 22 | --FILE-- | 24 | --FILE-- |
| 23 | <?php | 25 | <?php |
| 24 | @mkdir("/tmp/dump_result/"); | ||
| 25 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | ||
| 26 | @unlink($dump); | ||
| 27 | } | ||
| 28 | echo "1\n"; | 26 | echo "1\n"; |
| 29 | system("echo 1337;"); | 27 | system("echo 1337;"); |
| 30 | $filename = glob('/tmp/dump_result/sp_dump.*')[0]; | 28 | $filename = glob('/tmp/dump_result/sp_dump.*')[0]; |
| @@ -40,5 +38,5 @@ if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' \n") { | |||
| 40 | --EXPECTF-- | 38 | --EXPECTF-- |
| 41 | 1 | 39 | 1 |
| 42 | 40 | ||
| 43 | Warning: [snuffleupagus][0.0.0.0][disabled_function][simulation] Aborted execution on call of the function 'system' in %a/dump_request.php on line 7 | 41 | Warning: [snuffleupagus][0.0.0.0][disabled_function][simulation] Aborted execution on call of the function 'system' in %a/dump_request.php on line %d |
| 44 | 1337 | 42 | 1337 |
diff --git a/src/tests/dump_request/dump_request_stacktrace.phpt b/src/tests/dump_request/dump_request_stacktrace.phpt index 0a8b94e..9b02ab5 100644 --- a/src/tests/dump_request/dump_request_stacktrace.phpt +++ b/src/tests/dump_request/dump_request_stacktrace.phpt | |||
| @@ -5,7 +5,9 @@ Dump request | |||
| 5 | if (!extension_loaded("snuffleupagus")) { | 5 | if (!extension_loaded("snuffleupagus")) { |
| 6 | print "skip"; | 6 | print "skip"; |
| 7 | } | 7 | } |
| 8 | 8 | ?> | |
| 9 | --CLEAN-- | ||
| 10 | <?php | ||
| 9 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | 11 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { |
| 10 | @unlink($dump); | 12 | @unlink($dump); |
| 11 | } | 13 | } |
diff --git a/src/tests/dump_request/dump_request_too_big.phpt b/src/tests/dump_request/dump_request_too_big.phpt index e82ddc4..fd265f2 100644 --- a/src/tests/dump_request/dump_request_too_big.phpt +++ b/src/tests/dump_request/dump_request_too_big.phpt | |||
| @@ -6,6 +6,13 @@ if (!extension_loaded("snuffleupagus")) { | |||
| 6 | print "skip"; | 6 | print "skip"; |
| 7 | } | 7 | } |
| 8 | ?> | 8 | ?> |
| 9 | --CLEAN-- | ||
| 10 | <?php | ||
| 11 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | ||
| 12 | @unlink($dump); | ||
| 13 | } | ||
| 14 | @rmdir("/tmp/dump_result/"); | ||
| 15 | ?> | ||
| 9 | --POST-- | 16 | --POST-- |
| 10 | post_a=data_post_a&post_b=data_post_b&post_c=c | 17 | post_a=data_post_a&post_b=data_post_b&post_c=c |
| 11 | --GET-- | 18 | --GET-- |
| @@ -20,15 +27,11 @@ END; | |||
| 20 | sp.configuration_file={PWD}/config/dump_request.ini | 27 | sp.configuration_file={PWD}/config/dump_request.ini |
| 21 | --FILE-- | 28 | --FILE-- |
| 22 | <?php | 29 | <?php |
| 23 | @mkdir("/tmp/dump_result/"); | ||
| 24 | foreach (glob("/tmp/dump_result/sp_dump.*") as $dump) { | ||
| 25 | @unlink($dump); | ||
| 26 | } | ||
| 27 | |||
| 28 | echo "1\n"; | 30 | echo "1\n"; |
| 29 | system("echo 1337;"); | 31 | system("echo 1337;"); |
| 30 | $filename = glob('/tmp/dump_result/*')[0]; | 32 | $filename = glob('/tmp/dump_result/*')[0]; |
| 31 | $res = file($filename); | 33 | $res = file($filename); |
| 34 | // echo $res[3] . "\n"; | ||
| 32 | if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' get_c='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBBBB' \n") { | 35 | if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' get_c='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaBBBB' \n") { |
| 33 | echo "Invalid GET"; | 36 | echo "Invalid GET"; |
| 34 | } elseif ($res[4] != "POST:post_a='data_post_a' post_b='data_post_b' post_c='c' \n") { | 37 | } elseif ($res[4] != "POST:post_a='data_post_a' post_b='data_post_b' post_c='c' \n") { |
| @@ -40,5 +43,5 @@ if ($res[3] != "GET:get_a='data_get_a' get_b='data_get_b' get_c='aaaaaaaaaaaaaaa | |||
| 40 | --EXPECTF-- | 43 | --EXPECTF-- |
| 41 | 1 | 44 | 1 |
| 42 | 45 | ||
| 43 | Warning: [snuffleupagus][127.0.0.1][disabled_function][simulation] Aborted execution on call of the function 'system' in %a/dump_request_too_big.php on line 8 | 46 | Warning: [snuffleupagus][127.0.0.1][disabled_function][simulation] Aborted execution on call of the function 'system' in %a/dump_request_too_big.php on line %d |
| 44 | 1337 | 47 | 1337 |
diff --git a/src/tests/eval_blacklist/eval_backlist.phpt b/src/tests/eval_blacklist/eval_backlist.phpt index fa32b4b..2953efc 100644 --- a/src/tests/eval_blacklist/eval_backlist.phpt +++ b/src/tests/eval_blacklist/eval_backlist.phpt | |||
| @@ -14,4 +14,4 @@ echo "After eval: $a\n"; | |||
| 14 | --EXPECTF-- | 14 | --EXPECTF-- |
| 15 | Outside of eval: 1337 1337 1337 | 15 | Outside of eval: 1337 1337 1337 |
| 16 | 16 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %a/eval_backlist.php:1, dropping it. in %a/eval_backlist.php(4) : eval()'d code on line 1 | 17 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %a/eval_backlist.php(4) : eval()'d code on line 1 |
diff --git a/src/tests/eval_blacklist/eval_backlist_call_user_func.phpt b/src/tests/eval_blacklist/eval_backlist_call_user_func.phpt index 4c37263..546a53a 100644 --- a/src/tests/eval_blacklist/eval_backlist_call_user_func.phpt +++ b/src/tests/eval_blacklist/eval_backlist_call_user_func.phpt | |||
| @@ -11,4 +11,4 @@ eval(' | |||
| 11 | ') | 11 | ') |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECTF-- | 13 | --EXPECTF-- |
| 14 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %s/eval_backlist_call_user_func.php:%d, dropping it. in %s/eval_backlist_call_user_func.php(%d) : eval()'d code on line %d | 14 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %s/eval_backlist_call_user_func.php(%d) : eval()'d code on line %d |
diff --git a/src/tests/eval_blacklist/eval_backlist_chained.phpt b/src/tests/eval_blacklist/eval_backlist_chained.phpt index 820ef1d..1afb860 100644 --- a/src/tests/eval_blacklist/eval_backlist_chained.phpt +++ b/src/tests/eval_blacklist/eval_backlist_chained.phpt | |||
| @@ -13,4 +13,4 @@ eval(' | |||
| 13 | ') | 13 | ') |
| 14 | ?> | 14 | ?> |
| 15 | --EXPECTF-- | 15 | --EXPECTF-- |
| 16 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %s/eval_backlist_chained.php:%d, dropping it. in %s/eval_backlist_chained.php(%d) : eval()'d code on line %d | 16 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %s/eval_backlist_chained.php(%d) : eval()'d code on line %d |
diff --git a/src/tests/eval_blacklist/eval_backlist_list.phpt b/src/tests/eval_blacklist/eval_backlist_list.phpt index 725a9bb..1efd453 100644 --- a/src/tests/eval_blacklist/eval_backlist_list.phpt +++ b/src/tests/eval_blacklist/eval_backlist_list.phpt | |||
| @@ -14,4 +14,4 @@ echo "After eval: $a\n"; | |||
| 14 | --EXPECTF-- | 14 | --EXPECTF-- |
| 15 | Outside of eval: 1337 1337 1337 | 15 | Outside of eval: 1337 1337 1337 |
| 16 | 16 | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %a/eval_backlist_list.php:1, dropping it. in %a/eval_backlist_list.php(4) : eval()'d code on line 1 | 17 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %a/eval_backlist_list.php(4) : eval()'d code on line 1 |
diff --git a/src/tests/eval_blacklist/eval_backlist_simulation.phpt b/src/tests/eval_blacklist/eval_backlist_simulation.phpt index f09370d..0cc02b2 100644 --- a/src/tests/eval_blacklist/eval_backlist_simulation.phpt +++ b/src/tests/eval_blacklist/eval_backlist_simulation.phpt | |||
| @@ -14,5 +14,5 @@ echo "After eval: $a\n"; | |||
| 14 | --EXPECTF-- | 14 | --EXPECTF-- |
| 15 | Outside of eval: 1337 1337 1337 | 15 | Outside of eval: 1337 1337 1337 |
| 16 | 16 | ||
| 17 | Warning: [snuffleupagus][0.0.0.0][eval][simulation] A call to strtoupper was tried in eval, in %a/eval_backlist_simulation.php:1, logging it. in %a/eval_backlist_simulation.php(4) : eval()'d code on line 1 | 17 | Warning: [snuffleupagus][0.0.0.0][eval][simulation] A call to 'strtoupper' was tried in eval. logging it. in %a/eval_backlist_simulation.php(4) : eval()'d code on line 1 |
| 18 | After eval: 1234 | 18 | After eval: 1234 |
diff --git a/src/tests/eval_blacklist/nested_eval_blacklist.phpt b/src/tests/eval_blacklist/nested_eval_blacklist.phpt index 8ff0b6d..a06b66b 100644 --- a/src/tests/eval_blacklist/nested_eval_blacklist.phpt +++ b/src/tests/eval_blacklist/nested_eval_blacklist.phpt | |||
| @@ -26,4 +26,4 @@ Inception lvl 1... | |||
| 26 | Inception lvl 2... | 26 | Inception lvl 2... |
| 27 | Inception lvl 3... | 27 | Inception lvl 3... |
| 28 | 28 | ||
| 29 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %a/nested_eval_blacklist.php(5) : eval()'d code(4) : eval()'d code:3, dropping it. in %a/nested_eval_blacklist.php(5) : eval()'d code(4) : eval()'d code(4) : eval()'d code on line 3 | 29 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %a/nested_eval_blacklist.php(5) : eval()'d code(4) : eval()'d code(4) : eval()'d code on line 3 |
diff --git a/src/tests/eval_blacklist/nested_eval_blacklist2.phpt b/src/tests/eval_blacklist/nested_eval_blacklist2.phpt index 37f8967..63e56b1 100644 --- a/src/tests/eval_blacklist/nested_eval_blacklist2.phpt +++ b/src/tests/eval_blacklist/nested_eval_blacklist2.phpt | |||
| @@ -26,4 +26,4 @@ Inception lvl 1... | |||
| 26 | Inception lvl 2... | 26 | Inception lvl 2... |
| 27 | Inception lvl 3... | 27 | Inception lvl 3... |
| 28 | 28 | ||
| 29 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to strtoupper was tried in eval, in %a/nested_eval_blacklist2.php(5) : eval()'d code:7, dropping it. in %a/nested_eval_blacklist2.php(5) : eval()'d code(4) : eval()'d code on line 7 | 29 | Fatal error: [snuffleupagus][0.0.0.0][eval][drop] A call to 'strtoupper' was tried in eval. dropping it. in %a/nested_eval_blacklist2.php(5) : eval()'d code(4) : eval()'d code on line 7 |
diff --git a/src/tests/filter/config/filter.ini b/src/tests/filter/config/filter.ini new file mode 100644 index 0000000..5ebee61 --- /dev/null +++ b/src/tests/filter/config/filter.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.global.server_encode.enable(); | ||
| 2 | sp.global.server_strip.enable(); | ||
| 3 | |||
diff --git a/src/tests/filter/server_encode.phpt b/src/tests/filter/server_encode.phpt new file mode 100644 index 0000000..f7cc233 --- /dev/null +++ b/src/tests/filter/server_encode.phpt | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | --TEST-- | ||
| 2 | input filter: server_encode | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/filter.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --ENV-- | ||
| 11 | return <<<EOF | ||
| 12 | REQUEST_URI=AAA<>"'`!AAA | ||
| 13 | EOF; | ||
| 14 | --COOKIE-- | ||
| 15 | --GET-- | ||
| 16 | BBB<>"'`!BBB | ||
| 17 | --POST-- | ||
| 18 | --FILE-- | ||
| 19 | <?php | ||
| 20 | var_dump($_SERVER['REQUEST_URI']); | ||
| 21 | var_dump($_SERVER['QUERY_STRING']); | ||
| 22 | --EXPECT-- | ||
| 23 | string(22) "AAA%3C%3E%22%27%60!AAA" | ||
| 24 | string(22) "BBB%3C%3E%22%27%60!BBB" | ||
| 25 | |||
diff --git a/src/tests/filter/server_strip.phpt b/src/tests/filter/server_strip.phpt new file mode 100644 index 0000000..83072b4 --- /dev/null +++ b/src/tests/filter/server_strip.phpt | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | --TEST-- | ||
| 2 | input filter: server_strip | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/filter.ini | ||
| 7 | display_errors=1 | ||
| 8 | display_startup_errors=1 | ||
| 9 | error_reporting=E_ALL | ||
| 10 | --ENV-- | ||
| 11 | return <<<EOF | ||
| 12 | HTTP_USER_AGENT=Mozilla/5.0 (Windows NT 6.0; rv:29.0) <script>alert('123');</script>Gecko/20100101 Firefox/29.0 | ||
| 13 | EOF; | ||
| 14 | --COOKIE-- | ||
| 15 | --GET-- | ||
| 16 | --POST-- | ||
| 17 | --FILE-- | ||
| 18 | <?php | ||
| 19 | var_dump($_SERVER['HTTP_USER_AGENT']); | ||
| 20 | --EXPECT-- | ||
| 21 | string(95) "Mozilla/5.0 (Windows NT 6.0; rv:29.0) _script_alert(_123_);_/script_Gecko/20100101 Firefox/29.0" | ||
diff --git a/src/tests/inexistent_conf_file.phpt b/src/tests/inexistent_conf_file.phpt index cd10665..27b176f 100644 --- a/src/tests/inexistent_conf_file.phpt +++ b/src/tests/inexistent_conf_file.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Check for snuffleupagus presence | 2 | Check for snuffleupagus presence |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/unexistent_configuration_file.ini | 6 | sp.configuration_file={PWD}/config/unexistent_configuration_file.ini |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php ?> | 9 | <?php ?> |
| 10 | --EXPECTF-- | 10 | --EXPECTF-- |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/config/unexistent_configuration_file.ini : No such file or directory in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/config/unexistent_configuration_file.ini : No such file or directory in Unknown on line 0 | 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/config/unexistent_configuration_file.ini : No such file or directory in Unknown on line 0 |
| 14 | 12 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/inexistent_conf_file_list.phpt b/src/tests/inexistent_conf_file_list.phpt index 6cac934..fe9a206 100644 --- a/src/tests/inexistent_conf_file_list.phpt +++ b/src/tests/inexistent_conf_file_list.phpt | |||
| @@ -2,14 +2,12 @@ | |||
| 2 | Non-existent configuration file in a list | 2 | Non-existent configuration file in a list |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 6 | --INI-- | 5 | --INI-- |
| 7 | sp.configuration_file={PWD}/../../config/default.rules,{PWD}/non_existent_configuration_file | 6 | sp.configuration_file={PWD}/../../config/default.rules,{PWD}/non_existent_configuration_file |
| 7 | error_log=/dev/null | ||
| 8 | --FILE-- | 8 | --FILE-- |
| 9 | <?php ?> | 9 | <?php ?> |
| 10 | --EXPECTF-- | 10 | --EXPECTF-- |
| 11 | PHP Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/non_existent_configuration_file : No such file or directory in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/non_existent_configuration_file : No such file or directory in Unknown on line 0 | 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/non_existent_configuration_file : No such file or directory in Unknown on line 0 |
| 14 | 12 | ||
| 15 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
diff --git a/src/tests/ini/config/sp-policy-drop.ini b/src/tests/ini/config/sp-policy-drop.ini new file mode 100644 index 0000000..4b1e374 --- /dev/null +++ b/src/tests/ini/config/sp-policy-drop.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.ini_protection.enable(); | ||
| 2 | sp.ini_protection.policy_drop(); | ||
| 3 | sp.ini.key("max_execution_time").min("30").max("300"); | ||
diff --git a/src/tests/ini/config/sp-policy-silent-fail.ini b/src/tests/ini/config/sp-policy-silent-fail.ini new file mode 100644 index 0000000..2123837 --- /dev/null +++ b/src/tests/ini/config/sp-policy-silent-fail.ini | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | sp.ini_protection.enable(); | ||
| 2 | sp.ini_protection.policy_silent_fail(); | ||
| 3 | sp.ini.key("max_execution_time").min("30").max("300"); | ||
diff --git a/src/tests/ini/config/sp.ini b/src/tests/ini/config/sp.ini new file mode 100644 index 0000000..86a63a7 --- /dev/null +++ b/src/tests/ini/config/sp.ini | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | sp.ini_protection.enable(); | ||
| 2 | |||
| 3 | sp.ini.key("max_execution_time").min("30").max("300"); | ||
| 4 | sp.ini.key("highlight.comment").regexp("^#[0-9a-fA-F]{6}$"); | ||
| 5 | sp.ini.key("default_mimetype").set("text/plain").ro(); | ||
| 6 | |||
| 7 | sp.ini.key("sendmail_from").set("test@example.com").regexp(".*@example\\.com$").allow_null(); | ||
| 8 | sp.ini.key("unserialize_callback_func").set("def").regexp("^abc$"); | ||
| 9 | |||
| 10 | sp.ini.key("user_agent").regexp("^abc$").drop(); | ||
diff --git a/src/tests/ini/ini_min_policy_drop.phpt b/src/tests/ini/ini_min_policy_drop.phpt new file mode 100644 index 0000000..ef40ebc --- /dev/null +++ b/src/tests/ini/ini_min_policy_drop.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .min() + .policy_drop() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp-policy-drop.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_set("max_execution_time", "29") === false); | ||
| 10 | var_dump(ini_get("max_execution_time")); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value out of range in %a/ini_min_policy_drop.php on line 2 | ||
diff --git a/src/tests/ini/ini_min_policy_silent_fail.phpt b/src/tests/ini/ini_min_policy_silent_fail.phpt new file mode 100644 index 0000000..d0117a7 --- /dev/null +++ b/src/tests/ini/ini_min_policy_silent_fail.phpt | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .min() + .policy_silent_fail() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp-policy-silent-fail.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_set("max_execution_time", "29") === false); | ||
| 10 | var_dump(ini_get("max_execution_time")); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | bool(true) | ||
| 14 | string(1) "0" \ No newline at end of file | ||
diff --git a/src/tests/ini/ini_minmax.phpt b/src/tests/ini/ini_minmax.phpt new file mode 100644 index 0000000..4cd6bc4 --- /dev/null +++ b/src/tests/ini/ini_minmax.phpt | |||
| @@ -0,0 +1,34 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .min()/.max() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_set("max_execution_time", "30") === false); | ||
| 10 | var_dump(ini_get("max_execution_time")); | ||
| 11 | |||
| 12 | var_dump(ini_set("max_execution_time", "300") === false); | ||
| 13 | var_dump(ini_get("max_execution_time")); | ||
| 14 | |||
| 15 | var_dump(ini_set("max_execution_time", "29") === false); | ||
| 16 | var_dump(ini_get("max_execution_time")); | ||
| 17 | |||
| 18 | var_dump(ini_set("max_execution_time", "301") === false); | ||
| 19 | var_dump(ini_get("max_execution_time")); | ||
| 20 | |||
| 21 | ?> | ||
| 22 | --EXPECTF-- | ||
| 23 | bool(false) | ||
| 24 | string(2) "30" | ||
| 25 | bool(false) | ||
| 26 | string(3) "300" | ||
| 27 | |||
| 28 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 8 | ||
| 29 | bool(true) | ||
| 30 | string(3) "300" | ||
| 31 | |||
| 32 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value out of range in %a/ini_minmax.php on line 11 | ||
| 33 | bool(true) | ||
| 34 | string(3) "300" \ No newline at end of file | ||
diff --git a/src/tests/ini/ini_null.phpt b/src/tests/ini/ini_null.phpt new file mode 100644 index 0000000..32a12c1 --- /dev/null +++ b/src/tests/ini/ini_null.phpt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .allow_null() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_set("sendmail_from", "foo@example.com") === false); | ||
| 10 | var_dump(ini_get("sendmail_from")); | ||
| 11 | |||
| 12 | var_dump(ini_set("sendmail_from", NULL) === false); | ||
| 13 | var_dump(ini_get("sendmail_from")); | ||
| 14 | |||
| 15 | var_dump(ini_set("unserialize_callback_func", NULL) === false); | ||
| 16 | var_dump(ini_get("unserialize_callback_func")); | ||
| 17 | ?> | ||
| 18 | --EXPECTF-- | ||
| 19 | bool(false) | ||
| 20 | string(15) "foo@example.com" | ||
| 21 | bool(false) | ||
| 22 | string(0) "" | ||
| 23 | |||
| 24 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] new INI value must not be NULL or empty in %a/ini_null.php on line 8 | ||
| 25 | bool(true) | ||
| 26 | string(3) "def" \ No newline at end of file | ||
diff --git a/src/tests/ini/ini_regexp.phpt b/src/tests/ini/ini_regexp.phpt new file mode 100644 index 0000000..f6c5198 --- /dev/null +++ b/src/tests/ini/ini_regexp.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .regexp() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | ini_set("highlight.comment", "#000aBc"); | ||
| 10 | var_dump(ini_get("highlight.comment")); | ||
| 11 | |||
| 12 | ini_set("highlight.comment", "xxx"); | ||
| 13 | var_dump(ini_get("highlight.comment")); | ||
| 14 | ?> | ||
| 15 | --EXPECTF-- | ||
| 16 | string(7) "#000aBc" | ||
| 17 | |||
| 18 | Warning: [snuffleupagus][0.0.0.0][ini_protection][log] INI value does not match regex in %a/ini_regexp.php on line 5 | ||
| 19 | string(7) "#000aBc" | ||
diff --git a/src/tests/ini/ini_regexp_drop.phpt b/src/tests/ini/ini_regexp_drop.phpt new file mode 100644 index 0000000..9225470 --- /dev/null +++ b/src/tests/ini/ini_regexp_drop.phpt | |||
| @@ -0,0 +1,13 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .min() + .drop() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_set("user_agent", "Foo") === false); | ||
| 10 | var_dump(ini_get("user_agent")); | ||
| 11 | ?> | ||
| 12 | --EXPECTF-- | ||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][ini_protection][drop] INI value does not match regex in %a/ini_regexp_drop.php on line 2 | ||
diff --git a/src/tests/ini/ini_set.phpt b/src/tests/ini/ini_set.phpt new file mode 100644 index 0000000..bfafbe8 --- /dev/null +++ b/src/tests/ini/ini_set.phpt | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | --TEST-- | ||
| 2 | INI protection .set() | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print("skip"); ?> | ||
| 5 | --INI-- | ||
| 6 | sp.configuration_file={PWD}/config/sp.ini | ||
| 7 | --FILE-- | ||
| 8 | <?php | ||
| 9 | var_dump(ini_get("default_mimetype")); | ||
| 10 | ?> | ||
| 11 | --EXPECTF-- | ||
| 12 | string(10) "text/plain" \ No newline at end of file | ||
diff --git a/src/tests/php8/inexistent_conf_file.phpt b/src/tests/php8/inexistent_conf_file.phpt deleted file mode 100644 index ac763aa..0000000 --- a/src/tests/php8/inexistent_conf_file.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Test for unexistent configuration file, in php8 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/unexistent_configuration_file.ini | ||
| 8 | --FILE-- | ||
| 9 | <?php ?> | ||
| 10 | --EXPECTF-- | ||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/config/unexistent_configuration_file.ini : No such file or directory in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/php8/inexistent_conf_file_list.phpt b/src/tests/php8/inexistent_conf_file_list.phpt deleted file mode 100644 index 2309fc6..0000000 --- a/src/tests/php8/inexistent_conf_file_list.phpt +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | --TEST-- | ||
| 2 | Non-existent configuration file in a list in php8 | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/../../../config/default.rules,{PWD}/non_existent_configuration_file | ||
| 8 | --FILE-- | ||
| 9 | <?php ?> | ||
| 10 | --EXPECTF-- | ||
| 11 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Could not open configuration file %a/non_existent_configuration_file : No such file or directory in Unknown on line 0 | ||
| 12 | |||
| 13 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | ||
| 14 | Could not startup. | ||
diff --git a/src/tests/phpinfo_presence.phpt b/src/tests/phpinfo_presence.phpt index c1388ed..48daffb 100644 --- a/src/tests/phpinfo_presence.phpt +++ b/src/tests/phpinfo_presence.phpt | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Unserialize fail | 2 | phpinfo() showing snuffleupagus |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | --INI-- | 5 | --INI-- |
diff --git a/src/tests/session_encryption/config/config_crypt_session.ini b/src/tests/session_encryption/config/config_crypt_session.ini index 14b0c2c..054f0f8 100644 --- a/src/tests/session_encryption/config/config_crypt_session.ini +++ b/src/tests/session_encryption/config/config_crypt_session.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.session.encrypt(); \ No newline at end of file | 2 | sp.session.encrypt(); \ No newline at end of file |
diff --git a/src/tests/session_encryption/config/config_crypt_session_simul.ini b/src/tests/session_encryption/config/config_crypt_session_simul.ini index fbd43eb..5e3433b 100644 --- a/src/tests/session_encryption/config/config_crypt_session_simul.ini +++ b/src/tests/session_encryption/config/config_crypt_session_simul.ini | |||
| @@ -1,3 +1,3 @@ | |||
| 1 | sp.global.secret_key("abcdef").cookie_env_var("REMOTE_ADDR"); | 1 | sp.global.secret_key("abcdefGHIJ").cookie_env_var("REMOTE_ADDR"); |
| 2 | sp.session.encrypt(); | 2 | sp.session.encrypt(); |
| 3 | sp.session.simulation(); \ No newline at end of file | 3 | sp.session.simulation(); \ No newline at end of file |
diff --git a/src/tests/session_encryption/crypt_session_corrupted_session.phpt b/src/tests/session_encryption/crypt_session_corrupted_session.phpt index a97dbca..eca43b4 100644 --- a/src/tests/session_encryption/crypt_session_corrupted_session.phpt +++ b/src/tests/session_encryption/crypt_session_corrupted_session.phpt | |||
| @@ -2,11 +2,12 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | 6 | --EXTENSIONS-- |
| 7 | session | ||
| 7 | --INI-- | 8 | --INI-- |
| 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 9 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 10 | --ENV-- | 11 | --ENV-- |
| 11 | return <<<EOF | 12 | return <<<EOF |
| 12 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
| @@ -29,4 +30,4 @@ session_start(); | |||
| 29 | var_dump($_SESSION); | 30 | var_dump($_SESSION); |
| 30 | ?> | 31 | ?> |
| 31 | --EXPECTF-- | 32 | --EXPECTF-- |
| 32 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow tentative detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s | 33 | Fatal error: [snuffleupagus][127.0.0.1][cookie_encryption][drop] Buffer underflow (tentative) detected in cookie encryption handling in %s/crypt_session_corrupted_session.php on line %s |
diff --git a/src/tests/session_encryption/crypt_session_invalid.phpt b/src/tests/session_encryption/crypt_session_invalid.phpt index 967d9d1..a71a601 100644 --- a/src/tests/session_encryption/crypt_session_invalid.phpt +++ b/src/tests/session_encryption/crypt_session_invalid.phpt | |||
| @@ -2,8 +2,9 @@ | |||
| 2 | SESSION crypt and bad decrypt | 2 | SESSION crypt and bad decrypt |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (!extension_loaded("session")) print "skip"; ?> |
| 6 | <?php if (PHP_VERSION_ID >= 70400) print "skip"; ?> | 6 | --EXTENSIONS-- |
| 7 | session | ||
| 7 | --INI-- | 8 | --INI-- |
| 8 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 9 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/crypt_session_invalid_simul.phpt b/src/tests/session_encryption/crypt_session_invalid_simul.phpt index cbb80dc..3eb619c 100644 --- a/src/tests/session_encryption/crypt_session_invalid_simul.phpt +++ b/src/tests/session_encryption/crypt_session_invalid_simul.phpt | |||
| @@ -2,8 +2,14 @@ | |||
| 2 | SESSION crypt and bad decrypt | 2 | SESSION crypt and bad decrypt |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 10 | display_errors=0 | ||
| 11 | log_errors=1 | ||
| 12 | error_log="{PWD}"/crypt_session_invalid_simul.tmp | ||
| 7 | --ENV-- | 13 | --ENV-- |
| 8 | return <<<EOF | 14 | return <<<EOF |
| 9 | REMOTE_ADDR=127.0.0.1 | 15 | REMOTE_ADDR=127.0.0.1 |
| @@ -19,9 +25,12 @@ putenv("REMOTE_ADDR=127.0.0.2"); | |||
| 19 | session_id($id); // Recover the session with the previous session_id | 25 | session_id($id); // Recover the session with the previous session_id |
| 20 | session_start(); // Re start the session, It will read and decrypt the non empty session | 26 | session_start(); // Re start the session, It will read and decrypt the non empty session |
| 21 | var_dump($_SESSION); // Dump the session | 27 | var_dump($_SESSION); // Dump the session |
| 28 | |||
| 29 | echo file_get_contents(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp"); | ||
| 30 | unlink(dirname(__FILE__) . "/crypt_session_invalid_simul.tmp"); | ||
| 31 | |||
| 22 | ?> | 32 | ?> |
| 23 | --EXPECTF-- | 33 | --EXPECTF-- |
| 24 | array(1) { | 34 | array(0) { |
| 25 | ["toto"]=> | ||
| 26 | string(4) "tata" | ||
| 27 | } | 35 | } |
| 36 | %sPHP Warning: [snuffleupagus][127.0.0.2][cookie_encryption][simulation] Something went wrong with the decryption of the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_invalid_simul.php on line 9%A \ No newline at end of file | ||
diff --git a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt index 5e81b52..5966f8e 100644 --- a/src/tests/session_encryption/crypt_session_read_uncrypt.phpt +++ b/src/tests/session_encryption/crypt_session_read_uncrypt.phpt | |||
| @@ -2,27 +2,33 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 10 | session.save_path="{PWD}" | ||
| 11 | display_errors=0 | ||
| 12 | log_errors=1 | ||
| 13 | error_log="{PWD}"/crypt_session_read_uncrypt.tmp | ||
| 7 | --ENV-- | 14 | --ENV-- |
| 8 | return <<<EOF | 15 | return <<<EOF |
| 9 | REMOTE_ADDR=127.0.0.1 | 16 | REMOTE_ADDR=127.0.0.1 |
| 10 | EOF; | 17 | EOF; |
| 11 | --FILE-- | 18 | --FILE-- |
| 12 | <?php | 19 | <?php |
| 13 | $current_path = dirname(getcwd()) . "/src/tests/" ; | ||
| 14 | ini_set("session.save_path", $current_path); | ||
| 15 | |||
| 16 | session_start(); | 20 | session_start(); |
| 17 | $id = session_id(); // Get the session_id to use it later | 21 | $id = session_id(); // Get the session_id to use it later |
| 18 | $filename_sess = $current_path . "sess_" . $id; | 22 | $filename_sess = dirname(__FILE__) . "/sess_" . $id; |
| 19 | file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write a unencrypted session | 23 | file_put_contents($filename_sess, "toto|s:4:\"tata\";"); // Write unencrypted session |
| 20 | session_write_close(); // Close the session | 24 | session_write_close(); // Close the session |
| 21 | 25 | ||
| 22 | session_id($id); | 26 | session_id($id); |
| 23 | session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session | 27 | session_start(); // Try to read the unencrypted session, it will fail to decrypt but it must return the session |
| 24 | var_dump($_SESSION); | 28 | var_dump($_SESSION); |
| 25 | echo "OK"; | 29 | echo "OK\n"; |
| 30 | echo file_get_contents(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp"); | ||
| 31 | unlink(dirname(__FILE__) . "/crypt_session_read_uncrypt.tmp"); | ||
| 26 | unlink($filename_sess); | 32 | unlink($filename_sess); |
| 27 | ?> | 33 | ?> |
| 28 | --EXPECTF-- | 34 | --EXPECTF-- |
| @@ -31,3 +37,4 @@ array(1) { | |||
| 31 | string(4) "tata" | 37 | string(4) "tata" |
| 32 | } | 38 | } |
| 33 | OK | 39 | OK |
| 40 | %aPHP Warning: [snuffleupagus][127.0.0.1][cookie_encryption][simulation] Buffer underflow tentative detected in cookie encryption handling for the session. Using the cookie 'as is' instead of decrypting it in %a/crypt_session_read_uncrypt.php on line 9 | ||
diff --git a/src/tests/session_encryption/crypt_session_valid.phpt b/src/tests/session_encryption/crypt_session_valid.phpt index c272486..a28685b 100644 --- a/src/tests/session_encryption/crypt_session_valid.phpt +++ b/src/tests/session_encryption/crypt_session_valid.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/crypt_session_valid_simul.phpt b/src/tests/session_encryption/crypt_session_valid_simul.phpt index d63277d..6af015e 100644 --- a/src/tests/session_encryption/crypt_session_valid_simul.phpt +++ b/src/tests/session_encryption/crypt_session_valid_simul.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | SESSION crypt/decrypt valid | 2 | SESSION crypt/decrypt valid |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session_simul.ini |
| 7 | --ENV-- | 10 | --ENV-- |
diff --git a/src/tests/session_encryption/set_custom_session_handler.phpt b/src/tests/session_encryption/set_custom_session_handler.phpt index 725ee43..04edcd0 100644 --- a/src/tests/session_encryption/set_custom_session_handler.phpt +++ b/src/tests/session_encryption/set_custom_session_handler.phpt | |||
| @@ -2,9 +2,12 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 8 | --ENV-- | 11 | --ENV-- |
| 9 | return <<<EOF | 12 | return <<<EOF |
| 10 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/session_encryption/set_custom_session_handler2.phpt b/src/tests/session_encryption/set_custom_session_handler2.phpt index 8cc6786..0ebf7b6 100644 --- a/src/tests/session_encryption/set_custom_session_handler2.phpt +++ b/src/tests/session_encryption/set_custom_session_handler2.phpt | |||
| @@ -2,9 +2,12 @@ | |||
| 2 | Set a custom session handler, twice | 2 | Set a custom session handler, twice |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_path = "/tmp" | 10 | session.save_path="/tmp" |
| 8 | --ENV-- | 11 | --ENV-- |
| 9 | return <<<EOF | 12 | return <<<EOF |
| 10 | REMOTE_ADDR=127.0.0.1 | 13 | REMOTE_ADDR=127.0.0.1 |
diff --git a/src/tests/session_encryption/set_custom_session_handler_ini.phpt b/src/tests/session_encryption/set_custom_session_handler_ini.phpt index f9fbfb2..a454fc6 100644 --- a/src/tests/session_encryption/set_custom_session_handler_ini.phpt +++ b/src/tests/session_encryption/set_custom_session_handler_ini.phpt | |||
| @@ -2,6 +2,9 @@ | |||
| 2 | Set a custom session handler | 2 | Set a custom session handler |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> |
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 5 | --INI-- | 8 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/config_crypt_session.ini | 9 | sp.configuration_file={PWD}/config/config_crypt_session.ini |
| 7 | session.save_handler = | 10 | session.save_handler = |
diff --git a/src/tests/sid_too_long.phpt b/src/tests/sid_too_long.phpt new file mode 100644 index 0000000..85f7fc2 --- /dev/null +++ b/src/tests/sid_too_long.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | SESSION ID too long | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/sid_length_limit.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | session_id('123456789012345678901234567890123'); | ||
| 13 | session_start(); | ||
| 14 | echo strlen(session_id()); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][session][drop] Session ID is too long in %a.php on line %d | ||
| 18 | |||
| 19 | Fatal error: [snuffleupagus][0.0.0.0][session][drop] Session ID is too long in Unknown on line 0 \ No newline at end of file | ||
diff --git a/src/tests/sid_too_short.phpt b/src/tests/sid_too_short.phpt new file mode 100644 index 0000000..3ebbc58 --- /dev/null +++ b/src/tests/sid_too_short.phpt | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | --TEST-- | ||
| 2 | SESSION ID too short | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus")) print "skip"; ?> | ||
| 5 | <?php if (!extension_loaded("session")) print "skip"; ?> | ||
| 6 | --EXTENSIONS-- | ||
| 7 | session | ||
| 8 | --INI-- | ||
| 9 | sp.configuration_file={PWD}/config/sid_length_limit.ini | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | session_id('123'); | ||
| 13 | session_start(); | ||
| 14 | echo strlen(session_id()); | ||
| 15 | ?> | ||
| 16 | --EXPECTF-- | ||
| 17 | Fatal error: [snuffleupagus][0.0.0.0][session][drop] Session ID is too short in %a.php on line %d | ||
| 18 | |||
| 19 | Fatal error: [snuffleupagus][0.0.0.0][session][drop] Session ID is too short in Unknown on line 0 \ No newline at end of file | ||
diff --git a/src/tests/stream_wrapper/stream_wrapper.phpt b/src/tests/stream_wrapper/stream_wrapper.phpt index 588a10d..6cd7a66 100644 --- a/src/tests/stream_wrapper/stream_wrapper.phpt +++ b/src/tests/stream_wrapper/stream_wrapper.phpt | |||
| @@ -23,9 +23,9 @@ Warning: Unknown: Unable to find the wrapper "php" - did you forget to enable it | |||
| 23 | 23 | ||
| 24 | Warning: file_get_contents(): Unable to find the wrapper "http" - did you forget to enable it when you configured PHP? in %a/stream_wrapper.php on line %d | 24 | Warning: file_get_contents(): Unable to find the wrapper "http" - did you forget to enable it when you configured PHP? in %a/stream_wrapper.php on line %d |
| 25 | 25 | ||
| 26 | Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: %s | 26 | Warning: file_get_contents(): php_network_getaddresses: getaddrinfo%sfailed: %s |
| 27 | 27 | ||
| 28 | Warning: file_get_contents(https://qweqwezxc): %s to open stream: php_network_getaddresses: getaddrinfo failed: %s | 28 | Warning: file_get_contents(https://qweqwezxc): %s to open stream: php_network_getaddresses: getaddrinfo%sfailed: %s |
| 29 | 29 | ||
| 30 | Warning: file_get_contents(ftp://qweqwezxc): %s to open stream: operation failed in %a/stream_wrapper.php on line %d | 30 | Warning: file_get_contents(ftp://qweqwezxc): %s to open stream: operation failed in %a/stream_wrapper.php on line %d |
| 31 | 31 | ||
diff --git a/src/tests/strict_mode/strict_mode_enabled.phpt b/src/tests/strict_mode/strict_mode_enabled.phpt index a986987..a78a604 100644 --- a/src/tests/strict_mode/strict_mode_enabled.phpt +++ b/src/tests/strict_mode/strict_mode_enabled.phpt | |||
| @@ -8,11 +8,11 @@ if (!extension_loaded("snuffleupagus")) print "skip snuffleupagus extension miss | |||
| 8 | sp.configuration_file={PWD}/config/config_strict_mode_enabled.ini | 8 | sp.configuration_file={PWD}/config/config_strict_mode_enabled.ini |
| 9 | --FILE-- | 9 | --FILE-- |
| 10 | <?php | 10 | <?php |
| 11 | ini_set('display_errors', 1); | 11 | ini_get(23); |
| 12 | ?> | 12 | ?> |
| 13 | --EXPECTF-- | 13 | --EXPECTF-- |
| 14 | Fatal error: Uncaught TypeError: ini_set()%s given in %s/tests/strict_mode/strict_mode_enabled.php:%d | 14 | Fatal error: Uncaught TypeError: ini_get()%s given in %s/tests/strict_mode/strict_mode_enabled.php:%d |
| 15 | Stack trace: | 15 | Stack trace: |
| 16 | #0 %s/tests/strict_mode/strict_mode_enabled.php(2): ini_set('display_errors', 1) | 16 | #0 %s/tests/strict_mode/strict_mode_enabled.php(2): ini_get(23) |
| 17 | #1 {main} | 17 | #1 {main} |
| 18 | thrown in %s/tests/strict_mode/strict_mode_enabled.php on line 2 | 18 | thrown in %s/tests/strict_mode/strict_mode_enabled.php on line 2 |
diff --git a/src/tests/unserialize/config/config_serialize.ini b/src/tests/unserialize/config/config_serialize.ini index f2c1699..30e8fba 100644 --- a/src/tests/unserialize/config/config_serialize.ini +++ b/src/tests/unserialize/config/config_serialize.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable(); \ No newline at end of file | 2 | sp.unserialize_hmac.enable(); \ No newline at end of file |
diff --git a/src/tests/unserialize/config/config_serialize_sim.ini b/src/tests/unserialize/config/config_serialize_sim.ini index 7f015e0..c20013f 100644 --- a/src/tests/unserialize/config/config_serialize_sim.ini +++ b/src/tests/unserialize/config/config_serialize_sim.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable().simulation(); | 2 | sp.unserialize_hmac.enable().simulation(); |
diff --git a/src/tests/unserialize/config/dump_unserialize.ini b/src/tests/unserialize/config/dump_unserialize.ini index 4352a3e..09480cc 100644 --- a/src/tests/unserialize/config/dump_unserialize.ini +++ b/src/tests/unserialize/config/dump_unserialize.ini | |||
| @@ -1,2 +1,2 @@ | |||
| 1 | sp.global.secret_key("abcdef"); | 1 | sp.global.secret_key("abcdefGHIJ"); |
| 2 | sp.unserialize_hmac.enable().dump("/tmp/dump_result/"); | 2 | sp.unserialize_hmac.enable().dump("/tmp/dump_result/"); |
diff --git a/src/tests/unserialize/serialize.phpt b/src/tests/unserialize/serialize.phpt index e93dbaf..8b7c0bc 100644 --- a/src/tests/unserialize/serialize.phpt +++ b/src/tests/unserialize/serialize.phpt | |||
| @@ -9,5 +9,5 @@ sp.configuration_file={PWD}/config/config_serialize.ini | |||
| 9 | echo serialize("a"); | 9 | echo serialize("a"); |
| 10 | ?> | 10 | ?> |
| 11 | --EXPECT-- | 11 | --EXPECT-- |
| 12 | s:1:"a";650609b417904d0d9bbf1fc44a975d13ecdf6b02b715c1a06271fb3b673f25b1 | 12 | s:1:"a";cdbc93e593656164d448db33e4668a3f30fa794d6658016365f7eb453d48b022 |
| 13 | 13 | ||
diff --git a/src/tests/unserialize/unserialize_sim.phpt b/src/tests/unserialize/unserialize_sim.phpt index 9bff2c1..1256c23 100644 --- a/src/tests/unserialize/unserialize_sim.phpt +++ b/src/tests/unserialize/unserialize_sim.phpt | |||
| @@ -7,12 +7,13 @@ sp.configuration_file={PWD}/config/config_serialize_sim.ini | |||
| 7 | --FILE-- | 7 | --FILE-- |
| 8 | <?php | 8 | <?php |
| 9 | $a=serialize("a"); | 9 | $a=serialize("a"); |
| 10 | echo $a; | 10 | echo $a . PHP_EOL; |
| 11 | var_dump(unserialize($a)); | 11 | var_dump(unserialize($a)); |
| 12 | var_dump(unserialize('s:1:"a";alyualskdufyhalkdjsfhalkjdhflaksjdfhlkasdhflkahdawkuerylksjdfhlkssjgdflaksjdh1337sjdf')); | 12 | var_dump(unserialize('s:1:"a";alyualskdufyhalkdjsfhalkjdhflaksjdfhlkasdhflkahdawkuerylksjdfhlkssjgdflaksjdh1337sjdf')); |
| 13 | ?> | 13 | ?> |
| 14 | --EXPECTF-- | 14 | --EXPECTF-- |
| 15 | s:1:"a";650609b417904d0d9bbf1fc44a975d13ecdf6b02b715c1a06271fb3b673f25b1string(1) "a" | 15 | s:1:"a";cdbc93e593656164d448db33e4668a3f30fa794d6658016365f7eb453d48b022 |
| 16 | string(1) "a" | ||
| 16 | 17 | ||
| 17 | Warning: [snuffleupagus][0.0.0.0][unserialize][simulation] Invalid HMAC for s:1:"a";alyualskdufyhalkdjsfh in %a/unserialize_sim.php on line 5 | 18 | Warning: [snuffleupagus][0.0.0.0][unserialize][simulation] Invalid HMAC for s:1:"a";alyualskdufyhalkdjsfh in %a/unserialize_sim.php on line 5 |
| 18 | string(1) "a" | 19 | string(1) "a" |
diff --git a/src/tests/unserialize_php8/config/config_serialize.ini b/src/tests/unserialize_php8/config/config_serialize.ini index 7de4438..e107f15 100644 --- a/src/tests/unserialize_php8/config/config_serialize.ini +++ b/src/tests/unserialize_php8/config/config_serialize.ini | |||
| @@ -1 +1 @@ | |||
| sp.global.secret_key("abcdef"); | sp.global.secret_key("abcdefGHIJ"); | ||
diff --git a/src/tests/upload_validation/upload_validation.phpt b/src/tests/upload_validation/upload_validation.phpt index 965d3aa..810c23d 100644 --- a/src/tests/upload_validation/upload_validation.phpt +++ b/src/tests/upload_validation/upload_validation.phpt | |||
| @@ -15,4 +15,4 @@ echo 1; | |||
| 15 | --EXPECTF-- | 15 | --EXPECTF-- |
| 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 16 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 |
| 17 | 17 | ||
| 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] A rule can't be enabled and disabled on line 1 in Unknown on line 0 | 18 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (tests/upload_ko.sh) doesn't exist on line 1 in Unknown on line 0 |
diff --git a/src/tests/upload_validation/upload_validation_no_exec.phpt b/src/tests/upload_validation/upload_validation_no_exec.phpt index b198bda..ff3dc14 100644 --- a/src/tests/upload_validation/upload_validation_no_exec.phpt +++ b/src/tests/upload_validation/upload_validation_no_exec.phpt | |||
| @@ -4,6 +4,7 @@ Upload a file, validation script not executable | |||
| 4 | file_uploads=1 | 4 | file_uploads=1 |
| 5 | sp.configuration_file={PWD}/config/upload_validation_non_exec.ini | 5 | sp.configuration_file={PWD}/config/upload_validation_non_exec.ini |
| 6 | output_buffering=off | 6 | output_buffering=off |
| 7 | expose_php=0 | ||
| 7 | --POST_RAW-- | 8 | --POST_RAW-- |
| 8 | Content-Type: multipart/form-data; boundary=blabla | 9 | Content-Type: multipart/form-data; boundary=blabla |
| 9 | --blabla | 10 | --blabla |
| @@ -14,6 +15,6 @@ Content-Disposition: form-data; name="test"; filename="test.php" | |||
| 14 | var_dump($_FILES); | 15 | var_dump($_FILES); |
| 15 | ?> | 16 | ?> |
| 16 | --EXPECTF-- | 17 | --EXPECTF-- |
| 17 | Fatal error: [snuffleupagus][0.0.0.0][config][log] Invalid configuration file in Unknown on line 0 | 18 | Warning: [snuffleupagus][0.0.0.0][upload_validation][log] Could not call '%s' : Permission denied %s |
| 18 | 19 | %a | |
| 19 | Fatal error: [snuffleupagus][0.0.0.0][config][log] The `script` (tests/data/upload_no_exec.sh) isn't executable on line 1 in Unknown on line 0 | 20 | Fatal error: [snuffleupagus][0.0.0.0][upload_validation][drop] The upload %s was rejected. in Unknown on line 0 |
diff --git a/src/tests/xxe/config/disable_xxe.ini b/src/tests/xxe/config/disable_xxe.ini index bc9d1f2..a50a3b9 100644 --- a/src/tests/xxe/config/disable_xxe.ini +++ b/src/tests/xxe/config/disable_xxe.ini | |||
| @@ -1 +1 @@ | |||
| sp.disable_xxe.enable(); | sp.xxe_protection.enable(); | ||
diff --git a/src/tests/xxe/config/disable_xxe_disable.ini b/src/tests/xxe/config/disable_xxe_disable.ini index bb1e432..eaf5755 100644 --- a/src/tests/xxe/config/disable_xxe_disable.ini +++ b/src/tests/xxe/config/disable_xxe_disable.ini | |||
| @@ -1 +1 @@ | |||
| sp.disable_xxe.disable(); | sp.xxe_protection.disable(); | ||
diff --git a/src/tests/xxe/disable_xxe_dom_disabled.phpt b/src/tests/xxe/disable_xxe_dom_disabled.phpt index a49e094..107171c 100644 --- a/src/tests/xxe/disable_xxe_dom_disabled.phpt +++ b/src/tests/xxe/disable_xxe_dom_disabled.phpt | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | --TEST-- | 1 | --TEST-- |
| 2 | Disable XXE | 2 | Disable XXE (feature enabled) |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> |
| 6 | --INI-- | 6 | --INI-- |
| 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe.ini |
| 8 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 9 | dom | 9 | dom |
| 10 | --FILE-- | 10 | --FILE-- |
diff --git a/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt b/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt new file mode 100644 index 0000000..01e3349 --- /dev/null +++ b/src/tests/xxe/disable_xxe_dom_disabled_php8.phpt | |||
| @@ -0,0 +1,57 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable XXE (feature disabled) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini | ||
| 8 | --EXTENSIONS-- | ||
| 9 | dom | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $dir = __DIR__; | ||
| 13 | $content = '<content>WARNING, external entity loaded!</content>'; | ||
| 14 | file_put_contents($dir . '/content.txt', $content); | ||
| 15 | |||
| 16 | $xml = <<<EOD | ||
| 17 | <?xml version="1.0"?> | ||
| 18 | <!DOCTYPE root | ||
| 19 | [ | ||
| 20 | <!ENTITY foo SYSTEM "file://$dir/content.txt"> | ||
| 21 | ]> | ||
| 22 | <test><testing>&foo;</testing></test> | ||
| 23 | EOD; | ||
| 24 | |||
| 25 | file_put_contents($dir . '/content.xml', $xml); | ||
| 26 | |||
| 27 | |||
| 28 | $dom = new DOMDocument('1.0'); | ||
| 29 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 30 | printf("default setting with LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 31 | |||
| 32 | $dom = new DOMDocument('1.0'); | ||
| 33 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD); | ||
| 34 | printf("default setting without LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 35 | |||
| 36 | libxml_set_external_entity_loader(null); | ||
| 37 | |||
| 38 | $dom = new DOMDocument('1.0'); | ||
| 39 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 40 | printf("disabled entity loader with LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 41 | |||
| 42 | $dom = new DOMDocument('1.0'); | ||
| 43 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD); | ||
| 44 | printf("disabled entity loader without LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 45 | |||
| 46 | ?> | ||
| 47 | --EXPECTF-- | ||
| 48 | default setting with LIBXML_NOENT: WARNING, external entity loaded! | ||
| 49 | default setting without LIBXML_NOENT: | ||
| 50 | disabled entity loader with LIBXML_NOENT: WARNING, external entity loaded! | ||
| 51 | disabled entity loader without LIBXML_NOENT: | ||
| 52 | --CLEAN-- | ||
| 53 | <?php | ||
| 54 | $dir = __DIR__; | ||
| 55 | unlink($dir . "/content.xml"); | ||
| 56 | unlink($dir . "/content.txt"); | ||
| 57 | ?> | ||
diff --git a/src/tests/xxe/disable_xxe_dom_php8.phpt b/src/tests/xxe/disable_xxe_dom_php8.phpt new file mode 100644 index 0000000..485828f --- /dev/null +++ b/src/tests/xxe/disable_xxe_dom_php8.phpt | |||
| @@ -0,0 +1,59 @@ | |||
| 1 | --TEST-- | ||
| 2 | Disable XXE (feature enabled) | ||
| 3 | --SKIPIF-- | ||
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("dom")) print("skip"); ?> | ||
| 5 | <?php if (PHP_VERSION_ID < 80000) print "skip"; ?> | ||
| 6 | --INI-- | ||
| 7 | sp.configuration_file={PWD}/config/disable_xxe.ini | ||
| 8 | --EXTENSIONS-- | ||
| 9 | dom | ||
| 10 | --FILE-- | ||
| 11 | <?php | ||
| 12 | $dir = __DIR__; | ||
| 13 | $content = '<content>WARNING, external entity loaded!</content>'; | ||
| 14 | file_put_contents($dir . '/content.txt', $content); | ||
| 15 | |||
| 16 | $xml = <<<EOD | ||
| 17 | <?xml version="1.0"?> | ||
| 18 | <!DOCTYPE root | ||
| 19 | [ | ||
| 20 | <!ENTITY foo SYSTEM "file://$dir/content.txt"> | ||
| 21 | ]> | ||
| 22 | <test><testing>&foo;</testing></test> | ||
| 23 | EOD; | ||
| 24 | |||
| 25 | file_put_contents($dir . '/content.xml', $xml); | ||
| 26 | |||
| 27 | |||
| 28 | $dom = new DOMDocument('1.0'); | ||
| 29 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 30 | printf("default setting with LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 31 | |||
| 32 | $dom = new DOMDocument('1.0'); | ||
| 33 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD); | ||
| 34 | printf("default setting without LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 35 | |||
| 36 | libxml_set_external_entity_loader(null); | ||
| 37 | |||
| 38 | $dom = new DOMDocument('1.0'); | ||
| 39 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD|LIBXML_NOENT); | ||
| 40 | printf("disabled entity loader with LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 41 | |||
| 42 | $dom = new DOMDocument('1.0'); | ||
| 43 | $dom->loadXML($xml, LIBXML_DTDATTR|LIBXML_DTDLOAD); | ||
| 44 | printf("disabled entity loader without LIBXML_NOENT: %s\n", $dom->getElementsByTagName('testing')->item(0)->nodeValue); | ||
| 45 | |||
| 46 | ?> | ||
| 47 | --EXPECTF-- | ||
| 48 | default setting with LIBXML_NOENT: WARNING, external entity loaded! | ||
| 49 | default setting without LIBXML_NOENT: | ||
| 50 | |||
| 51 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_set_external_entity_loader was tried and nopped in %a.php on line 26 | ||
| 52 | disabled entity loader with LIBXML_NOENT: WARNING, external entity loaded! | ||
| 53 | disabled entity loader without LIBXML_NOENT: | ||
| 54 | --CLEAN-- | ||
| 55 | <?php | ||
| 56 | $dir = __DIR__; | ||
| 57 | unlink($dir . "/content.xml"); | ||
| 58 | unlink($dir . "/content.txt"); | ||
| 59 | ?> | ||
diff --git a/src/tests/xxe/disable_xxe_simplexml.phpt b/src/tests/xxe/disable_xxe_simplexml.phpt index 1d3ef4c..9560156 100644 --- a/src/tests/xxe/disable_xxe_simplexml.phpt +++ b/src/tests/xxe/disable_xxe_simplexml.phpt | |||
| @@ -2,8 +2,9 @@ | |||
| 2 | Disable XXE | 2 | Disable XXE |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> | 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 5 | --INI-- | 6 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/disable_xxe.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini |
| 7 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 8 | simplexml | 9 | simplexml |
| 9 | --XFAIL-- | 10 | --XFAIL-- |
diff --git a/src/tests/xxe/disable_xxe_simplexml_oop.phpt b/src/tests/xxe/disable_xxe_simplexml_oop.phpt index e101337..1b2c4ca 100644 --- a/src/tests/xxe/disable_xxe_simplexml_oop.phpt +++ b/src/tests/xxe/disable_xxe_simplexml_oop.phpt | |||
| @@ -2,8 +2,9 @@ | |||
| 2 | Disable XXE | 2 | Disable XXE |
| 3 | --SKIPIF-- | 3 | --SKIPIF-- |
| 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> | 4 | <?php if (!extension_loaded("snuffleupagus") || !extension_loaded("simplexml") || getenv('TRAVIS')) print("skip"); ?> |
| 5 | <?php if (PHP_VERSION_ID >= 80000) print "skip"; ?> | ||
| 5 | --INI-- | 6 | --INI-- |
| 6 | sp.configuration_file={PWD}/config/disable_xxe.ini | 7 | sp.configuration_file={PWD}/config/disable_xxe_disable.ini |
| 7 | --EXTENSIONS-- | 8 | --EXTENSIONS-- |
| 8 | simplexml | 9 | simplexml |
| 9 | --XFAIL-- | 10 | --XFAIL-- |
diff --git a/src/tests/xxe/disable_xxe_xml_parse.phpt b/src/tests/xxe/disable_xxe_xml_parse.phpt index 6b48bea..bc7e338 100644 --- a/src/tests/xxe/disable_xxe_xml_parse.phpt +++ b/src/tests/xxe/disable_xxe_xml_parse.phpt | |||
| @@ -70,7 +70,8 @@ $parser = create_parser(); | |||
| 70 | $doc = xml_parse($parser, $xml, true); | 70 | $doc = xml_parse($parser, $xml, true); |
| 71 | xml_parser_free($parser); | 71 | xml_parser_free($parser); |
| 72 | 72 | ||
| 73 | --EXPECT-- | 73 | --EXPECTF-- |
| 74 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 41 | ||
| 74 | string(4) "TEST" | 75 | string(4) "TEST" |
| 75 | 76 | ||
| 76 | array(0) { | 77 | array(0) { |
| @@ -81,6 +82,8 @@ array(0) { | |||
| 81 | } | 82 | } |
| 82 | string(7) "TESTING" | 83 | string(7) "TESTING" |
| 83 | string(4) "TEST" | 84 | string(4) "TEST" |
| 85 | |||
| 86 | Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_disable_entity_loader was tried and nopped in %a.php on line 46 | ||
| 84 | string(4) "TEST" | 87 | string(4) "TEST" |
| 85 | 88 | ||
| 86 | array(0) { | 89 | array(0) { |
