diff --git a/docs/hook-order-compatibility.md b/docs/hook-order-compatibility.md index a621a57..b2508aa 100644 --- a/docs/hook-order-compatibility.md +++ b/docs/hook-order-compatibility.md @@ -3,6 +3,10 @@ Focused check on 2026-11-13: WebDecoy 2.11.4 at `92a92da`, PHP 8.5.10, WordPress 7.1.4 hook dispatcher. Fourteen request cases passed. +A follow-up [installed-plugin HTTP matrix](plugin-stack-compatibility-2026-11-13.md) +now adds 122 measured cases using real WordPress and MariaDB. This page describes +the earlier, narrower hook fixture. + The general front-end check is registered on `init` at priority 1. A callback that exits before it runs prevents detection of that request. Later redirects do not erase an already recorded detection. @@ -28,7 +32,8 @@ nonce, authentication, or enforcement behavior. ## Current companion sources reviewed -These are source reviews, **not installed-plugin compatibility certifications**: +These were source reviews during the initial pass. The linked installed-plugin +follow-up records the runtime cases now exercised and the remaining limits: - Redirection 5.10.1: `includes/module/class-plugin.php` registers canonical redirects and initialization at default `init` priority 10, with page @@ -37,11 +42,14 @@ These are source reviews, **not installed-plugin compatibility certifications**: default `init` priority 10 and its main login handling on `wp_loaded`. Its earlier `plugins_loaded` handler rewrites login request paths and `$pagenow`; consequently WebDecoy may inspect the rewritten path rather than - the original login URL. Complete mixed-plugin behavior remains untested. + the original login URL. The follow-up exercises the main login and redirect + flows, but not every setting. - Wordfence 9.1.1 has earlier bootstrap protection and later hooks. Its optimized firewall runs before WordPress. Requests it ends before WebDecoy runs are - outside this plugin's observation window; no complete Wordfence coexistence - or Extended Protection installation was tested. + outside this plugin's observation window; the initial hook fixture did not + exercise that runtime. The follow-up now + tests a manual Wordfence block in basic and native prepend modes; licensed + vendor signatures remain outside its scope. Official packages reviewed: [Redirection](https://downloads.wordpress.org/plugin/redirection.5.10.1.zip), diff --git a/docs/plugin-stack-compatibility-2026-11-13.json b/docs/plugin-stack-compatibility-2026-11-13.json new file mode 100644 index 0000000..6d6e8df --- /dev/null +++ b/docs/plugin-stack-compatibility-2026-11-13.json @@ -0,0 +1,218 @@ +{ + "tested_at": "2026-11-13", + "runtime": { + "wordpress": "7.1.4", + "php": "8.3.33", + "mariadb": "11.8.9", + "webdecoy": "2.11.4", + "wordpress_image_id": "sha256:8801a1239d7ba9fb340a5fc5ba0bf7f8d3652adbd64893e3fba7992ba618108e", + "mariadb_image_id": "sha256:2439dcd7d14010ecd1ff7a4e1c5abe8e208c34fe35290744deeeaac3569043c3" + }, + "packages": [ + { + "slug": "webdecoy", + "version": "2.11.4", + "url": "https://downloads.wordpress.org/plugin/webdecoy.2.11.4.zip", + "sha256": "6fc5d8a1e6c520f98ca67e4ab9d0274cdc1d7c06967c4ad6fbd5f0ee3a912e11" + }, + { + "slug": "redirection", + "version": "5.10.1", + "url": "https://downloads.wordpress.org/plugin/redirection.5.10.1.zip", + "sha256": "f68a4be447ecba00c64e8a39d7517807ed49cc18e77b7a364c20cb31848235b7" + }, + { + "slug": "wps-hide-login", + "version": "1.9.20", + "url": "https://downloads.wordpress.org/plugin/wps-hide-login.1.9.20.zip", + "sha256": "86fc072944700163a221c11ea4d132bd907e04229d38c3e98030e47a46ba6b72" + }, + { + "slug": "wordfence", + "version": "9.1.1", + "url": "https://downloads.wordpress.org/plugin/wordfence.9.1.1.zip", + "sha256": "51acb206ebaef1756e03112df81c749a70e4086d1a71b6e3426373e393880ad1" + } + ], + "scenarios": [ + { + "name": "baseline", + "mode": "Wordfence default/learning where active", + "plugins": [ + "webdecoy/webdecoy.php" + ], + "http_cases": 10, + "passed": true, + "wordfence": null + }, + { + "name": "redirection", + "mode": "Wordfence default/learning where active", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php" + ], + "http_cases": 11, + "passed": true, + "wordfence": null + }, + { + "name": "hide", + "mode": "Wordfence default/learning where active", + "plugins": [ + "webdecoy/webdecoy.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 11, + "passed": true, + "wordfence": null + }, + { + "name": "wordfence", + "mode": "Wordfence default/learning where active", + "plugins": [ + "webdecoy/webdecoy.php", + "wordfence/wordfence.php" + ], + "http_cases": 10, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all", + "mode": "Wordfence default/learning where active", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 12, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all-reverse", + "mode": "Wordfence default/learning where active", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 12, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all-waf-enabled", + "mode": "Wordfence enabled, native plugin bootstrap", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 14, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all-waf-enabled-reverse", + "mode": "Wordfence enabled, native plugin bootstrap", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 14, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all-extended", + "mode": "Wordfence enabled, native auto_prepend_file", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 14, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + }, + { + "name": "all-extended-reverse", + "mode": "Wordfence enabled, native auto_prepend_file", + "plugins": [ + "redirection/redirection.php", + "webdecoy/webdecoy.php", + "wordfence/wordfence.php", + "wps-hide-login/wps-hide-login.php" + ], + "http_cases": 14, + "passed": true, + "wordfence": { + "api_key_configured": false, + "is_paid": false, + "waf_status": "learning-mode", + "waf_rules_file_present": true, + "basic_protection": true + } + } + ], + "http_cases_passed": 122, + "independent_server_receipts_matched": 122, + "local_detection_rows_in_these_cases": 54, + "limitations": [ + "Synthetic HTTP clients; no browser JavaScript/client scanner exercise.", + "No Wordfence license or downloaded vendor signatures; local manual UA rule tested in both basic and auto_prepend modes.", + "No cloud reporting, real OpenAI identity/DNS verification, Apache/FPM, CDN or full-page-cache certification." + ], + "findings": [ + "No conflict observed in the tested login, navigation, redirect, AI counter and WebDecoy trap enforcement flows.", + "Wordfence manual block returns503 before WebDecoy detection; auto_prepend cases terminate before WordPress loads.", + "Repeated already-blocked-IP requests return403 without a fresh detection row.", + "WPS Hide Login rewrites the hidden login path before WebDecoy sees its request context." + ], + "production_changes": false, + "wordfence_downloaded_rule_feed_bytes": 0 +} diff --git a/docs/plugin-stack-compatibility-2026-11-13.md b/docs/plugin-stack-compatibility-2026-11-13.md new file mode 100644 index 0000000..a6aeee3 --- /dev/null +++ b/docs/plugin-stack-compatibility-2026-11-13.md @@ -0,0 +1,114 @@ +# Installed WordPress plugin coexistence check — 2026-11-13 + +**122 synthetic HTTP cases passed across 10 scenarios**, matched one-to-one +with independent server-side access receipts. No conflict was observed in the +tested navigation, login, redirect, AI-counter or WebDecoy blocking flows. +No production detection-hook change is supported by this check. + +This follows the [14-case hook-order check](hook-order-compatibility.md). +These tests use actual installed plugins, full WordPress bootstrap and a real +MariaDB database. They do not use the earlier in-memory service adapters. +The [measurement summary](plugin-stack-compatibility-2026-11-13.json) records +package hashes, runtime identities and per-scenario results. All traffic is +controlled fixture traffic, never customer traffic or detection-accuracy data. + +## Versions and scenarios + +WordPress7.1.4, PHP8.3.33, MariaDB11.8.9, public WebDecoy2.11.4, +Redirection5.10.1, WPS Hide Login1.9.20 and Wordfence9.1.1. Official WordPress.org +packages were staged before execution; no plugin code was patched. + +| Scenario | HTTP cases | Result | +| --- | ---: | --- | +| WebDecoy alone | 10 | Passed | +| WebDecoy + Redirection | 11 | Passed | +| WebDecoy + WPS Hide Login | 11 | Passed | +| WebDecoy + Wordfence, default learning mode | 10 | Passed | +| All four plugins | 12 | Passed | +| All four, alternate load order | 12 | Passed | +| All four, Wordfence enabled with local manual rule | 14 | Passed | +| Same, alternate load order | 14 | Passed | +| All four, native Wordfence `auto_prepend_file` | 14 | Passed | +| Same, alternate load order | 14 | Passed | + +The first six scenarios total 66; enforcement-enabled scenarios add 28 and native +prepend scenarios add 28. A later re-run checks the saved reproduction runner; +it does not add new coverage categories to the primary 122-case measurement. + +## What was exercised + +- A browser-style HTTP client retrieves the target page successfully. This is + an HTML request check, not a browser JavaScript test. +- Ordinary `python-requests` traffic creates real local detection rows from + WebDecoy scoring, independently of the reserved test-trigger control. +- A separate reserved Test UA returns its labeled403 JSON receipt. +- One synthetic GPTBot-UA request per scenario increments the real hourly AI + counter by exactly one. Its identity stays **claimed**, never verified. +- Correct credentials submitted to the real login form produce a login redirect + and an authenticated200 admin page, including WPS Hide Login's custom URL. +- An unauthenticated client-detection AJAX call without a nonce is rejected403 + through the dedicated handler and creates no general front-end detection. +- A local tripwire in monitor mode records its violation and proceeds to404; + block mode returns403 and records the fresh violation. +- Redirection's actual installer/model API creates a301 rule; the redirected + bot request still has a WebDecoy detection row. +- WPS Hide Login hides the original login URL with404 while WebDecoy still + records the scored bot request. +- Wordfence's local manual UA rule returns503 and prevents target content from + being served. In native prepend mode the receipt proves WordPress has not + loaded and there is no WebDecoy detection row. +- Every extended-mode request independently proves that native + `WFWAF_AUTO_PREPEND` ran; merely configuring an option is insufficient. + +## Observation boundaries confirmed + +A Wordfence block before WebDecoy runs appears in the server access log and has +no WebDecoy detection row. That is expected earlier termination, not evidence +that a protected action ran. The native prepend block happens before WordPress +itself loads. + +A second important distinction is inside WebDecoy: **an already-blocked IP can +receive403 without being scored again or creating a new detection row**. The +initial enforcement-enabled pass exposed state carried from a preceding case. +The fixture now resets only its dummy IP blocks between scenarios and separately +asserts the repeated-block behavior. Detection-row totals are not a total of all +blocked HTTP requests. Admin/AJAX exclusions and earlier edge/cache responses +also prevent one-to-one equivalence with the host's access log. + +WPS Hide Login rewrites the original hidden login URI during bootstrap. A +subsequent detector can therefore see the rewritten path. Successful login, +original-login hiding, bot scoring and AI counting still passed in this setup. + +These results support keeping the detector at its present lifecycle hook. +Moving it earlier would introduce a separate dependency/bootstrap risk and +would not make a WordPress plugin observe requests stopped before WordPress. + +## Isolation, evidence and limitations + +The two disposable containers share only a private loopback namespace. There +are no published host ports, external network routes, production credentials, +cloud keys or mail delivery. Code and toolchains are read-only. Database, +Wordfence state, logs and uploads use bounded tmpfs. Each container has one CPU, +384MB RAM limits and PID/file-size limits; PHP requests and HTTP clients have +execution deadlines. Only a dummy local administrator is created. + +The enforcement cases use a test-only trusted-loopback proxy header carrying +`192.0.2.42`, avoiding Wordfence's loopback allowlist. This is not a real +reverse-proxy deployment certification. The extended listener uses native PHP +index fallback, with no router that might skip prepend execution. + +Wordfence is unlicensed and offline. Its downloaded rules file is empty. A +local manual block is exercised in enabled and native prepend modes; vendor +signature efficacy, feed updates, scanning and cloud services are not tested. +There were startup missing-rule warnings. An initial fixture-only `WP_CLI` +bootstrap mistake was corrected before measured runs. The verified HTTP cases +show no PHP critical-error page; the full setup log is not claimed to be empty. + +Other untested surfaces include the client-side scanner (disabled to isolate +server-side behavior), browser JavaScript, Apache/FPM and `.htaccess`, multisite, +actual CDN/full-page-cache behavior, real crawler identity verification, cloud +reporting, and settings combinations outside this matrix. + +[Reproduction fixture and isolated setup](../tests/wp-compat/plugin-stack/README.md). +The fixture contains first-party test code only; WordPress and companion +packages are supplied separately. No production plugin source was changed. diff --git a/tests/wp-compat/README.md b/tests/wp-compat/README.md index b10b8ab..c62c811 100644 --- a/tests/wp-compat/README.md +++ b/tests/wp-compat/README.md @@ -48,3 +48,11 @@ python3 tests/wp-compat/hook-order.py /path/to/wordpress/wp-includes php This supplements the Docker smoke tests; it is not a full plugin-stack test. See [scope and measured results](../../docs/hook-order-compatibility.md). + +## Installed companion-plugin matrix + +The [isolated plugin-stack fixture](plugin-stack/README.md) exercises full +WordPress HTTP requests, real MariaDB storage, Redirection, WPS Hide Login and +Wordfence, including native `auto_prepend_file`. See the +[122-case measured results](../../docs/plugin-stack-compatibility-2026-11-13.md) +for the tested versions, observation limits and remaining scope. diff --git a/tests/wp-compat/plugin-stack/README.md b/tests/wp-compat/plugin-stack/README.md new file mode 100644 index 0000000..1b68419 --- /dev/null +++ b/tests/wp-compat/plugin-stack/README.md @@ -0,0 +1,76 @@ +# Installed-plugin HTTP compatibility fixture + +Disposable local tests only. This changes plugin activation/settings and creates +an administrator in the supplied **test database**. It never targets production. +It requires Docker, Python3, cached `wordpress:7.1-php8.3-apache` and `mariadb:11` +images, and an existing temporary WordPress7.1.4 tree with these public plugins: +WebDecoy2.11.4, Redirection5.10.1, WPS Hide Login1.9.20, Wordfence9.1.1. +Do not copy production files or credentials into the fixture. + +The source tree is mounted read-only. Writable DB, logs, uploads and Wordfence +storage are bounded tmpfs. Both services share a namespace with only loopback; +no ports are published and vendor downloads/cloud reporting cannot work. +`run.py` refuses an unlabeled container, exposed host ports, a writable root, +or a shared namespace whose database has external networking. + +## Prepare an existing temporary source tree + +Set `COMPAT_WORDPRESS_DIR` to a fresh, disposable WordPress directory with the +four plugin packages already extracted under `wp-content/plugins`. This fixture +does not download or install dependencies. The supplied configuration contains +public dummy credentials only. + +From this directory: + +```sh +cp wp-config.fixture.php "$COMPAT_WORDPRESS_DIR/wp-config.php" +mkdir -p "$COMPAT_WORDPRESS_DIR/wp-content/mu-plugins" "$COMPAT_WORDPRESS_DIR/wp-content/uploads" "$COMPAT_WORDPRESS_DIR/wp-content/wflogs" +cp observer.fixture.php "$COMPAT_WORDPRESS_DIR/wp-content/mu-plugins/compat-observer.php" +docker compose -p wd-plugin-stack up -d +export WP_COMPAT_CONTAINER=$(docker compose -p wd-plugin-stack ps -q wp) +export WP_COMPAT_OUTPUT=/tmp/wd-plugin-stack-results +docker exec "$WP_COMPAT_CONTAINER" php /fixture/control.php install +python3 run.py +python3 run.py --waf-enabled +``` + +The default run covers six plugin/load-order scenarios. The enforcement run +covers two combined-stack orders with a manually configured Wordfence UA block. +A test-only trusted-loopback proxy supplies `192.0.2.42` through `X-Real-IP` so +Wordfence's loopback allowlist does not mask the blocking check. This is a +controlled fixture identity, not a production proxy configuration recommendation. + +## Native Wordfence prepend mode + +Start a second listener on a different address in the same private loopback +namespace. There is deliberately **no router script**: PHP's native index +fallback must execute `auto_prepend_file` for pretty URLs as well as PHP files. +The client preserves the original host/port with `CURLOPT_CONNECT_TO`. + +```sh +docker exec -d "$WP_COMPAT_CONTAINER" sh -c 'exec php -d auto_prepend_file=/fixture/wordfence-waf.php -d display_errors=0 -d log_errors=1 -d error_log=/scratch/php-extended-errors.log -d memory_limit=128M -d max_execution_time=10 -d session.save_path=/scratch -S 127.0.0.3:8080 -t /site > /scratch/extended-server.log 2>&1' +python3 run.py --extended +``` + +Every case must match exactly one independent server receipt and its status. +Every extended-mode receipt must prove `WFWAF_AUTO_PREPEND=true`; Wordfence's +manual deny must occur before WordPress loads. Each run uses unique markers and +cookie jars and resets only fixture IP blocks between scenarios. A PHP failure, +timeout, missing SQL record, wrong redirect/login result, or wrong crawler-counter +increment fails the run. The `X-Compat-Case` observer never logs passwords/cookies. + +AI cases spoof GPTBot's UA solely to exercise the counter, and assert it is not +counted as a verified identity. This tests no external vendor rule feed or cloud +reporting. The client-side scanner is disabled; browser JavaScript, Apache/FPM, +multisite, actual proxies/CDNs and full-page caches need separate validation. +Wordfence uses an unlicensed offline install and a local manual UA rule, not +licensed signatures. These are synthetic cases, never customer traffic/efficacy. + +## Clean up + +The database and runtime files are tmpfs; removal discards the whole test site. +The output directory contains only parsed measurements and can be retained. + +```sh +docker compose -p wd-plugin-stack down +``` diff --git a/tests/wp-compat/plugin-stack/access.php b/tests/wp-compat/plugin-stack/access.php new file mode 100644 index 0000000..8597c34 --- /dev/null +++ b/tests/wp-compat/plugin-stack/access.php @@ -0,0 +1,6 @@ +$_SERVER['HTTP_X_COMPAT_CASE']??'','method'=>$_SERVER['REQUEST_METHOD'],'uri'=>$_SERVER['REQUEST_URI'],'ua'=>$_SERVER['HTTP_USER_AGENT']??'']; + register_shutdown_function(static function()use($receipt){$receipt['status']=http_response_code();$receipt['auto_prepend']=defined('WFWAF_AUTO_PREPEND') && WFWAF_AUTO_PREPEND;$receipt['wp_init_count']=function_exists('did_action')?did_action('init'):null;file_put_contents('/scratch/server-access.jsonl',json_encode($receipt)."\n",FILE_APPEND|LOCK_EX);}); +} diff --git a/tests/wp-compat/plugin-stack/client.php b/tests/wp-compat/plugin-stack/client.php new file mode 100644 index 0000000..2f42043 --- /dev/null +++ b/tests/wp-compat/plugin-stack/client.php @@ -0,0 +1,13 @@ +true,CURLOPT_FOLLOWLOCATION=>false,CURLOPT_CONNECTTIMEOUT=>2,CURLOPT_TIMEOUT=>15,CURLOPT_USERAGENT=>$ua,CURLOPT_HTTPHEADER=>$headers,CURLOPT_ENCODING=>'',CURLOPT_COOKIEFILE=>'/scratch/'.($p['jar']??'default').'.cookies',CURLOPT_COOKIEJAR=>'/scratch/'.($p['jar']??'default').'.cookies',CURLOPT_HEADERFUNCTION=>static function($c,$h)use(&$responseHeaders){$kv=explode(':',$h,2);if(count($kv)===2 && in_array(strtolower(trim($kv[0])),['location','x-redirect-by','content-type','retry-after'],true))$responseHeaders[strtolower(trim($kv[0]))]=trim($kv[1]);return strlen($h);}]); +if(!empty($p['extended']))curl_setopt($c,CURLOPT_CONNECT_TO,['127.0.0.1:8080:127.0.0.3:8080']); +if(isset($p['post'])){curl_setopt($c,CURLOPT_POST,true);curl_setopt($c,CURLOPT_POSTFIELDS,http_build_query($p['post']));} +$body=curl_exec($c);if($body===false)throw new Exception(curl_error($c)); +$summary=['marker'=>$p['marker'],'path'=>$path,'status'=>curl_getinfo($c,CURLINFO_RESPONSE_CODE),'headers'=>$responseHeaders,'body_bytes'=>strlen($body),'login_form'=>strpos($body,'name="log"')!==false,'target_content'=>strpos($body,'COMPAT_TARGET_CONTENT')!==false,'admin_screen'=>strpos($body,'wp-admin-bar-my-account')!==false,'critical_error'=>strpos($body,'There has been a critical error')!==false,'test_receipt'=>strpos($body,'"webdecoy_test":true')!==false,'wordfence_block'=>strpos($body,'Your access to this site has been limited')!==false || strpos($body,'Generated by Wordfence')!==false]; +file_put_contents('/scratch/client-results.jsonl',json_encode($summary)."\n",FILE_APPEND|LOCK_EX);echo json_encode($summary); diff --git a/tests/wp-compat/plugin-stack/compose.yml b/tests/wp-compat/plugin-stack/compose.yml new file mode 100644 index 0000000..44be665 --- /dev/null +++ b/tests/wp-compat/plugin-stack/compose.yml @@ -0,0 +1,71 @@ +# Only for an already staged, disposable WordPress source tree. +# No port mappings; HTTP clients run via docker exec inside private loopback. +services: + db: + image: mariadb:11 + pull_policy: never + labels: + webdecoy.task: wp-stack-compat + network_mode: none + read_only: true + user: "999:999" + mem_limit: 384m + memswap_limit: 384m + cpus: 1 + pids_limit: 96 + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + environment: + HOME: /tmp + MARIADB_DATABASE: wp + MARIADB_USER: wp + MARIADB_PASSWORD: fixture-db-password + MARIADB_ROOT_PASSWORD: fixture-root-password + tmpfs: + - /var/lib/mysql:rw,size=268435456,uid=999,gid=999,mode=0700 + - /run/mysqld:rw,size=1048576,uid=999,gid=999,mode=0750 + - /tmp:rw,size=16777216,uid=999,gid=999,mode=0700 + ulimits: + nofile: 256 + fsize: 134217728 + command: [--bind-address=127.0.0.1, --skip-name-resolve, --innodb-buffer-pool-size=32M, --innodb-log-file-size=8M, --innodb-log-buffer-size=4M, --max-connections=12, --performance-schema=OFF] + healthcheck: + test: [CMD, healthcheck.sh, --connect, --innodb_initialized] + interval: 2s + timeout: 3s + retries: 30 + logging: + options: {max-size: 1m, max-file: "1"} + wp: + image: wordpress:7.1-php8.3-apache + pull_policy: never + labels: + webdecoy.task: wp-stack-compat + depends_on: + db: {condition: service_healthy} + network_mode: service:db + read_only: true + user: "33:33" + mem_limit: 384m + memswap_limit: 384m + cpus: 1 + pids_limit: 32 + cap_drop: [ALL] + security_opt: [no-new-privileges:true] + environment: {HOME: /scratch, TMPDIR: /tmp} + working_dir: /scratch + volumes: + - ${COMPAT_WORDPRESS_DIR:?Set a disposable staged WordPress directory}:/site:ro + - .:/fixture:ro + tmpfs: + - /scratch:rw,size=67108864,uid=33,gid=33,mode=0700 + - /tmp:rw,size=16777216,uid=33,gid=33,mode=0700 + - /site/wp-content/uploads:rw,size=16777216,uid=33,gid=33,mode=0750 + - /site/wp-content/wflogs:rw,size=33554432,uid=33,gid=33,mode=0750 + ulimits: + nofile: 128 + fsize: 16777216 + entrypoint: php + command: [-d, display_errors=0, -d, log_errors=1, -d, error_log=/scratch/php-errors.log, -d, memory_limit=128M, -d, max_execution_time=10, -d, session.save_path=/scratch, -S, "127.0.0.1:8080", -t, /site, /fixture/router.php] + logging: + options: {max-size: 1m, max-file: "1"} diff --git a/tests/wp-compat/plugin-stack/configure-redirection.php b/tests/wp-compat/plugin-stack/configure-redirection.php new file mode 100644 index 0000000..cb64d50 --- /dev/null +++ b/tests/wp-compat/plugin-stack/configure-redirection.php @@ -0,0 +1,8 @@ +install(); +if(is_wp_error($install))throw new Exception($install->get_error_message()); +global $wpdb; +if ($wpdb->get_var("SELECT id FROM {$wpdb->prefix}redirection_items WHERE url='/compat-old/' LIMIT 1")) { echo json_encode(['redirection_installed'=>true,'rule_exists'=>true]); return; } +$redirect=\Redirection\Redirect\Redirect::create(['url'=>'/compat-old/','action_type'=>'url','action_code'=>301,'action_data'=>['url'=>'http://127.0.0.1:8080/compat-target/'],'match_type'=>'url','group_id'=>1]); +if(is_wp_error($redirect))throw new Exception($redirect->get_error_message()); +echo json_encode(['redirection_installed'=>true,'rule_created'=>true]); diff --git a/tests/wp-compat/plugin-stack/configure-wordfence-block.php b/tests/wp-compat/plugin-stack/configure-wordfence-block.php new file mode 100644 index 0000000..4713d5b --- /dev/null +++ b/tests/wp-compat/plugin-stack/configure-wordfence-block.php @@ -0,0 +1,6 @@ +getStorageEngine()->setConfig('wafStatus','enabled'); +$found=false;foreach(wfBlock::patternBlocks(true) as $pattern){if($pattern->userAgent==='*Compat-wf-rule-block*')$found=true;} +if(!$found)wfBlock::createPattern('Offline compatibility user-agent block','','','*Compat-wf-rule-block*','',600); +echo json_encode(['waf_status'=>wfWAF::getInstance()->getStorageEngine()->getConfig('wafStatus'),'pattern_count'=>count(wfBlock::patternBlocks(true)),'license_configured'=>(bool)wfConfig::get('apiKey','')]); diff --git a/tests/wp-compat/plugin-stack/configure-wordfence-proxy.php b/tests/wp-compat/plugin-stack/configure-wordfence-proxy.php new file mode 100644 index 0000000..281de69 --- /dev/null +++ b/tests/wp-compat/plugin-stack/configure-wordfence-proxy.php @@ -0,0 +1,7 @@ +getStorageEngine()->setConfig('howGetIPs','HTTP_X_REAL_IP','synced'); +wfWAF::getInstance()->getStorageEngine()->setConfig('howGetIPs_trusted_proxies_unified','127.0.0.1','synced'); +echo json_encode(['header'=>'HTTP_X_REAL_IP','proxy'=>'127.0.0.1']); diff --git a/tests/wp-compat/plugin-stack/control.php b/tests/wp-compat/plugin-stack/control.php new file mode 100644 index 0000000..4220c46 --- /dev/null +++ b/tests/wp-compat/plugin-stack/control.php @@ -0,0 +1,43 @@ +'Compatibility target','post_name'=>'compat-target','post_type'=>'page','post_status'=>'publish','post_content'=>'COMPAT_TARGET_CONTENT']); + echo json_encode(['installed'=>is_blog_installed(),'target_id'=>$id]);exit; +} +if($cmd==='plugins'){ + $want=array_filter(explode(',',$argv[2]??'webdecoy/webdecoy.php')); + foreach(get_option('active_plugins',[]) as $plugin)if(!in_array($plugin,$want,true))deactivate_plugins($plugin,true); + foreach($want as $plugin){$e=activate_plugin($plugin);if(is_wp_error($e))throw new Exception($e->get_error_message());} + echo json_encode(['active'=>get_option('active_plugins')]);exit; +} +if($cmd==='configure'){ + $o=get_option('webdecoy_options',[]);$o['enabled']=true;$o['api_key']='';$o['monitor_mode']=($argv[2]??'monitor')==='monitor'; + $o['trusted_proxies']=($argv[3]??'')==='proxy'?'127.0.0.1':''; + $o['scanner_enabled']=false;$o['honeytoken_enabled']=false;$o['traps_fake_plugins']=false;$o['traps_xmlrpc']=false; + $o['rate_limit_enabled']=false;$o['tripwire_enabled']=true;$o['tripwire_include_defaults']=false;$o['tripwire_paths']=['/compat-trap/'];$o['tripwire_prefixes']=[];$o['tripwire_patterns']=[];$o['tripwire_action']='block';$o['tripwire_response']='block';$o['tripwire_dry_run']=false; + update_option('webdecoy_options',$o); update_option('whl_page','compat-login');update_option('whl_redirect_admin','compat-hidden'); + echo json_encode(['monitor_mode'=>$o['monitor_mode']]);exit; +} +if($cmd==='order'){ update_option('active_plugins',explode(',',$argv[2]));echo json_encode(['active'=>get_option('active_plugins')]);exit; } +if($cmd==='query'){ + global $wpdb;$marker=$argv[2]??''; + $rows=$wpdb->get_results($wpdb->prepare("SELECT id,ip_address,user_agent,score,threat_level,source,flags FROM {$wpdb->prefix}webdecoy_detections WHERE user_agent LIKE %s ORDER BY id",'%'.$wpdb->esc_like($marker).'%'),ARRAY_A); + echo json_encode(['rows'=>$rows,'db_error'=>$wpdb->last_error]);exit; +} +if($cmd==='state'){ + global $wp_version;echo json_encode(['wp'=>$wp_version,'php'=>PHP_VERSION,'plugins'=>get_option('active_plugins',[]),'webdecoy'=>get_option('webdecoy_options',[]),'wordfence_api_key_configured'=>class_exists('wfConfig') ? (bool)wfConfig::get('apiKey','') : null]);exit; +} +if($cmd==='eval'){ + // Trusted fixture file supplied by the test runner, never an HTTP parameter. + require '/fixture/'.$argv[2];exit; +} +throw new Exception('Unknown control command'); diff --git a/tests/wp-compat/plugin-stack/crawler-counts.php b/tests/wp-compat/plugin-stack/crawler-counts.php new file mode 100644 index 0000000..5686fad --- /dev/null +++ b/tests/wp-compat/plugin-stack/crawler-counts.php @@ -0,0 +1,2 @@ +$wpdb->get_results("SELECT agent_id,verification,SUM(hits) AS hits FROM {$t} GROUP BY agent_id,verification",ARRAY_A),'db_error'=>$wpdb->last_error]); diff --git a/tests/wp-compat/plugin-stack/inspect-wordfence.php b/tests/wp-compat/plugin-stack/inspect-wordfence.php new file mode 100644 index 0000000..51a6f40 --- /dev/null +++ b/tests/wp-compat/plugin-stack/inspect-wordfence.php @@ -0,0 +1,2 @@ +(bool)wfConfig::get('apiKey',''),'is_paid'=>(bool)wfConfig::get('isPaid',false),'waf_status'=>wfWAF::getInstance()->getStorageEngine()->getConfig('wafStatus'),'waf_rules_file_present'=>is_file(WP_CONTENT_DIR.'/wflogs/rules.php'),'basic_protection'=>defined('WFWAF_OPERATIONAL')?WFWAF_OPERATIONAL:null]); diff --git a/tests/wp-compat/plugin-stack/ip-block-state.php b/tests/wp-compat/plugin-stack/ip-block-state.php new file mode 100644 index 0000000..c972834 --- /dev/null +++ b/tests/wp-compat/plugin-stack/ip-block-state.php @@ -0,0 +1,2 @@ +$wpdb->get_results("SELECT ip_address,reason FROM {$wpdb->prefix}webdecoy_blocked_ips",ARRAY_A),'db_error'=>$wpdb->last_error]); diff --git a/tests/wp-compat/plugin-stack/observer.fixture.php b/tests/wp-compat/plugin-stack/observer.fixture.php new file mode 100644 index 0000000..5a4e4a7 --- /dev/null +++ b/tests/wp-compat/plugin-stack/observer.fixture.php @@ -0,0 +1,12 @@ +$compat_marker,'original_uri'=>$compat_original_uri,'final_uri'=>$_SERVER['REQUEST_URI'] ?? '', 'status'=>http_response_code(),'init'=>did_action('init'),'webdecoy_registered'=>function_exists('webdecoy') ? has_action('init',[webdecoy(),'early_check']) : false]; + if($error && in_array($error['type'],[E_ERROR,E_PARSE,E_COMPILE_ERROR],true))$row['fatal']=$error['message']; + file_put_contents('/scratch/request-observer.jsonl',json_encode($row)."\n",FILE_APPEND|LOCK_EX); +}); diff --git a/tests/wp-compat/plugin-stack/read-access.php b/tests/wp-compat/plugin-stack/read-access.php new file mode 100644 index 0000000..c6611a3 --- /dev/null +++ b/tests/wp-compat/plugin-stack/read-access.php @@ -0,0 +1,2 @@ +query("DELETE FROM {$wpdb->prefix}webdecoy_blocked_ips WHERE ip_address IN ('127.0.0.1','192.0.2.42')");wp_cache_flush();echo json_encode(['removed_fixture_blocks'=>$n]); diff --git a/tests/wp-compat/plugin-stack/router.php b/tests/wp-compat/plugin-stack/router.php new file mode 100644 index 0000000..930cbf5 --- /dev/null +++ b/tests/wp-compat/plugin-stack/router.php @@ -0,0 +1,5 @@ +