diff --git a/.github/workflows/vip-policy-preview.yml b/.github/workflows/vip-policy-preview.yml new file mode 100644 index 0000000..06d2d9a --- /dev/null +++ b/.github/workflows/vip-policy-preview.yml @@ -0,0 +1,22 @@ +name: VIP policy preview tests +on: + pull_request: + paths: + - 'docs/integrations/wordpress-vip/**' + - '.github/workflows/vip-policy-preview.yml' + push: + branches: [main] + paths: + - 'docs/integrations/wordpress-vip/**' + - '.github/workflows/vip-policy-preview.yml' +permissions: + contents: read +jobs: + offline-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '22' + - run: node --test docs/integrations/wordpress-vip/plan.test.mjs diff --git a/.github/workflows/vip-standards.yml b/.github/workflows/vip-standards.yml new file mode 100644 index 0000000..e6ef861 --- /dev/null +++ b/.github/workflows/vip-standards.yml @@ -0,0 +1,20 @@ +name: VIP coding standards +on: + pull_request: + push: + branches: [main] +permissions: + contents: read +jobs: + vip-phpcs: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: shivammathur/setup-php@v2 + with: + php-version: '8.3' + tools: composer + - name: Install isolated, locked VIP standards + run: composer --working-dir=docs/integrations/wordpress-vip install --no-interaction --no-progress --prefer-dist + - name: Require zero unreviewed VIP errors and warnings + run: docs/integrations/wordpress-vip/vendor/bin/phpcs --standard=WordPress-VIP-Go --extensions=php webdecoy.php uninstall.php admin includes public sdk/src templates diff --git a/admin/partials/blocked-ips-page.php b/admin/partials/blocked-ips-page.php index 2cc28c2..f66cf64 100644 --- a/admin/partials/blocked-ips-page.php +++ b/admin/partials/blocked-ips-page.php @@ -45,14 +45,14 @@ } // Get blocked IPs -$page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; -$per_page = 20; +$wd_current_page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; +$wd_per_page = 20; $blocked_ips = $blocker->get_blocked_ips([ - 'page' => $page, - 'per_page' => $per_page, + 'page' => $wd_current_page, + 'per_page' => $wd_per_page, ]); $total = $blocker->get_blocked_count(); -$total_pages = ceil($total / $per_page); +$total_pages = ceil($total / $wd_per_page); $stats = $blocker->get_stats(); ?> @@ -168,7 +168,7 @@ class="button button-small" 'prev_text' => '«', 'next_text' => '»', 'total' => $total_pages, - 'current' => $page, + 'current' => $wd_current_page, ]); ?> diff --git a/admin/partials/detections-page.php b/admin/partials/detections-page.php index 0d17cce..87a17a6 100644 --- a/admin/partials/detections-page.php +++ b/admin/partials/detections-page.php @@ -19,9 +19,9 @@ $table = esc_sql($wpdb->prefix . 'webdecoy_detections'); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only admin list filtering via GET, no state change -$page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; -$per_page = 50; -$offset = ($page - 1) * $per_page; +$wd_current_page = isset($_GET['paged']) ? max(1, intval($_GET['paged'])) : 1; +$wd_per_page = 50; +$offset = ($wd_current_page - 1) * $wd_per_page; // Filters $threat_level = isset($_GET['threat_level']) ? sanitize_text_field(wp_unslash($_GET['threat_level'])) : ''; @@ -86,13 +86,15 @@ }; $output = fopen('php://output', 'w'); + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv -- Writes exclusively to the already-open php://output CSV download stream; no local filesystem path is used. fputcsv($output, ['Date', 'IP Address', 'Score', 'Threat Level', 'Source', 'User Agent', 'Flags']); $export_query = "SELECT * FROM {$table} WHERE {$where} ORDER BY created_at DESC"; - // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names $export_results = $wpdb->get_results($wpdb->prepare($export_query, $params), ARRAY_A); foreach ($export_results as $row) { + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv -- Writes exclusively to the already-open php://output CSV download stream; no local filesystem path is used. fputcsv($output, [ $csv_safe($row['created_at']), $csv_safe($row['ip_address']), @@ -110,14 +112,14 @@ // Get total - always use prepare() $total_query = "SELECT COUNT(*) FROM {$table} WHERE {$where}"; -// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names +// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names $total = $wpdb->get_var($wpdb->prepare($total_query, $params)); -$total_pages = ceil($total / $per_page); +$total_pages = ceil($total / $wd_per_page); // Get detections - always use prepare() $query = "SELECT * FROM {$table} WHERE {$where} ORDER BY created_at DESC LIMIT %d OFFSET %d"; -$query_params = array_merge($params, [$per_page, $offset]); -// phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names +$query_params = array_merge($params, [$wd_per_page, $offset]); +// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- Query built dynamically with safe table/column names $detections = $wpdb->get_results($wpdb->prepare($query, $query_params), ARRAY_A); // Get stats @@ -536,7 +538,7 @@ class="button button-small"> 'prev_text' => '«', 'next_text' => '»', 'total' => $total_pages, - 'current' => $page, + 'current' => $wd_current_page, ]; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- paginate_links returns safe HTML echo paginate_links($pagination_args); diff --git a/admin/partials/statistics-page.php b/admin/partials/statistics-page.php index 52a22e5..b120395 100644 --- a/admin/partials/statistics-page.php +++ b/admin/partials/statistics-page.php @@ -20,107 +20,124 @@ $blocked_table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); $checkout_table = esc_sql($wpdb->prefix . 'webdecoy_checkout_attempts'); -// 30-day detection trend -$thirty_days_ago = gmdate('Y-m-d H:i:s', strtotime('-30 days')); -$daily_counts = $wpdb->get_results($wpdb->prepare( - "SELECT DATE(created_at) as date, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY DATE(created_at) ORDER BY date ASC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago -), ARRAY_A); +// Read-only admin aggregates may lag writes by at most one minute. No enforcement uses them. +$wd_stats_key = 'admin_statistics_' . gmdate('Y-m-d') . '_' . (int) class_exists('WooCommerce'); +$wd_stats_cached = wp_cache_get($wd_stats_key, 'webdecoy_analytics'); +if (is_array($wd_stats_cached)) { + [$daily_data, $threat_distribution, $top_signals, $top_ips, $source_distribution, $total_30d, $total_7d, $total_today, $active_blocks, $woo_stats] = $wd_stats_cached; +} else { + // 30-day detection trend + $thirty_days_ago = gmdate('Y-m-d H:i:s', strtotime('-30 days')); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $daily_counts = $wpdb->get_results($wpdb->prepare( + "SELECT DATE(created_at) as date, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY DATE(created_at) ORDER BY date ASC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + ), ARRAY_A); -// Fill in missing days with 0 -$daily_data = []; -for ($i = 29; $i >= 0; $i--) { - $date = gmdate('Y-m-d', strtotime("-{$i} days")); - $daily_data[$date] = 0; -} -foreach ($daily_counts as $row) { - if (isset($daily_data[$row['date']])) { - $daily_data[$row['date']] = (int) $row['count']; + // Fill in missing days with 0 + $daily_data = []; + for ($i = 29; $i >= 0; $i--) { + $date = gmdate('Y-m-d', strtotime("-{$i} days")); + $daily_data[$date] = 0; + } + foreach ($daily_counts as $row) { + if (isset($daily_data[$row['date']])) { + $daily_data[$row['date']] = (int) $row['count']; + } } -} -// Threat level distribution -$threat_distribution = $wpdb->get_results($wpdb->prepare( - "SELECT threat_level, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY threat_level ORDER BY count DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago -), ARRAY_A); + // Threat level distribution + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $threat_distribution = $wpdb->get_results($wpdb->prepare( + "SELECT threat_level, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY threat_level ORDER BY count DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + ), ARRAY_A); -// Top flagged signals (parse from JSON flags) -$recent_flags = $wpdb->get_results($wpdb->prepare( - "SELECT flags FROM {$detections_table} WHERE created_at > %s AND flags IS NOT NULL AND flags != '' LIMIT 500", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago -), ARRAY_A); + // Top flagged signals (parse from JSON flags) + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $recent_flags = $wpdb->get_results($wpdb->prepare( + "SELECT flags FROM {$detections_table} WHERE created_at > %s AND flags IS NOT NULL AND flags != '' LIMIT 500", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + ), ARRAY_A); -$signal_counts = []; -foreach ($recent_flags as $row) { - // flags is TEXT DEFAULT NULL; cast so a null row never reaches json_decode() - // (a deprecation on PHP 8.1+). '' decodes to null and is skipped just below. - $flags_data = json_decode((string) ($row['flags'] ?? ''), true); - if (!is_array($flags_data)) { - continue; - } - // Handle structured format - $flags_arr = []; - if (isset($flags_data['flags']) && is_array($flags_data['flags'])) { - $flags_arr = $flags_data['flags']; - } elseif (isset($flags_data['f']) && is_array($flags_data['f'])) { - $flags_arr = $flags_data['f']; - } elseif (!isset($flags_data['flags']) && !isset($flags_data['f']) && !isset($flags_data['metadata'])) { - // Plain array of flags - $flags_arr = array_filter($flags_data, 'is_string'); - } - foreach ($flags_arr as $flag) { - if (is_string($flag)) { - $signal_counts[$flag] = ($signal_counts[$flag] ?? 0) + 1; + $signal_counts = []; + foreach ($recent_flags as $row) { + // flags is TEXT DEFAULT NULL; cast so a null row never reaches json_decode() + // (a deprecation on PHP 8.1+). '' decodes to null and is skipped just below. + $flags_data = json_decode((string) ($row['flags'] ?? ''), true); + if (!is_array($flags_data)) { + continue; + } + // Handle structured format + $flags_arr = []; + if (isset($flags_data['flags']) && is_array($flags_data['flags'])) { + $flags_arr = $flags_data['flags']; + } elseif (isset($flags_data['f']) && is_array($flags_data['f'])) { + $flags_arr = $flags_data['f']; + } elseif (!isset($flags_data['flags']) && !isset($flags_data['f']) && !isset($flags_data['metadata'])) { + // Plain array of flags + $flags_arr = array_filter($flags_data, 'is_string'); + } + foreach ($flags_arr as $flag) { + if (is_string($flag)) { + $signal_counts[$flag] = ($signal_counts[$flag] ?? 0) + 1; + } } } -} -arsort($signal_counts); -$top_signals = array_slice($signal_counts, 0, 10, true); + arsort($signal_counts); + $top_signals = array_slice($signal_counts, 0, 10, true); -// Top blocked IPs -$top_ips = $wpdb->get_results($wpdb->prepare( - "SELECT ip_address, COUNT(*) as count, MAX(created_at) as last_seen FROM {$detections_table} WHERE created_at > %s GROUP BY ip_address ORDER BY count DESC LIMIT 10", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago -), ARRAY_A); + // Top blocked IPs + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $top_ips = $wpdb->get_results($wpdb->prepare( + "SELECT ip_address, COUNT(*) as count, MAX(created_at) as last_seen FROM {$detections_table} WHERE created_at > %s GROUP BY ip_address ORDER BY count DESC LIMIT 10", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + ), ARRAY_A); -// Source distribution -$source_distribution = $wpdb->get_results($wpdb->prepare( - "SELECT source, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY source ORDER BY count DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago -), ARRAY_A); + // Source distribution + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $source_distribution = $wpdb->get_results($wpdb->prepare( + "SELECT source, COUNT(*) as count FROM {$detections_table} WHERE created_at > %s GROUP BY source ORDER BY count DESC", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + ), ARRAY_A); -// Overall stats -$total_30d = array_sum($daily_data); -$total_7d = $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$detections_table} WHERE created_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - gmdate('Y-m-d H:i:s', strtotime('-7 days')) -)); -$total_today = $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$detections_table} WHERE created_at >= %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - gmdate('Y-m-d 00:00:00') -)); -// expires_at is stored in UTC, so it must be compared against a UTC value. MySQL's -// NOW() resolves in the database session time zone (SYSTEM by default, which -// WordPress never sets), so it disagrees with the column on any DB host not on UTC. -$active_blocks = $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$blocked_table} WHERE expires_at IS NULL OR expires_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - gmdate('Y-m-d H:i:s') -)); + // Overall stats + $total_30d = array_sum($daily_data); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $total_7d = $wpdb->get_var($wpdb->prepare( + "SELECT COUNT(*) FROM {$detections_table} WHERE created_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + gmdate('Y-m-d H:i:s', strtotime('-7 days')) + )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $total_today = $wpdb->get_var($wpdb->prepare( + "SELECT COUNT(*) FROM {$detections_table} WHERE created_at >= %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + gmdate('Y-m-d 00:00:00') + )); + // expires_at is stored in UTC, so it must be compared against a UTC value. MySQL's + // NOW() resolves in the database session time zone (SYSTEM by default, which + // WordPress never sets), so it disagrees with the column on any DB host not on UTC. + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + $active_blocks = $wpdb->get_var($wpdb->prepare( + "SELECT COUNT(*) FROM {$blocked_table} WHERE expires_at IS NULL OR expires_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + gmdate('Y-m-d H:i:s') + )); -// WooCommerce stats (if active) -$woo_stats = null; -if (class_exists('WooCommerce')) { - $woo_stats = [ - 'attempts' => (int) $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$checkout_table} WHERE created_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago - )), - 'blocked' => (int) $wpdb->get_var($wpdb->prepare( - "SELECT COUNT(*) FROM {$checkout_table} WHERE created_at > %s AND status = 'blocked'", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input - $thirty_days_ago - )), - ]; + // WooCommerce stats (if active) + $woo_stats = null; + if (class_exists('WooCommerce')) { + $woo_stats = [ + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query. + 'attempts' => (int) $wpdb->get_var($wpdb->prepare( + "SELECT COUNT(*) FROM {$checkout_table} WHERE created_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + )), + 'blocked' => (int) $wpdb->get_var($wpdb->prepare( + "SELECT COUNT(*) FROM {$checkout_table} WHERE created_at > %s AND status = 'blocked'", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix, not user input + $thirty_days_ago + )), + ]; + } + wp_cache_set($wd_stats_key, [$daily_data, $threat_distribution, $top_signals, $top_ips, $source_distribution, $total_30d, $total_7d, $total_today, $active_blocks, $woo_stats], 'webdecoy_analytics', 60); } // Known crawlers, AI agents and bot tools over 7 days (counters only). @@ -135,6 +152,7 @@

+

diff --git a/docs/integrations/wordpress-vip/.gitignore b/docs/integrations/wordpress-vip/.gitignore new file mode 100644 index 0000000..887e2f4 --- /dev/null +++ b/docs/integrations/wordpress-vip/.gitignore @@ -0,0 +1,2 @@ +/vendor/ +!composer.lock diff --git a/docs/integrations/wordpress-vip/README.md b/docs/integrations/wordpress-vip/README.md new file mode 100644 index 0000000..8b4b36a --- /dev/null +++ b/docs/integrations/wordpress-vip/README.md @@ -0,0 +1,63 @@ +# WordPress VIP integration prototype + +Status: **offline policy preview, not VIP-certified or live-validated**. No network calls or apply command. This developer tool lives under `docs/`, which `build.sh` excludes from distributed plugin ZIPs. It adds no WordPress request overhead. + +This prototype converts an explicitly selected list of crawler User-Agent tokens into a proposed VIP edge restriction configuration. It does not fetch a WebDecoy policy feed, ingest VIP logs, verify agent identities, or install the WordPress plugin. Each is a separate integration capability. + +## Preview a synthetic example + +Requires Node.js22+. From the repository root: + +```sh +node --test docs/integrations/wordpress-vip/plan.test.mjs +# Make a fresh copy of the synthetic snapshot; do not misdate real snapshots. +node --input-type=module -e 'import fs from "node:fs"; const p="docs/integrations/wordpress-vip/examples/snapshot.json";const s=JSON.parse(fs.readFileSync(p));s.capturedAt=new Date().toISOString();fs.writeFileSync("/tmp/webdecoy-vip-example.json",JSON.stringify(s));' +node docs/integrations/wordpress-vip/plan.mjs \ + --snapshot /tmp/webdecoy-vip-example.json \ + --policy docs/integrations/wordpress-vip/examples/policy.json \ + > /tmp/webdecoy-vip-plan.json +``` + +The sample environment42, UUIDs and `WebDecoy-VIP-Test/1.0` token are synthetic. This is not a recommended production blocklist. A stale example intentionally fails unless you create a fresh synthetic copy. + +## Inputs and output + +For a real preview, an authorized VIP operator must capture the **complete** current restriction list for the specific environment and map it to the snapshot format. A missing or partial response must never become `groups: []`. Existing groups require their real IDs. Optional API timestamps are stripped from mutation inputs. Unsupported fields/operators fail rather than being silently discarded. The snapshot timestamp is supplied by the operator; it is not proof of completeness or authenticity. + +Choose specific crawler tokens using the publisher's policy, WebDecoy evidence and recent HTTP request logs. UA tokens are case-insensitive substring rules: a claimed name does not verify identity, intent or harm. There is no automatic recommendation to block all AI traffic. Add actual monitoring/support/browser UAs to `protectedUserAgents`; built-in examples only catch obvious mistakes and cannot guarantee zero false positives. + +Keep a stable UUID `managedGroupId` for WebDecoy's group. Repeated runs update that ID, preserving unrelated groups. Group ID/note collisions are rejected. The planner enforces the default25 total rule entries across all groups; it does not assume VIP has granted a higher limit. + +The JSON plan contains `before`, `after`, a baseline fingerprint, and GraphQL request bodies for the proposed change and rollback. **Neither request is sent.** Store plans privately: they expose environment policy even though they contain no API credentials. + +## Operator validation before any write + +1. Obtain a VIP nonproduction environment and an authorized operator. This prototype needs no credentials; never put credentials in a policy file or commit. +2. Capture the full configuration and verify environment identity. Preview the policy. Inspect every preserved rule and every proposed token. +3. Compare proposed rules against recent actual HTTP logs and all required VIP/support services. VIP restrictions are global: cached/uncached pages, logged-in traffic, assets and API endpoints can be affected. +4. Immediately before a manual mutation, recapture the list and compare the normalized groups to `before`. If changed, regenerate and re-review. The hash is an offline comparison aid, **not an atomic concurrency lock**. Coordinate with other administrators to avoid concurrent writes. +5. If separately approved, an authorized operator submits the reviewed GraphQL request through VIP's supported API tooling. Observe propagation and test the selected test UA and ordinary browser/service UAs. Record response codes and preserve the before-state. +6. Rollback also replaces the complete list. Re-read and reconcile any intervening third-party edits before submitting a rollback; blindly replaying an old snapshot can erase other administrators' changes. + +No cron workflow, network client or live deployment is included. Do not describe the prototype as an approved Integration Center integration. An end-to-end VIP pilot and partner review remain required. + +## Coverage architecture + +- **WordPress plugin:** only PHP-reaching requests. Full-page edge cache hits and edge rejections do not execute plugin code. +- **VIP edge restriction plan:** control of declared User-Agent names, including cached requests. No analytics delivered by this planner. +- **Future observability connector:** evaluate VIP HTTP request log export/Log Shipping with VIP. Confirm eligible sources, coverage, delivery format and data handling before claiming complete edge visibility. + +## Official references (checked November15,2026) + +- [VIP user-agent restrictions: scope, rule limit, services and propagation](https://docs.wpvip.com/security-controls/user-agent-restrictions/) +- [VIP update mutation](https://docs.wpvip.com/vip-api/reference/security/operations/mutations/update-user-agent-access-restrictions) +- [Group input schema](https://docs.wpvip.com/vip-api/reference/common/types/inputs/edge-config-update-user-agent-group-input) +- [VIP service user agents](https://docs.wpvip.com/infrastructure/vip-user-agents/) +- [Plugin evaluation](https://docs.wpvip.com/plugins/third-party-plugins/) +- [Git-based plugin installation](https://docs.wpvip.com/plugins/installing-plugins/) +- [Log Shipping](https://docs.wpvip.com/logs/log-shipping/) +- [Technology partner intake](https://wpvip.com/partners/technology-partners/become-a-partner/) + +## Runtime standards follow-up + +See [remediation](remediation.md) for code changes, reproducible scan commands, reviewed exceptions, and remaining VIP pilot requirements. The original baseline is preserved. A passing static check is not VIP certification. diff --git a/docs/integrations/wordpress-vip/composer.json b/docs/integrations/wordpress-vip/composer.json new file mode 100644 index 0000000..6bbee74 --- /dev/null +++ b/docs/integrations/wordpress-vip/composer.json @@ -0,0 +1,11 @@ +{ + "require-dev": { + "automattic/vipwpcs": "^3.0" + }, + "config": { + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } + }, + "license": "GPL-2.0-or-later" +} diff --git a/docs/integrations/wordpress-vip/composer.lock b/docs/integrations/wordpress-vip/composer.lock new file mode 100644 index 0000000..a394e10 --- /dev/null +++ b/docs/integrations/wordpress-vip/composer.lock @@ -0,0 +1,545 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "5785c94aa16b73200c99746c57fb0858", + "packages": [], + "packages-dev": [ + { + "name": "automattic/vipwpcs", + "version": "3.1.0", + "source": { + "type": "git", + "url": "https://github.com/Automattic/VIP-Coding-Standards.git", + "reference": "9c47cd036754e0e5f354a9914568f052043c3f30" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Automattic/VIP-Coding-Standards/zipball/9c47cd036754e0e5f354a9914568f052043c3f30", + "reference": "9c47cd036754e0e5f354a9914568f052043c3f30", + "shasum": "" + }, + "require": { + "php": ">=7.4", + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "sirbrillig/phpcs-variable-analysis": "^2.13.0", + "squizlabs/php_codesniffer": "^3.13.5", + "wp-coding-standards/wpcs": "^3.4.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9", + "phpcsstandards/phpcsdevtools": "^1.2.3", + "phpunit/phpunit": "^9" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/Automattic/VIP-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress VIP minimum coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/Automattic/VIP-Coding-Standards/issues", + "source": "https://github.com/Automattic/VIP-Coding-Standards", + "wiki": "https://github.com/Automattic/VIP-Coding-Standards/wiki" + }, + "time": "2026-07-27T14:33:48+00:00" + }, + { + "name": "dealerdirect/phpcodesniffer-composer-installer", + "version": "v1.2.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/composer-installer.git", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/composer-installer/zipball/963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "reference": "963f0c67bffde0eac41b56be71ac0e8ba132f0bd", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2.2", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.1.0 || ^4.0" + }, + "require-dev": { + "composer/composer": "^2.2", + "ext-json": "*", + "ext-zip": "*", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^9.0 || ^10.0.0@dev", + "yoast/phpunit-polyfills": "^1.0" + }, + "type": "composer-plugin", + "extra": { + "class": "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin" + }, + "autoload": { + "psr-4": { + "PHPCSStandards\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Franck Nijhof", + "email": "opensource@frenck.dev", + "homepage": "https://frenck.dev", + "role": "Open source developer" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/composer-installer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer Standards Composer Installer Plugin", + "keywords": [ + "PHPCodeSniffer", + "PHP_CodeSniffer", + "code quality", + "codesniffer", + "composer", + "installer", + "phpcbf", + "phpcs", + "plugin", + "qa", + "quality", + "standard", + "standards", + "style guide", + "stylecheck", + "tests" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/composer-installer/issues", + "security": "https://github.com/PHPCSStandards/composer-installer/security/policy", + "source": "https://github.com/PHPCSStandards/composer-installer" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-05-06T08:26:05+00:00" + }, + { + "name": "phpcsstandards/phpcsextra", + "version": "1.5.1", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSExtra.git", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSExtra/zipball/39467533fdb742446d68c1d10ac33d625ee0311c", + "reference": "39467533fdb742446d68c1d10ac33d625ee0311c", + "shasum": "" + }, + "require": { + "php": ">=5.4", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "phpcsstandards/phpcsdevtools": "^1.2.1", + "phpunit/phpunit": "^4.5 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSExtra/graphs/contributors" + } + ], + "description": "A collection of sniffs and standards for use with PHP_CodeSniffer.", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHPCSExtra/issues", + "security": "https://github.com/PHPCSStandards/PHPCSExtra/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSExtra" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T11:13:17+00:00" + }, + { + "name": "phpcsstandards/phpcsutils", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHPCSUtils.git", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHPCSUtils/zipball/5f35d9408c54d7b529501f3c688b6eae562aea1f", + "reference": "5f35d9408c54d7b529501f3c688b6eae562aea1f", + "shasum": "" + }, + "require": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.4.1 || ^0.5 || ^0.6.2 || ^0.7 || ^1.0", + "php": ">=5.4", + "squizlabs/php_codesniffer": "^3.13.5 || ^4.0.1" + }, + "require-dev": { + "ext-filter": "*", + "php-parallel-lint/php-console-highlighter": "^1.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcsstandards/phpcsdevcs": "^1.2.0", + "yoast/phpunit-polyfills": "^1.1.0 || ^2.0.0 || ^3.0.0" + }, + "type": "phpcodesniffer-standard", + "extra": { + "branch-alias": { + "dev-stable": "1.x-dev", + "dev-develop": "1.x-dev" + } + }, + "autoload": { + "classmap": [ + "PHPCSUtils/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "Juliette Reinders Folmer", + "homepage": "https://github.com/jrfnl", + "role": "lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHPCSUtils/graphs/contributors" + } + ], + "description": "A suite of utility functions for use with PHP_CodeSniffer", + "homepage": "https://phpcsutils.com/", + "keywords": [ + "PHP_CodeSniffer", + "phpcbf", + "phpcodesniffer-standard", + "phpcs", + "phpcs3", + "phpcs4", + "standards", + "static analysis", + "tokens", + "utility" + ], + "support": { + "docs": "https://phpcsutils.com/", + "issues": "https://github.com/PHPCSStandards/PHPCSUtils/issues", + "security": "https://github.com/PHPCSStandards/PHPCSUtils/security/policy", + "source": "https://github.com/PHPCSStandards/PHPCSUtils" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-07-27T10:28:41+00:00" + }, + { + "name": "sirbrillig/phpcs-variable-analysis", + "version": "v2.13.0", + "source": { + "type": "git", + "url": "https://github.com/sirbrillig/phpcs-variable-analysis.git", + "reference": "a15e970b8a0bf64cfa5e86d941f5e6b08855f369" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sirbrillig/phpcs-variable-analysis/zipball/a15e970b8a0bf64cfa5e86d941f5e6b08855f369", + "reference": "a15e970b8a0bf64cfa5e86d941f5e6b08855f369", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "squizlabs/php_codesniffer": "^3.5.7 || ^4.0.0" + }, + "require-dev": { + "dealerdirect/phpcodesniffer-composer-installer": "^0.7 || ^1.0", + "phpstan/phpstan": "^1.7 || ^2.0", + "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.5 || ^7.0 || ^8.0 || ^9.0 || ^10.5.32 || ^11.3.3", + "vimeo/psalm": "^0.2 || ^0.3 || ^1.1 || ^4.24 || ^5.0 || ^6.0 || ^7.0" + }, + "type": "phpcodesniffer-standard", + "autoload": { + "psr-4": { + "VariableAnalysis\\": "VariableAnalysis/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Sam Graham", + "email": "php-codesniffer-variableanalysis@illusori.co.uk" + }, + { + "name": "Payton Swick", + "email": "payton@foolord.com" + } + ], + "description": "A PHPCS sniff to detect problems with variables.", + "keywords": [ + "phpcs", + "static analysis" + ], + "support": { + "issues": "https://github.com/sirbrillig/phpcs-variable-analysis/issues", + "source": "https://github.com/sirbrillig/phpcs-variable-analysis", + "wiki": "https://github.com/sirbrillig/phpcs-variable-analysis/wiki" + }, + "time": "2025-09-30T22:22:48+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.13.6", + "source": { + "type": "git", + "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/4c378e1a528ea066890fc2397cbdd2f94eb2fc91", + "reference": "4c378e1a528ea066890fc2397cbdd2f94eb2fc91", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki" + }, + "funding": [ + { + "url": "https://github.com/PHPCSStandards", + "type": "github" + }, + { + "url": "https://github.com/jrfnl", + "type": "github" + }, + { + "url": "https://opencollective.com/php_codesniffer", + "type": "open_collective" + }, + { + "url": "https://thanks.dev/u/gh/phpcsstandards", + "type": "thanks_dev" + } + ], + "time": "2026-08-06T00:17:32+00:00" + }, + { + "name": "wp-coding-standards/wpcs", + "version": "3.4.1", + "source": { + "type": "git", + "url": "https://github.com/WordPress/WordPress-Coding-Standards.git", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WordPress/WordPress-Coding-Standards/zipball/ec2ff942335f33683a5957a85d138753876a05cf", + "reference": "ec2ff942335f33683a5957a85d138753876a05cf", + "shasum": "" + }, + "require": { + "ext-filter": "*", + "ext-libxml": "*", + "ext-tokenizer": "*", + "ext-xmlreader": "*", + "php": ">=7.2", + "phpcsstandards/phpcsextra": "^1.5.1", + "phpcsstandards/phpcsutils": "^1.2.3", + "squizlabs/php_codesniffer": "^3.13.5" + }, + "require-dev": { + "php-parallel-lint/php-console-highlighter": "^1.0.0", + "php-parallel-lint/php-parallel-lint": "^1.4.0", + "phpcompatibility/php-compatibility": "^10.0.0@dev", + "phpcsstandards/phpcsdevtools": "^1.2.0", + "phpunit/phpunit": "^8.0 || ^9.0" + }, + "suggest": { + "ext-iconv": "For improved results", + "ext-mbstring": "For improved results" + }, + "type": "phpcodesniffer-standard", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Contributors", + "homepage": "https://github.com/WordPress/WordPress-Coding-Standards/graphs/contributors" + } + ], + "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions", + "keywords": [ + "phpcs", + "standards", + "static analysis", + "wordpress" + ], + "support": { + "issues": "https://github.com/WordPress/WordPress-Coding-Standards/issues", + "source": "https://github.com/WordPress/WordPress-Coding-Standards", + "wiki": "https://github.com/WordPress/WordPress-Coding-Standards/wiki" + }, + "funding": [ + { + "url": "https://opencollective.com/php_codesniffer", + "type": "custom" + } + ], + "time": "2026-07-27T11:53:23+00:00" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": {}, + "prefer-stable": false, + "prefer-lowest": false, + "platform": {}, + "platform-dev": {}, + "plugin-api-version": "2.9.0" +} diff --git a/docs/integrations/wordpress-vip/examples/policy.json b/docs/integrations/wordpress-vip/examples/policy.json new file mode 100644 index 0000000..0c398d2 --- /dev/null +++ b/docs/integrations/wordpress-vip/examples/policy.json @@ -0,0 +1,6 @@ +{ + "environmentId": 42, + "managedGroupId": "e4ab9cac-781a-44de-89df-79dc9a937274", + "tokens": ["WebDecoy-VIP-Test/1.0"], + "protectedUserAgents": [] +} diff --git a/docs/integrations/wordpress-vip/examples/snapshot.json b/docs/integrations/wordpress-vip/examples/snapshot.json new file mode 100644 index 0000000..1aa5b37 --- /dev/null +++ b/docs/integrations/wordpress-vip/examples/snapshot.json @@ -0,0 +1,11 @@ +{ + "environmentId": 42, + "capturedAt": "2026-11-15T12:00:00.000Z", + "groups": [ + { + "id": "ad46770d-c785-4479-86a5-4d57b41f2a5d", + "notes": "Existing operator rule: synthetic example", + "rules": [{"operator": "equals", "value": "ExampleBlockedClient/1.0"}] + } + ] +} diff --git a/docs/integrations/wordpress-vip/phpcs-baseline.json b/docs/integrations/wordpress-vip/phpcs-baseline.json new file mode 100644 index 0000000..1cc1da8 --- /dev/null +++ b/docs/integrations/wordpress-vip/phpcs-baseline.json @@ -0,0 +1,2494 @@ +{ + "totals": { + "errors": 45, + "warnings": 191, + "fixable": 0 + }, + "files": { + "webdecoy.php": { + "errors": 17, + "warnings": 9, + "messages": [ + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 1270, + "column": 17 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1425, + "column": 91 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1428, + "column": 57 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1521, + "column": 54 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 1787, + "column": 9 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1789, + "column": 105 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 1832, + "column": 13 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1908, + "column": 89 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 1985, + "column": 9 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 1987, + "column": 105 + }, + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 1991, + "column": 24 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 2018, + "column": 105 + }, + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 2064, + "column": 13 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 2078, + "column": 60 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 2102, + "column": 9 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 2104, + "column": 105 + }, + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 2108, + "column": 24 + }, + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 2115, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 2197, + "column": 13 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 2199, + "column": 109 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 2818, + "column": 99 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 2962, + "column": 9 + }, + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 2992, + "column": 13 + }, + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 3035, + "column": 23 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 3328, + "column": 9 + }, + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 3346, + "column": 17 + } + ] + }, + "uninstall.php": { + "errors": 0, + "warnings": 13, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 43, + "column": 9 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 43, + "column": 9 + }, + { + "message": "Redeclaration of global variable $wpdb as global variable.", + "source": "VariableAnalysis.CodeAnalysis.VariableAnalysis.VariableRedeclaration", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 68, + "column": 8 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 71, + "column": 1 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 71, + "column": 1 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 75, + "column": 1 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 75, + "column": 1 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 100, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 100, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 123, + "column": 9 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 123, + "column": 9 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 127, + "column": 9 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 127, + "column": 9 + } + ] + }, + "admin/partials/settings-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/blocked-ips-page.php": { + "errors": 2, + "warnings": 0, + "messages": [ + { + "message": "Overriding WordPress globals is prohibited. Found assignment to $page", + "source": "WordPress.WP.GlobalVariablesOverride.Prohibited", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 48, + "column": 1 + }, + { + "message": "Overriding WordPress globals is prohibited. Found assignment to $per_page", + "source": "WordPress.WP.GlobalVariablesOverride.Prohibited", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 49, + "column": 1 + } + ] + }, + "admin/partials/detections-page.php": { + "errors": 2, + "warnings": 8, + "messages": [ + { + "message": "Overriding WordPress globals is prohibited. Found assignment to $page", + "source": "WordPress.WP.GlobalVariablesOverride.Prohibited", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 22, + "column": 1 + }, + { + "message": "Overriding WordPress globals is prohibited. Found assignment to $per_page", + "source": "WordPress.WP.GlobalVariablesOverride.Prohibited", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 23, + "column": 1 + }, + { + "message": "File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fputcsv(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv", + "severity": 6, + "fixable": false, + "type": "WARNING", + "line": 89, + "column": 5 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 93, + "column": 23 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 93, + "column": 23 + }, + { + "message": "File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fputcsv(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv", + "severity": 6, + "fixable": false, + "type": "WARNING", + "line": 96, + "column": 9 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 114, + "column": 10 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 114, + "column": 10 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 121, + "column": 15 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 121, + "column": 15 + } + ] + }, + "admin/partials/dashboard-widget.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/statistics-page.php": { + "errors": 0, + "warnings": 18, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 25, + "column": 17 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 25, + "column": 17 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 43, + "column": 24 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 43, + "column": 24 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 49, + "column": 17 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 49, + "column": 17 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 82, + "column": 12 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 82, + "column": 12 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 88, + "column": 24 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 88, + "column": 24 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 95, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 95, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 99, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 99, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 106, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 106, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 115, + "column": 29 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 115, + "column": 29 + } + ] + }, + "includes/class-webdecoy-runtime-config.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-violation-reporter.php": { + "errors": 0, + "warnings": 3, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 108, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 219, + "column": 17 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 219, + "column": 17 + } + ] + }, + "includes/class-webdecoy-blocker.php": { + "errors": 4, + "warnings": 28, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 89, + "column": 21 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 89, + "column": 21 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 96, + "column": 23 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 107, + "column": 23 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 156, + "column": 25 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 157, + "column": 51 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 157, + "column": 59 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 230, + "column": 25 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 231, + "column": 65 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 231, + "column": 73 + }, + { + "message": "This comment is 50% valid code; is this commented out code?", + "source": "Squiz.PHP.CommentedOutCode.Found", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 266, + "column": 27 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 349, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 381, + "column": 26 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 394, + "column": 24 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 442, + "column": 20 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 442, + "column": 20 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 468, + "column": 22 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 468, + "column": 22 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 483, + "column": 19 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 483, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 515, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 537, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 558, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 558, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 828, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 828, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 829, + "column": 19 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 829, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 834, + "column": 22 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 834, + "column": 22 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 837, + "column": 19 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 837, + "column": 19 + } + ] + }, + "includes/class-webdecoy-detection-sender.php": { + "errors": 1, + "warnings": 0, + "messages": [ + { + "message": "error_log() found. Debug code should not normally be used in production.", + "source": "WordPress.PHP.DevelopmentFunctions.error_log_error_log", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 102, + "column": 17 + } + ] + }, + "includes/class-webdecoy-cli.php": { + "errors": 0, + "warnings": 8, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 84, + "column": 24 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 84, + "column": 24 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 85, + "column": 25 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 85, + "column": 25 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 89, + "column": 32 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 89, + "column": 32 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 291, + "column": 20 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 291, + "column": 20 + } + ] + }, + "includes/class-webdecoy-review-ask.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-critical-moment.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-actor-feed.php": { + "errors": 1, + "warnings": 2, + "messages": [ + { + "message": "This comment is 45% valid code; is this commented out code?", + "source": "Squiz.PHP.CommentedOutCode.Found", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 156, + "column": 25 + }, + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 233, + "column": 21 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `8`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 234, + "column": 13 + } + ] + }, + "includes/class-webdecoy-ip-enrichment.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 115, + "column": 21 + } + ] + }, + "includes/class-webdecoy-detector.php": { + "errors": 1, + "warnings": 14, + "messages": [ + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 145, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 244, + "column": 9 + }, + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 250, + "column": 24 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 279, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 279, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 298, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 298, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 303, + "column": 21 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 303, + "column": 21 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 308, + "column": 19 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 308, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 313, + "column": 22 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 313, + "column": 22 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 340, + "column": 22 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 340, + "column": 22 + } + ] + }, + "includes/class-webdecoy-rate-limit-rule.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "Cache expiry time could not be determined. Please inspect that the fourth parameter passed to wp_cache_add() evaluates to 300 seconds or more. Found: \"$win * 2\"", + "source": "WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 166, + "column": 58 + } + ] + }, + "includes/class-webdecoy-robots-txt.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "Don't forget to flush the robots.txt cache by going to Settings > Reading and toggling the privacy settings.", + "source": "WordPressVIPMinimum.Hooks.RestrictedHooks.robots_txt", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 72, + "column": 9 + } + ] + }, + "includes/class-webdecoy-updater.php": { + "errors": 2, + "warnings": 2, + "messages": [ + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 58, + "column": 25 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `10`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 59, + "column": 17 + }, + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 183, + "column": 21 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `10`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 184, + "column": 13 + } + ] + }, + "includes/class-webdecoy-ai-referrals.php": { + "errors": 1, + "warnings": 1, + "messages": [ + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 262, + "column": 27 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `5`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 355, + "column": 13 + } + ] + }, + "includes/class-webdecoy-behavioral-scorer.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-honeytoken.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-activator.php": { + "errors": 2, + "warnings": 13, + "messages": [ + { + "message": "`flush_rewrite_rules` should not be used in any normal circumstances in the theme code.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 41, + "column": 9 + }, + { + "message": "`flush_rewrite_rules` should not be used in any normal circumstances in the theme code.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 56, + "column": 9 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 193, + "column": 19 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 193, + "column": 19 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 326, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 326, + "column": 13 + }, + { + "message": "Attempting a database schema change is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.SchemaChange", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 326, + "column": 26 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 352, + "column": 5 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 352, + "column": 5 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 358, + "column": 5 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 358, + "column": 5 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 368, + "column": 5 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 368, + "column": 5 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 388, + "column": 5 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 388, + "column": 5 + } + ] + }, + "includes/class-webdecoy-cloud-policy.php": { + "errors": 1, + "warnings": 1, + "messages": [ + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 72, + "column": 21 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `5`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 73, + "column": 13 + } + ] + }, + "includes/class-webdecoy-wp-traps.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-decoy-response.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-actor-intel.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-cloud-connect.php": { + "errors": 2, + "warnings": 3, + "messages": [ + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 248, + "column": 18 + }, + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 249, + "column": 18 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `10`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 294, + "column": 13 + }, + { + "message": "wp_remote_get() is highly discouraged. Please use vip_safe_wp_remote_get() instead which is designed to more gracefully handle failure than wp_remote_get() does.", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 355, + "column": 21 + }, + { + "message": "Detected high remote request timeout. `timeout` is set to `5`.", + "source": "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 356, + "column": 13 + } + ] + }, + "includes/class-webdecoy-pow.php": { + "errors": 1, + "warnings": 0, + "messages": [ + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 149, + "column": 95 + } + ] + }, + "includes/class-webdecoy-rate-limiter.php": { + "errors": 0, + "warnings": 28, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 91, + "column": 21 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 91, + "column": 21 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 99, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 99, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 102, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 102, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 103, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 134, + "column": 21 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 134, + "column": 21 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 143, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 143, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 151, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 151, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 152, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 174, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 174, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 208, + "column": 25 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 208, + "column": 25 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 236, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 236, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 251, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 251, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 344, + "column": 23 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 344, + "column": 23 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 349, + "column": 27 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 349, + "column": 27 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 354, + "column": 21 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 354, + "column": 21 + } + ] + }, + "includes/class-webdecoy-request-counts.php": { + "errors": 4, + "warnings": 8, + "messages": [ + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 28, + "column": 91 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 101, + "column": 13 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 101, + "column": 13 + }, + { + "message": "Use placeholders and $wpdb->prepare(); found interpolated variable {$table} at \"INSERT INTO {$table} (bucket, outcome, hits) VALUES (%s, %s, 1) ON DUPLICATE KEY UPDATE hits = hits + 1\"", + "source": "WordPress.DB.PreparedSQL.InterpolatedNotPrepared", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 102, + "column": 17 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 166, + "column": 17 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 166, + "column": 17 + }, + { + "message": "Use placeholders and $wpdb->prepare(); found interpolated variable {$table} at \"SELECT outcome, SUM(hits) AS hits FROM {$table} WHERE bucket >= %s AND bucket < %s GROUP BY outcome\"", + "source": "WordPress.DB.PreparedSQL.InterpolatedNotPrepared", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 167, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 171, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 171, + "column": 18 + }, + { + "message": "Use placeholders and $wpdb->prepare(); found interpolated variable {$detections} at \"SELECT COUNT(*) FROM {$detections} WHERE created_at >= %s AND created_at < %s\"", + "source": "WordPress.DB.PreparedSQL.InterpolatedNotPrepared", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 172, + "column": 13 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 190, + "column": 9 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 190, + "column": 9 + } + ] + }, + "includes/class-webdecoy-woocommerce.php": { + "errors": 1, + "warnings": 19, + "messages": [ + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 238, + "column": 9 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 296, + "column": 9 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 296, + "column": 9 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 375, + "column": 20 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 375, + "column": 20 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 384, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 384, + "column": 16 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 433, + "column": 9 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "severity": 6, + "fixable": false, + "type": "ERROR", + "line": 435, + "column": 105 + }, + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 492, + "column": 23 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 582, + "column": 18 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 582, + "column": 18 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 587, + "column": 22 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 587, + "column": 22 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 592, + "column": 23 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 592, + "column": 23 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 597, + "column": 20 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 597, + "column": 20 + }, + { + "message": "Use of a direct database call is discouraged.", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 628, + "column": 16 + }, + { + "message": "Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 628, + "column": 16 + } + ] + }, + "includes/class-webdecoy-crawler-visits.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/DetectionResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/AgentRegistry.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/LlmReferral.php": { + "errors": 0, + "warnings": 3, + "messages": [ + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 48, + "column": 21 + }, + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 54, + "column": 18 + }, + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 104, + "column": 21 + } + ] + }, + "sdk/src/Detection.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/hit-explanations.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/agents.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/llm-platforms.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleEngine.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/TripwireRule.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleInterface.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleContext.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/FilterRule.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleEngineResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Parser.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "This comment is 40% valid code; is this commented out code?", + "source": "Squiz.PHP.CommentedOutCode.Found", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 186, + "column": 13 + } + ] + }, + "sdk/src/Rules/Filter/FilterSyntaxException.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Tokenizer.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Evaluator.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/ViolationEvent.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/HitExplanation.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/RouteResolution.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/BotDetector.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "parse_url() is discouraged because of inconsistency in the output across PHP versions; use wp_parse_url() instead.", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 589, + "column": 27 + } + ] + }, + "sdk/src/SignalCollector.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "`strip_tags()` does not strip CSS and JS in between the script and style tags. Use `wp_strip_all_tags()` to strip all tags.", + "source": "WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 68, + "column": 94 + } + ] + }, + "sdk/src/Exception/WebDecoyException.php": { + "errors": 0, + "warnings": 1, + "messages": [ + { + "message": "json_encode() is discouraged. Use wp_json_encode() instead.", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 224, + "column": 38 + } + ] + }, + "sdk/src/GoodBotList.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Client.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "templates/block-page.php": { + "errors": 3, + "warnings": 3, + "messages": [ + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 68, + "column": 87 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 68, + "column": 95 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 83, + "column": 118 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 83, + "column": 126 + }, + { + "message": "Header \"REMOTE_ADDR\" is user-controlled and should be properly validated before use.", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "severity": 5, + "fixable": false, + "type": "ERROR", + "line": 91, + "column": 97 + }, + { + "message": "Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "severity": 5, + "fixable": false, + "type": "WARNING", + "line": 91, + "column": 105 + } + ] + }, + "templates/challenge-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + }, + "assessment": { + "commit": "e8f8041072cb9975436012d59a2f0a1454b3cd06", + "standard": "WordPress-VIP-Go", + "vipwpcs": "3.1.0", + "php": "8.5.10", + "scope": "webdecoy.php uninstall.php admin includes public sdk/src templates; PHP files only; tests/dev/vendor excluded; self-hosted updater included even though gated at runtime", + "top_sources": { + "WordPress.DB.DirectDatabaseQuery.DirectQuery": 88, + "WordPress.DB.DirectDatabaseQuery.NoCaching": 69, + "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__": 12, + "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders": 7, + "WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout": 7, + "WordPress.WP.AlternativeFunctions.parse_url_parse_url": 7, + "WordPress.PHP.DevelopmentFunctions.error_log_error_log": 6, + "WordPress.WP.AlternativeFunctions.json_encode_json_encode": 6, + "WordPressVIPMinimum.Functions.RestrictedFunctions.wp_remote_get_wp_remote_get": 6, + "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__": 5, + "WordPress.WP.GlobalVariablesOverride.Prohibited": 4, + "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE": 3 + }, + "caveat": "Static scanner findings need contextual triage. Not an exploitation finding, performance benchmark or VIP certification." + } +} diff --git a/docs/integrations/wordpress-vip/phpcs-remediated.json b/docs/integrations/wordpress-vip/phpcs-remediated.json new file mode 100644 index 0000000..454db90 --- /dev/null +++ b/docs/integrations/wordpress-vip/phpcs-remediated.json @@ -0,0 +1,345 @@ +{ + "totals": { + "errors": 0, + "warnings": 0, + "fixable": 0 + }, + "files": { + "webdecoy.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "uninstall.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/settings-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/blocked-ips-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/detections-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/dashboard-widget.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "admin/partials/statistics-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-runtime-config.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-violation-reporter.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-blocker.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-diagnostics.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-detection-sender.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-cli.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-http.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-review-ask.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-critical-moment.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-actor-feed.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-ip-enrichment.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-detector.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-rate-limit-rule.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-robots-txt.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-updater.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-ai-referrals.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-behavioral-scorer.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-honeytoken.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-activator.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-cloud-policy.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-wp-traps.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-decoy-response.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-actor-intel.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-cloud-connect.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-pow.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-rate-limiter.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-request-counts.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-woocommerce.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "includes/class-webdecoy-crawler-visits.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/DetectionResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/AgentRegistry.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/LlmReferral.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Detection.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/hit-explanations.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/agents.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/registry/llm-platforms.generated.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleEngine.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/TripwireRule.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleInterface.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleContext.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/FilterRule.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/RuleEngineResult.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Parser.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/FilterSyntaxException.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Tokenizer.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/Filter/Evaluator.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Rules/ViolationEvent.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/HitExplanation.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/RouteResolution.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/BotDetector.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/SignalCollector.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Exception/WebDecoyException.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/GoodBotList.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "sdk/src/Client.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "templates/block-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + }, + "templates/challenge-page.php": { + "errors": 0, + "warnings": 0, + "messages": [] + } + }, + "assessment": { + "date": "2026-11-15", + "standard": "WordPress-VIP-Go", + "vipcs": "3.1.0", + "php": "8.5.10", + "scope": [ + "webdecoy.php", + "uninstall.php", + "admin", + "includes", + "public", + "sdk/src", + "templates" + ], + "note": "Includes line-specific reviewed exceptions. Static analysis only; not VIP approval." + } +} diff --git a/docs/integrations/wordpress-vip/plan.mjs b/docs/integrations/wordpress-vip/plan.mjs new file mode 100644 index 0000000..cb3edcc --- /dev/null +++ b/docs/integrations/wordpress-vip/plan.mjs @@ -0,0 +1,99 @@ +#!/usr/bin/env node +// Offline prototype: no network access, credentials, scheduler, or apply command. +import {createHash} from 'node:crypto'; +import {readFileSync} from 'node:fs'; +import {pathToFileURL} from 'node:url'; +import {parseArgs} from 'node:util'; +const notes = 'Managed by WebDecoy'; +const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i; +const protectedUAs = [ + 'Mozilla/5.0 AppleWebKit/537.36 Chrome/130.0 Safari/537.36', + 'Mozilla/5.0 AppleWebKit/605.1.15 Version/18.0 Mobile/15E148 Safari/604.1', + 'Mozilla/5.0 Firefox/132.0', + "WPVIP Let's Encrypt Certificates (+https://docs.wpvip.com/vip-user-agents)", + 'WordPress.com; https://acme.wordpress.com', + 'WordPress.com; https://clitools.wordpress.com', + "Mozilla/5.0 (compatible; Let's Encrypt validation server; +https://www.letsencrypt.org)", + 'WPVIP Media (+https://docs.wpvip.com/vip-user-agents)', + 'VIP Webhooks (+https://docs.wpvip.com/vip-user-agents)', + 'VIP Webhooks (+https://vip.wordpress.com)', + 'Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)', + 'Jetpack by WordPress.com', +]; +function requireValue(ok, message) { if (!ok) throw new Error(message); } +function keys(value, allowed, required) { + requireValue(value && typeof value === 'object' && !Array.isArray(value), 'Expected an object'); + requireValue(Object.keys(value).every(k => allowed.includes(k)), 'Unsupported input field; review schema before planning'); + requireValue(required.every(k => Object.hasOwn(value, k)), 'Missing required input field'); +} +export function fingerprint(groups) { + return createHash('sha256').update(JSON.stringify(groups)).digest('hex'); +} +const mutation = 'mutation WebDecoyVipRestrictions($input: EdgeConfigUpdateUserAgentAccessRestrictionsInput) { updateUserAgentAccessRestrictions(input: $input) { groups { id notes } } }'; +export function buildPlan(snapshot, policy, {now = Date.now()} = {}) { + keys(snapshot, ['environmentId', 'capturedAt', 'groups'], ['environmentId', 'capturedAt', 'groups']); + keys(policy, ['environmentId', 'managedGroupId', 'tokens', 'protectedUserAgents'], ['environmentId', 'managedGroupId', 'tokens', 'protectedUserAgents']); + requireValue(Number.isInteger(snapshot.environmentId) && snapshot.environmentId > 0 && snapshot.environmentId <= 2147483647, 'Invalid VIP environment ID'); + requireValue(policy.environmentId === snapshot.environmentId, 'Environment mismatch'); + requireValue(typeof snapshot.capturedAt === 'string' && /T.*Z$/.test(snapshot.capturedAt), 'capturedAt must be UTC'); + const age = now - Date.parse(snapshot.capturedAt); + requireValue(Number.isFinite(age) && age >= -30000 && age <= 15 * 60 * 1000, 'Snapshot is stale or future-dated; recapture the full configuration'); + requireValue(typeof policy.managedGroupId === 'string' && uuid.test(policy.managedGroupId), 'A stable managedGroupId UUID is required'); + requireValue(Array.isArray(snapshot.groups), 'Full groups array is required; missing data is not an empty list'); + const ids = new Set(); + const before = snapshot.groups.map(g => { + keys(g, ['id', 'notes', 'rules', 'createdAt', 'updatedAt'], ['id', 'notes', 'rules']); + requireValue(typeof g.id === 'string' && uuid.test(g.id) && !ids.has(g.id.toLowerCase()), 'Invalid or duplicate existing group ID'); + ids.add(g.id.toLowerCase()); + requireValue(typeof g.notes === 'string' && Array.isArray(g.rules) && g.rules.length > 0, 'Invalid existing group'); + requireValue(!(g.notes === notes && g.id.toLowerCase() !== policy.managedGroupId.toLowerCase()), 'Managed notes belong to another group; resolve ownership explicitly'); + requireValue(!(g.id.toLowerCase() === policy.managedGroupId.toLowerCase() && g.notes !== notes), 'Refusing to take over an unrelated group'); + const rules = g.rules.map(r => { + keys(r, ['operator', 'value'], ['operator', 'value']); + requireValue(['contains', 'equals'].includes(r.operator) && typeof r.value === 'string' && r.value.trim().length > 0, 'Invalid existing rule'); + return {operator:r.operator, value:r.value}; + }); + return {id:g.id, notes:g.notes, rules}; + }); + requireValue(Array.isArray(policy.protectedUserAgents) && policy.protectedUserAgents.every(s => typeof s === 'string' && s.length > 0), 'protectedUserAgents must be an explicit array'); + requireValue(Array.isArray(policy.tokens) && policy.tokens.length > 0, 'Empty token policy refused; removals need an explicit operator review'); + const tokens = [...new Set(policy.tokens.map(t => { + requireValue(typeof t === 'string' && /^[a-z][a-z0-9._/-]{3,127}$/i.test(t), 'Use specific UA tokens (4–128 ASCII characters), not globs or expressions'); + const token = t.toLowerCase(); + requireValue(![...protectedUAs, ...policy.protectedUserAgents].some(ua => ua.toLowerCase().includes(token)), 'Token would match a protected browser or VIP service'); + return token; + }))].sort(); + const managed = {id:policy.managedGroupId, notes, rules:tokens.map(value => ({operator:'contains', value}))}; + const existingIndex = before.findIndex(g => g.id.toLowerCase() === policy.managedGroupId.toLowerCase()); + const after = structuredClone(before); + if (existingIndex < 0) after.push(managed); else after[existingIndex] = managed; + requireValue(after.reduce((n,g) => n + g.rules.length, 0) <= 25, 'Combined configuration exceeds the default VIP 25-rule limit'); + const request = groups => ({query:mutation, variables:{input:{environmentId:snapshot.environmentId, groups}}}); + return { + mode:'offline-preview', liveValidated:false, environmentId:snapshot.environmentId, + capturedAt:snapshot.capturedAt, baselineSha256:fingerprint(before), + changed:JSON.stringify(before) !== JSON.stringify(after), + ruleCount:after.reduce((n,g) => n + g.rules.length, 0), + before, after, proposedRequest:request(after), rollbackRequest:request(before), + warnings:[ + 'UA matching is a declared-name policy, not verified identity or behavioral detection.', + 'Rules apply globally at the VIP edge, including cached pages, media and logged-in requests.', + 'Read and compare the complete live configuration immediately before any manual write; this offline hash does not prevent races.', + 'Rollback is a full-list replacement too. Reconcile intervening changes before restoring.', + 'Browser/VIP sample protection is incomplete. Check the site’s actual HTTP logs and service UAs in staging.', + 'No crawler analytics ingestion or VIP integration approval is established by this plan.', + ], + }; +} +if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { + try { + const {values} = parseArgs({options:{snapshot:{type:'string'}, policy:{type:'string'}}, strict:true}); + requireValue(values.snapshot && values.policy, 'Usage: node plan.mjs --snapshot snapshot.json --policy policy.json'); + const plan = buildPlan(JSON.parse(readFileSync(values.snapshot,'utf8')), JSON.parse(readFileSync(values.policy,'utf8'))); + process.stdout.write(JSON.stringify(plan,null,2)+'\n'); + } catch (error) { + // Do not echo config contents or raw exception details from file/JSON parsing. + process.stderr.write('Preview failed: '+(error instanceof SyntaxError ? 'Invalid JSON or arguments' : error.code ? 'Unable to read input file' : error.message)+'\n'); + process.exitCode = 1; + } +} diff --git a/docs/integrations/wordpress-vip/plan.test.mjs b/docs/integrations/wordpress-vip/plan.test.mjs new file mode 100644 index 0000000..43f6e96 --- /dev/null +++ b/docs/integrations/wordpress-vip/plan.test.mjs @@ -0,0 +1,49 @@ +import {test} from 'node:test'; +import assert from 'node:assert/strict'; +import {buildPlan} from './plan.mjs'; +import {readFileSync} from 'node:fs'; +import {spawnSync} from 'node:child_process'; +const s=()=>JSON.parse(readFileSync(new URL('./examples/snapshot.json',import.meta.url))); +const p=()=>JSON.parse(readFileSync(new URL('./examples/policy.json',import.meta.url))); +const now=Date.parse('2026-11-15T12:01:00Z'); +const plan=(a=s(),b=p())=>buildPlan(a,b,{now}); +test('preserves unrelated groups, produces reversible payload and never mutates input',()=>{ + const a=s(),b=p(),original=JSON.stringify(a);const out=plan(a,b); + assert.deepEqual(out.after[0],a.groups[0]);assert.equal(JSON.stringify(a),original); + assert.deepEqual(out.rollbackRequest.variables.input.groups,out.before); + assert.deepEqual(out.proposedRequest.variables.input.groups,out.after); + assert.equal(out.mode,'offline-preview');assert.equal(out.liveValidated,false); +}); +test('updates only its stable ID and is idempotent',()=>{ + const a=s();a.groups=plan().after; + const out=plan(a);assert.equal(out.changed,false);assert.equal(out.after.length,2); +}); +test('normalizes case and duplicate tokens without adding duplicate rules',()=>{ + const b=p();b.tokens=['ExampleCrawler','examplecrawler'];assert.equal(plan(s(),b).after.at(-1).rules.length,1); +}); +for(const [name,change] of [ + ['missing groups',a=>delete a.groups],['stale snapshot',a=>a.capturedAt='2026-11-14T12:00:00Z'], + ['future snapshot',a=>a.capturedAt='2026-11-16T12:00:00Z'],['invalid environment',a=>a.environmentId='42'], + ['unknown group field',a=>a.groups[0].action='allow'],['unknown rule operator',a=>a.groups[0].rules[0].operator='regex'], + ['duplicate group ID',a=>a.groups.push(a.groups[0])],['missing existing rules',a=>delete a.groups[0].rules], +]) test('rejects '+name,()=>{const a=s();change(a);assert.throws(()=>plan(a));}); +for(const token of ['Mozilla','Safari','Chrome','Firefox','WPVIP','WordPress.com','Jetpack','UptimeRobot','VIP','*','bot','a\nbot']) + test('rejects broad or protected token '+JSON.stringify(token),()=>{const b=p();b.tokens=[token];assert.throws(()=>plan(s(),b));}); +test('checks the total limit across unrelated and managed groups',()=>{ + const a=s();a.groups[0].rules=Array.from({length:25},(_,i)=>({operator:'equals',value:'Existing'+i}));assert.throws(()=>plan(a),/25-rule/); +}); +test('accepts exactly 25 total rules',()=>{ + const a=s();a.groups[0].rules=Array.from({length:24},(_,i)=>({operator:'equals',value:'Existing'+i}));assert.equal(plan(a).ruleCount,25); +}); +test('refuses ownership collisions, empty policy and environment mismatch',()=>{ + const a=s(),b=p();a.groups[0].notes='Managed by WebDecoy';assert.throws(()=>plan(a,b),/ownership/); + a.groups[0].id=b.managedGroupId;a.groups[0].notes='Not ours';assert.throws(()=>plan(a,b),/take over/); + b.tokens=[];assert.throws(()=>plan(s(),b));b.environmentId=99;assert.throws(()=>plan(s(),b)); +}); +test('protects site-specific service agents',()=>{ + const b=p();b.tokens=['MyMonitor'];b.protectedUserAgents=['MyMonitor/1.0'];assert.throws(()=>plan(s(),b),/protected/); +}); +test('CLI refuses apply flag; no accidental mutation interface',()=>{ + const r=spawnSync(process.execPath,[new URL('./plan.mjs',import.meta.url).pathname,'--apply'],{encoding:'utf8'}); + assert.equal(r.status,1);assert.equal(r.stdout,''); +}); diff --git a/docs/integrations/wordpress-vip/readiness.md b/docs/integrations/wordpress-vip/readiness.md new file mode 100644 index 0000000..1974256 --- /dev/null +++ b/docs/integrations/wordpress-vip/readiness.md @@ -0,0 +1,43 @@ +# WordPress VIP readiness assessment + +Assessed November15,2026 against WordPress plugin2.13.0, commit `e8f8041072cb9975436012d59a2f0a1454b3cd06`. + +**Decision: ready for a technical partnership conversation and an offline connector demonstration; not ready to claim VIP compatibility or ship a production VIP integration.** No VIP environment, authenticated API call, customer pilot, load benchmark or VIP certification was available in this assessment. + +## Evidence and gaps + +| Area | Evidence | Readiness / next validation | +|---|---|---| +| Integration prototype | Offline Node planner and28tests in this directory. Input fields follow the documented VIP mutation. | Locally tested only. Need real complete restriction export and nonproduction API round-trip, propagation, response codes and rollback test. | +| Edge cache visibility | `includes/class-webdecoy-crawler-visits.php` explicitly excludes full-page cache hits; request logic executes in PHP. | Fundamental coverage gap for publishers. Pair plugin observations with a separately validated edge/log source. Do not claim PHP counts are complete site traffic. | +| VIP rules scope | Official API can control UA restrictions at VIP edge. Global matching covers cached content, assets and authenticated requests. | Declared-name blocking only; it does not establish bot identity. Publisher must choose policy and validate service/browser exclusions. | +| Static code standards | VIPCS3.1.0 / PHP8.5.10 / WordPress-VIP-Go: **45errors,191warnings** in the original baseline. Remediation scan: **0errors,0warnings**, with documented line-specific exceptions. Reports in `phpcs-baseline.json` and `phpcs-remediated.json`. | See [remediation and exceptions](remediation.md); runtime VIP evidence is still required. This is not a vulnerability count. | +| Git deployment | Plugin has source repository, versioned builds, no runtime Composer dependencies. Self-updater is gated by `WEBDECOY_SELF_HOSTED`. | VIP deploys plugins through site git repositories. Use a reviewed artifact without updater; do not enable self-hosted updates or instruct dashboard installation. | +| Data storage and scale | Custom detection, request, crawler and referral tables in activator; hourly/day aggregate counters; prepared queries. | Need realistic high-volume write/query measurements, retention/cleanup timing, multisite and object-cache evaluation on VIP. | +| Request-dependent responses | Detector/blocker uses UA, cookies, clientIP; challenge/block response and cookie paths exist. | Need cache correctness tests for anonymous/logged-in requests; ensure personalized challenges/decoys cannot leak through shared cache. No cache bypass should be enabled merely to make counting complete. | +| Proxy/client IP | `sdk/src/SignalCollector.php` trusts forwarding headers only from configured trusted hops; blocker tracks unresolved proxy state. | Validate VIP's actual server/header contract. Do not automatically trust arbitrary X-Forwarded-For or derive production allowlists from this report. | +| Outbound requests | Optional cloud/reporting/feeds use WP HTTP API, timeouts, transient caches, some queued reporting. | Review request-path latency, cron reliability, outage behavior, rate limits and privacy before enabling cloud features. | +| Data handling | Local aggregates coexist with detections and optional cloud reports. | Document each enabled module's IP/request/landing-path flow, retention and deletion; confirm DPA/support requirements with VIP. Full privacy audit not performed. | + +## Original static-scan triage (before remediation) + +1. **Cache correctness and coverage:**12UA,5REMOTE_ADDR and3COOKIE restricted-variable findings plus cookie-setting and header-validation findings. Several are expected for bot software, but need a VIP-specific architecture and runtime evidence. Deleting checks solely to silence the scanner would undermine detection. +2. **Request latency:**7high-timeout findings, including cron feed8seconds and cloud/referral operations5–10seconds.2findings come from the self-hosted updater, inactive by default and removable from a VIP artifact. Distinguish cron/admin operations from public request paths before changing deadlines. +3. **Database work:**88direct-query and69uncached-query findings across reads/writes/maintenance. Aggregate counter writes cannot simply be cached away. Measure contention, cache suitable reads, and document lifecycle operations separately.3table-interpolation errors in request counters need manual review; table names come from plugin helpers, so these scanner errors alone do not establish injection. +4. **Smaller review items:**6error-log findings,4WordPress-global assignment findings in admin partials,2rewrite flush findings in activation/deactivation. Verify actual scope; admin includes may run within method scope, and activation hooks differ from per-request theme execution. Do not blanket-suppress standards. + +The initial assessment changed no runtime code. The follow-up remediation now includes runtime fixes and reviewed line-level exceptions; see [remediation](remediation.md). The scan includes the self-hosted updater and PHP only, not a complete security audit or JavaScript scan. Tool versions and exact scanned directories are embedded in the baseline. Re-run after changing the release artifact or dependency versions. + +## Nonproduction pilot acceptance criteria + +- VIP engineer/operator confirms installation and API requirements; correct environment and permission scopes established. +- Preserve existing restrictions through create/update/no-op and a rollback reconciled with intervening changes. +- Verify normal browsers, VIP monitoring, certificates, webhooks, media imports, REST and admin access after rule propagation. +- Test cached/uncached and anonymous/logged-in requests, checkout if applicable, worker/proxy failures, timeout behavior and retention/cron jobs. +- Measure latency/error rate and database cost at an agreed realistic load with/without enabled features; include measurements rather than promises in partnership material. +- Validate coverage from each data source: PHP observations, browser observations, edge logs and blocked requests remain distinct. No edge-log ingestion currently supplied by this prototype. +- Obtain VIP technical feedback before using partnership/certification badges or claiming Integration Center availability. + +## Sources + +See official references in [integration README](README.md). VIP does not maintain a pre-approved third-party plugin list; partner approval, site-specific deployment review and our own tests are separate evidence. diff --git a/docs/integrations/wordpress-vip/remediation.md b/docs/integrations/wordpress-vip/remediation.md new file mode 100644 index 0000000..f826cdd --- /dev/null +++ b/docs/integrations/wordpress-vip/remediation.md @@ -0,0 +1,59 @@ +# VIP standards remediation + +November 15, 2026. Follow-up to the original plugin 2.13.0 assessment. This changes runtime code; it does **not** establish VIP approval, production compatibility, or complete edge-traffic coverage. + +## Runtime fixes + +- The shared HTTP adapter uses VIP's GET circuit breaker, with a `WP_Error` fallback preserving caller refusal/backoff behavior. It preserves authorization headers and response status/body. VIP GET/POST waits are bounded to 0.1–3 seconds; ordinary WordPress retains existing caller budgets. POSTs are never replayed or response-cached here. Existing caller-specific caches remain separate. +- The Statistics screen and detector/blocker/checkout summary methods cache presentation aggregates for 60 seconds in a site-scoped object-cache group. Protection, checkout velocity, audit lists, counters, and setup receipts stay live. The Statistics screen explains the delay. This is not a measured load benchmark. +- The block page validates IPs, receives the trusted-proxy-aware visitor address used for enforcement, and sends no-cache headers. Proxy guards validate direct-peer addresses. No forwarding-header trust was added. +- Successful challenge clearance and its AJAX verification response explicitly send no-cache headers. The HttpOnly clearance cookie specifies SameSite=Lax alongside existing expiry/path/HTTPS behavior. +- Debug logs require both `WP_DEBUG` and `WP_DEBUG_LOG` and accept only fixed operational event codes. Raw exceptions, credentials, and request payloads are not logged by this helper. +- WordPress adapters use `wp_json_encode`/`wp_parse_url`. The framework-independent SDK retains its native operations with specific explanations rather than gaining a WordPress dependency. +- Admin pagination variables no longer reuse WordPress global names. Uninstall declares `$wpdb` once and prepares escaped literal transient prefixes instead of broad wildcard matches. +- Activation/deactivation request soft rewrite flushes without `.htaccess` writes. +- Robots category changes queue a targeted VIP `/robots.txt` purge, preferring the current API with a guarded legacy fallback. Purges are asynchronous. Registry/constant changes during deployment still require operator invalidation. Physical robots.txt files remain outside the virtual filter. + +## What zero findings means + +The original baseline was **45 errors and 191 warnings**. The final scan reports **0 errors and 0 warnings, including reviewed exceptions**. This is **not 236 bugs fixed**. + +Most findings concern generic direct-query/cache checks on plugin-owned tables. Event writes, queue acknowledgements, schema lifecycle, retention, and live security decisions cannot be replaced with cached results. Suitable presentation aggregates now have an actual cache. Fresh audit/export/status reads remain deliberate. [Reviewed exceptions](reviewed-exceptions.json) records file/function/sniff/rationale. Additional inline explanations cover bounded transport, non-VIP fallback, debug logging, rewrite lifecycle, clearance cookie, and robots purge. + +All new exceptions are line-specific and name individual rules. No new file-wide suppressions, excluded runtime directories, lowered severity thresholds, or successful-exit overrides were added. Existing project exceptions are outside this focused review. + +UA/cookie/IP signals remain **PHP request observations**. Cache hits that bypass PHP cannot be detected or blocked by this plugin. Removing these signals would weaken detection. Passing static analysis does not validate cache isolation at VIP's edge. + +## Reproduce + +Scanner dependencies are isolated from the PHP 7.4 plugin runtime. The lock pins VIPCS 3.1.0 and transitive tools. + +```sh +composer --working-dir=docs/integrations/wordpress-vip install + +docs/integrations/wordpress-vip/vendor/bin/phpcs \ + --standard=WordPress-VIP-Go --extensions=php \ + webdecoy.php uninstall.php admin includes public sdk/src templates + +php tests/run.php +node --test docs/integrations/wordpress-vip/plan.test.mjs +./build.sh 2.13.0 --org +``` + +The new CI job fails on findings (no `|| true`); branch-protection settings determine whether the job is mandatory for merge. The original report remains in `phpcs-baseline.json`; `phpcs-remediated.json` contains the final sanitized report. + +Local verification: **269 PHP tests passed**, **28 connector tests passed**, **119 PHP source/test files passed syntax checks**. Added tests cover transport response/auth/error preservation, VIP timeout bounds, site-isolated analytics cache reuse/expiry, opt-in diagnostics, invalid direct-peer input, and modern/legacy targeted robots purges. The WordPress.org ZIP builds and passes the same VIP scan. This is a test build of 2.13.0, not a published release. + +## Remaining pilot requirements + +A real VIP environment must validate anonymous/authenticated and cached/uncached requests, challenges/decoys/cookies, proxy configuration, realistic database contention/retention/cron/latency, service outages and timeouts, and robots purge propagation. Include the case where a one-time connection exchange completes server-side after a client timeout. Validate deploy-time robots invalidation separately. + +The offline edge-policy planner also still needs authenticated nonproduction API/rollback testing. No VIP API call, production deployment, certification, or load benchmark was performed here. Scoped database exceptions are not VIP performance approval. + +## Primary references + +- [VIP remote data guidance](https://docs.wpvip.com/databases/optimize-queries/retrieving-remote-data/) +- [VIP helper implementation and signature](https://github.com/Automattic/vip-go-mu-plugins-built/blob/master/vip-helpers/vip-utils.php) +- [VIP targeted purge API](https://docs.wpvip.com/caching/page-cache/purging/programmatically/) +- [VIP robots.txt behavior](https://docs.wpvip.com/security-controls/robots-txt/) +- [VIP cache-control headers](https://docs.wpvip.com/caching/page-cache/customize-behavior/cache-control-headers/) diff --git a/docs/integrations/wordpress-vip/reviewed-exceptions.json b/docs/integrations/wordpress-vip/reviewed-exceptions.json new file mode 100644 index 0000000..1e2adaf --- /dev/null +++ b/docs/integrations/wordpress-vip/reviewed-exceptions.json @@ -0,0 +1,1061 @@ +{ + "description": "Line-scoped review decisions, not VIP approval or runtime evidence. See remediation.md for operational limitations.", + "findings": [ + { + "file": "webdecoy.php", + "function": "record_synthetic_tripwire", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "record_synthetic_tripwire", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "reason": "Sanitized clearance token is reported with this trap event; it is not rendered into cached content." + }, + { + "file": "webdecoy.php", + "function": "build_rule_context", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "log_decoy_served", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "webdecoy.php", + "function": "log_decoy_served", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "log_rule_violations", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "webdecoy.php", + "function": "is_challenge_verified", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "reason": "HMAC-matched clearance affects only this request; successful verification calls nocache_headers before continuing." + }, + { + "file": "webdecoy.php", + "function": "log_detection", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "webdecoy.php", + "function": "log_detection", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "submit_detection", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "is_test_trigger_request", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Reserved setup probe produces an explicit no-cache 403 receipt; does not personalize shared page content." + }, + { + "file": "webdecoy.php", + "function": "handle_test_trigger", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "webdecoy.php", + "function": "handle_test_trigger", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "check_canary_login", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "webdecoy.php", + "function": "check_canary_login", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "inject_js_verification_token", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "webdecoy.php", + "function": "log_client_detection", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "uninstall.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv", + "reason": "Writes exclusively to the already-open php://output CSV download stream; no local filesystem path is used." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv", + "reason": "Writes exclusively to the already-open php://output CSV download stream; no local filesystem path is used." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/detections-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Capability-gated filtered audit list/export needs current records; paginated view and export do not feed enforcement." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "admin/partials/statistics-page.php", + "function": "file scope", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Custom-table admin aggregates are cached together in webdecoy_analytics for 60 seconds above/below this query." + }, + { + "file": "includes/class-webdecoy-violation-reporter.php", + "function": "report", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-violation-reporter.php", + "function": "drain_locked", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-violation-reporter.php", + "function": "drain_locked", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "block", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Read-before-upsert needs current plugin block row; successful mutation invalidates the IP decision cache." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "block", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Read-before-upsert needs current plugin block row; successful mutation invalidates the IP decision cache." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "block", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "block", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "guard", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "reason": "FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "guard", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "reason": "Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "unresolved_forwarding_header", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "reason": "FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "unresolved_forwarding_header", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "reason": "Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "unblock", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "is_blocked", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned block lookup on object-cache miss; result is cached and block mutations invalidate the IP cache." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "is_blocked", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned block lookup on object-cache miss; result is cached and block mutations invalidate the IP cache." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_blocked_ips", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Filtered, paginated operator block list needs current entries after block/unblock actions." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_blocked_ips", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Filtered, paginated operator block list needs current entries after block/unblock actions." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_blocked_count", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Operator list pagination uses current plugin block counts, including time-dependent expirations." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_blocked_count", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Operator list pagination uses current plugin block counts, including time-dependent expirations." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_block_info", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live block reason/expiration lookup for the no-cache security response; do not serve stale block details." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_block_info", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live block reason/expiration lookup for the no-cache security response; do not serve stale block details." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "extend_block", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "clear_all", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit operator mutation clears plugin blocks; no cached result can execute deletion." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "cleanup_expired", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Scheduled deletion of expired plugin blocks; no cached result can execute retention." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "cleanup_expired", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Scheduled deletion of expired plugin blocks; no cached result can execute retention." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-blocker.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "status", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "logs", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-cli.php", + "function": "logs", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "has_wordpress_cookies", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE", + "reason": "Cookie presence is only a request-local detection signal, never authentication; cached page hits remain outside PHP coverage." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "log_detection", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_recent_detections", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Current operator audit rows are deliberately uncached so a setup test appears immediately; row limit is prepared." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_recent_detections", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Current operator audit rows are deliberately uncached so a setup test appears immediately; row limit is prepared." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_unique_ips", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Current operator distinct-IP total from the plugin detection table; not used on public enforcement paths." + }, + { + "file": "includes/class-webdecoy-detector.php", + "function": "get_unique_ips", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Current operator distinct-IP total from the plugin detection table; not used on public enforcement paths." + }, + { + "file": "includes/class-webdecoy-rate-limit-rule.php", + "function": "checkSliding", + "source": "WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined", + "reason": "Security sliding-window bucket TTL is intentionally twice the configured window; raising it to 300 seconds changes counter lifetime." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "create_tables", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "create_tables", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.SchemaChange", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-activator.php", + "function": "uninstall", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state." + }, + { + "file": "includes/class-webdecoy-pow.php", + "function": "get_difficulty_for_ip", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "UA changes only PoW challenge difficulty; the challenge response is sent no-cache." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "check_and_increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "increment", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_count", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_count", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_reset_time", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_reset_time", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "reset", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "reset", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "cleanup", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "cleanup", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-rate-limiter.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "mark", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "flush", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "flush", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "summary", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "summary", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "summary", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "summary", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "prune", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-request-counts.php", + "function": "prune", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "track_attempt", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "resolve_attempt", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist checkout status transition on the plugin attempt row; no cached result can apply this update." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "resolve_attempt", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Persist checkout status transition on the plugin attempt row; no cached result can apply this update." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_recent_attempts", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_recent_attempts", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_recent_attempts", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_recent_attempts", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "log_detection", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "log_detection", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__", + "reason": "Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_stats", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_suspicious_ips", + "source": "WordPress.DB.DirectDatabaseQuery.DirectQuery", + "reason": "Current suspicious-checkout IP list based on the moving 24-hour failure window; not a cached enforcement substitute." + }, + { + "file": "includes/class-webdecoy-woocommerce.php", + "function": "get_suspicious_ips", + "source": "WordPress.DB.DirectDatabaseQuery.NoCaching", + "reason": "Current suspicious-checkout IP list based on the moving 24-hour failure window; not a cached enforcement substitute." + }, + { + "file": "sdk/src/LlmReferral.php", + "function": "classify", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "reason": "Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests." + }, + { + "file": "sdk/src/LlmReferral.php", + "function": "classify", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "reason": "Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests." + }, + { + "file": "sdk/src/LlmReferral.php", + "function": "platformForTag", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "reason": "Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests." + }, + { + "file": "sdk/src/BotDetector.php", + "function": "cloudRefusal", + "source": "WordPress.WP.AlternativeFunctions.parse_url_parse_url", + "reason": "Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests." + }, + { + "file": "sdk/src/SignalCollector.php", + "function": "sanitizeString", + "source": "WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter", + "reason": "Framework-independent SDK fallback only; WordPress sanitizer/wp_strip_all_tags is preferred when available; output remains HTML-escaped." + }, + { + "file": "sdk/src/Exception/WebDecoyException.php", + "function": "__toString", + "source": "WordPress.WP.AlternativeFunctions.json_encode_json_encode", + "reason": "Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests." + }, + { + "file": "templates/block-page.php", + "function": "file scope", + "source": "WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders", + "reason": "FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here." + }, + { + "file": "templates/block-page.php", + "function": "file scope", + "source": "WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__", + "reason": "Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response." + } + ] +} diff --git a/includes/class-webdecoy-activator.php b/includes/class-webdecoy-activator.php index a366ab4..5bb6f3b 100644 --- a/includes/class-webdecoy-activator.php +++ b/includes/class-webdecoy-activator.php @@ -38,7 +38,8 @@ public static function activate(): void } // Flush rewrite rules - flush_rewrite_rules(); + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules -- Lifecycle only; soft flush updates rewrite options without writing .htaccess. + flush_rewrite_rules(false); } /** @@ -53,7 +54,8 @@ public static function deactivate(): void wp_clear_scheduled_hook('webdecoy_sync_actor_feed'); // Flush rewrite rules - flush_rewrite_rules(); + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.flush_rewrite_rules_flush_rewrite_rules -- Lifecycle only; soft flush updates rewrite options without writing .htaccess. + flush_rewrite_rules(false); } /** @@ -190,6 +192,7 @@ private static function create_tables(): bool dbDelta($sql_ai_referral_days); dbDelta($sql_request_counts); $table = $wpdb->prefix . 'webdecoy_request_counts'; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state. $exists = $wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $wpdb->esc_like($table))) === $table; if ($exists) { add_option('webdecoy_request_counts_started_at', time(), '', false); @@ -322,7 +325,7 @@ public static function uninstall(): void ]; foreach ($tables as $table) { - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe, built from $wpdb->prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe, built from $wpdb->prefix $wpdb->query("DROP TABLE IF EXISTS {$table}"); } @@ -349,12 +352,14 @@ public static function uninstall(): void global $wpdb; // Clean up expired blocks + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state. $wpdb->query($wpdb->prepare( "DELETE FROM {$wpdb->prefix}webdecoy_blocked_ips WHERE expires_at IS NOT NULL AND expires_at < %s", current_time('mysql', true) )); // Clean up old rate limit entries + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state. $wpdb->query($wpdb->prepare( "DELETE FROM {$wpdb->prefix}webdecoy_rate_limits WHERE window_start < %s", gmdate('Y-m-d H:i:s', strtotime('-1 hour')) @@ -365,6 +370,7 @@ public static function uninstall(): void $retention_days = class_exists('WebDecoy_Runtime_Config') ? WebDecoy_Runtime_Config::log_retention_days() : 30; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state. $wpdb->query($wpdb->prepare( "DELETE FROM {$wpdb->prefix}webdecoy_detections WHERE created_at < %s", gmdate('Y-m-d H:i:s', strtotime("-{$retention_days} days")) @@ -385,6 +391,7 @@ public static function uninstall(): void } // Clean up old checkout attempts (keep 7 days) + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Lifecycle schema verification or scheduled retention cleanup on plugin-owned tables; requires actual database state. $wpdb->query($wpdb->prepare( "DELETE FROM {$wpdb->prefix}webdecoy_checkout_attempts WHERE created_at < %s", gmdate('Y-m-d H:i:s', strtotime('-7 days')) diff --git a/includes/class-webdecoy-actor-feed.php b/includes/class-webdecoy-actor-feed.php index 366069d..673035c 100644 --- a/includes/class-webdecoy-actor-feed.php +++ b/includes/class-webdecoy-actor-feed.php @@ -48,6 +48,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-http.php'; + /** * WebDecoy Actor Feed controller. */ @@ -153,7 +155,7 @@ public function sync(): void $cursor = (int) get_option(self::CURSOR_OPTION, 0); $latest_cursor = $cursor; - $ip_map = []; // ip => ['actor_id' => string, 'last_seen' => int] + $ip_map = []; // Each IP maps to its actor identifier and last-seen timestamp. $pages = 0; do { @@ -230,7 +232,8 @@ private function fetch_page(string $api_key, int $since): array $url = self::FEED_ENDPOINT . '?since=' . rawurlencode((string) $since); - $response = wp_remote_get($url, [ + $response = WebDecoy_HTTP::get($url, [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 8, 'headers' => [ 'Accept' => 'application/json', diff --git a/includes/class-webdecoy-ai-referrals.php b/includes/class-webdecoy-ai-referrals.php index b42c390..7cb8149 100644 --- a/includes/class-webdecoy-ai-referrals.php +++ b/includes/class-webdecoy-ai-referrals.php @@ -6,6 +6,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-http.php'; + /** * Counts page visits that AI products (ChatGPT, Claude, Perplexity, Gemini, * Copilot and others) send to this site, for WebDecoy's AI Traffic page. @@ -259,7 +261,7 @@ public static function classifyRequest(string $method, string $mode, string $des /** The path of a request URI, cut to the width WebDecoy stores. */ public static function landingPath(string $uri): string { - $path = (string) (parse_url($uri, PHP_URL_PATH) ?: '/'); + $path = (string) (wp_parse_url($uri, PHP_URL_PATH) ?: '/'); if ($path === '' || $path[0] !== '/') { $path = '/' . $path; } @@ -351,7 +353,8 @@ public static function flush(string $apiKey): void */ private static function send(string $apiKey, string $batch, array $referrals): bool { - $response = wp_remote_post(self::ENDPOINT, [ + $response = WebDecoy_HTTP::post(self::ENDPOINT, [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 5, 'headers' => [ 'Content-Type' => 'application/json', diff --git a/includes/class-webdecoy-blocker.php b/includes/class-webdecoy-blocker.php index 4773065..597a44b 100644 --- a/includes/class-webdecoy-blocker.php +++ b/includes/class-webdecoy-blocker.php @@ -86,6 +86,7 @@ public function block(string $ip, string $reason = '', ?int $duration_hours = nu } // Check if already blocked + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Read-before-upsert needs current plugin block row; successful mutation invalidates the IP decision cache. $existing = $wpdb->get_var($wpdb->prepare( "SELECT id FROM {$table} WHERE ip_address = %s", $ip @@ -93,6 +94,7 @@ public function block(string $ip, string $reason = '', ?int $duration_hours = nu if ($existing) { // Update existing block + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $result = $wpdb->update( $table, [ @@ -104,6 +106,7 @@ public function block(string $ip, string $reason = '', ?int $duration_hours = nu ); } else { // Insert new block + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $result = $wpdb->insert( $table, [ @@ -153,9 +156,8 @@ private function guard(string $ip): ?string // The "behind a proxy" signal is the stored flag, NOT this request's headers: // keying off the headers would let an attacker who reaches the origin directly // send X-Forwarded-For and make guard() refuse to block them. - $remote = isset($_SERVER['REMOTE_ADDR']) - ? trim(sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']))) - : ''; + // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__ -- FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here. Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response. + $remote = filter_var(wp_unslash($_SERVER['REMOTE_ADDR'] ?? ''), FILTER_VALIDATE_IP) ?: ''; if ($remote !== '' && $addr === $remote && get_option('webdecoy_proxy_detected', false)) { return 'address is this site\'s proxy front door (proxy detected, no trusted proxy configured)'; } @@ -227,9 +229,8 @@ public static function unresolved_forwarding_header(): string return ''; } - $remote = isset($_SERVER['REMOTE_ADDR']) - ? self::canonical_ip(sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']))) - : ''; + // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__ -- FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here. Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response. + $remote = self::canonical_ip(filter_var(wp_unslash($_SERVER['REMOTE_ADDR'] ?? ''), FILTER_VALIDATE_IP) ?: ''); if ($remote === '') { return $seen; } @@ -263,7 +264,7 @@ private static function forwarded_addresses(string $value): array if (stripos($part, 'for=') === 0) { $part = substr($part, 4); } elseif (strpos($part, '=') !== false) { - continue; // by=, proto=, host= + continue; // Ignore the Forwarded header by, proto, and host attributes. } $ip = self::canonical_ip($part); if ($ip !== '') { @@ -346,6 +347,7 @@ public function unblock(string $ip): bool $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $result = $wpdb->delete($table, ['ip_address' => $ip]); // Clear cache @@ -378,6 +380,7 @@ public function is_blocked(string $ip): bool $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); // First check for exact IP match (fastest) + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned block lookup on object-cache miss; result is cached and block mutations invalidate the IP cache. $exact_blocked = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE ip_address = %s AND (expires_at IS NULL OR expires_at > %s)", $ip, @@ -390,7 +393,7 @@ public function is_blocked(string $ip): bool } // Check CIDR ranges - // phpcs:ignore WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery -- Searching for CIDR notation IPs containing / + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.PreparedSQLPlaceholders.LikeWildcardsInQuery -- Searching for CIDR notation IPs containing / $cidr_blocks = $wpdb->get_col($wpdb->prepare( "SELECT ip_address FROM {$table} WHERE ip_address LIKE '%%/%%' AND (expires_at IS NULL OR expires_at > %s)", gmdate('Y-m-d H:i:s') @@ -439,6 +442,7 @@ public function get_blocked_ips(array $args = []): array $offset = ($args['page'] - 1) * $args['per_page']; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Filtered, paginated operator block list needs current entries after block/unblock actions. $results = $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$table} WHERE {$where} ORDER BY {$orderby} {$order} LIMIT %d OFFSET %d", $args['per_page'], @@ -465,6 +469,7 @@ public function get_blocked_count(bool $include_expired = false): int $where .= $wpdb->prepare(" AND (expires_at IS NULL OR expires_at > %s)", gmdate('Y-m-d H:i:s')); } + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Operator list pagination uses current plugin block counts, including time-dependent expirations. return (int) $wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE {$where}"); } @@ -480,6 +485,7 @@ public function get_block_info(string $ip): ?array $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live block reason/expiration lookup for the no-cache security response; do not serve stale block details. $result = $wpdb->get_row($wpdb->prepare( "SELECT * FROM {$table} WHERE ip_address = %s AND (expires_at IS NULL OR expires_at > %s)", $ip, @@ -512,6 +518,7 @@ public function extend_block(string $ip, int $hours): bool $new_expires = gmdate('Y-m-d H:i:s', strtotime($info['expires_at'] . " +{$hours} hours")); } + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $result = $wpdb->update( $table, ['expires_at' => $new_expires], @@ -534,6 +541,7 @@ public function clear_all(): int $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Explicit operator mutation clears plugin blocks; no cached result can execute deletion. $count = $wpdb->query("DELETE FROM {$table}"); // Clear all cache (wp_cache_flush_group() requires WP 6.1+) @@ -555,6 +563,7 @@ public function cleanup_expired(): int $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Scheduled deletion of expired plugin blocks; no cached result can execute retention. return $wpdb->query($wpdb->prepare( "DELETE FROM {$table} WHERE expires_at IS NOT NULL AND expires_at < %s", gmdate('Y-m-d H:i:s') @@ -821,30 +830,43 @@ public function bulk_unblock(array $ips): int */ public function get_stats(): array { + // Presentation only: enforcement and velocity checks never read this cache. + $cache_key = 'blocked_stats'; + $cached = wp_cache_get($cache_key, 'webdecoy_analytics'); + if (is_array($cached)) { + return $cached; + } + global $wpdb; $table = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $total = $wpdb->get_var("SELECT COUNT(*) FROM {$table}"); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $active = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE expires_at IS NULL OR expires_at > %s", gmdate('Y-m-d H:i:s') )); $expired = $total - $active; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $permanent = $wpdb->get_var("SELECT COUNT(*) FROM {$table} WHERE expires_at IS NULL"); // Blocks in last 24 hours + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $recent = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE blocked_at > %s", gmdate('Y-m-d H:i:s', strtotime('-24 hours')) )); - return [ + $stats = [ 'total' => (int) $total, 'active' => (int) $active, 'expired' => (int) $expired, 'permanent' => (int) $permanent, 'last_24h' => (int) $recent, ]; + wp_cache_set($cache_key, $stats, 'webdecoy_analytics', 60); + return $stats; } } diff --git a/includes/class-webdecoy-cli.php b/includes/class-webdecoy-cli.php index a58a9d7..5d3dbe0 100644 --- a/includes/class-webdecoy-cli.php +++ b/includes/class-webdecoy-cli.php @@ -81,11 +81,13 @@ public function status($args, $assoc_args): void $blocked = esc_sql($wpdb->prefix . 'webdecoy_blocked_ips'); $now = gmdate('Y-m-d H:i:s'); - $total = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$detections}"); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix + $total = (int) $wpdb->get_var("SELECT COUNT(*) FROM {$detections}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit WP-CLI status reads current plugin table state. $last24 = (int) $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$detections} WHERE created_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared gmdate('Y-m-d H:i:s', strtotime('-24 hours')) )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit WP-CLI operator status/maintenance of plugin tables; report current state rather than a stale cache. $active_blocks = (int) $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$blocked} WHERE expires_at IS NULL OR expires_at > %s", // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared $now @@ -288,7 +290,7 @@ public function logs($args, $assoc_args): void \WP_CLI::confirm('Delete ALL recorded detections on this site?', $assoc_args); $detections = esc_sql($wpdb->prefix . 'webdecoy_detections'); - $deleted = $wpdb->query("DELETE FROM {$detections}"); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix + $deleted = $wpdb->query("DELETE FROM {$detections}"); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- table name from $wpdb->prefix \WP_CLI::success(sprintf('Deleted %d detection%s.', (int) $deleted, (int) $deleted === 1 ? '' : 's')); } diff --git a/includes/class-webdecoy-cloud-connect.php b/includes/class-webdecoy-cloud-connect.php index a272aa6..1168410 100644 --- a/includes/class-webdecoy-cloud-connect.php +++ b/includes/class-webdecoy-cloud-connect.php @@ -29,6 +29,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-http.php'; + /** * WebDecoy Cloud Connect controller. */ @@ -245,8 +247,8 @@ public static function setup_url_from(array $result): string if ($candidate === '') { return self::SETUP_URL; } - $parts = parse_url($candidate); - $base = parse_url(self::SETUP_URL); + $parts = wp_parse_url($candidate); + $base = wp_parse_url(self::SETUP_URL); if ( !is_array($parts) || !is_array($base) || ($parts['scheme'] ?? '') !== 'https' @@ -290,7 +292,8 @@ public function handle_disconnect(): void */ private function exchange_token(string $token, string $nonce): ?array { - $response = wp_remote_post(self::EXCHANGE_ENDPOINT, [ + $response = WebDecoy_HTTP::post(self::EXCHANGE_ENDPOINT, [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 10, 'headers' => [ 'Content-Type' => 'application/json', @@ -352,7 +355,8 @@ public function sync_entitlements(): void // Same auth scheme as WebDecoy_Violation_Reporter::send(): the API key // as a Bearer token in the Authorization header. - $response = wp_remote_get(self::ENTITLEMENTS_ENDPOINT, [ + $response = WebDecoy_HTTP::get(self::ENTITLEMENTS_ENDPOINT, [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 5, 'headers' => [ 'Accept' => 'application/json', diff --git a/includes/class-webdecoy-cloud-policy.php b/includes/class-webdecoy-cloud-policy.php index 6ab8633..08f985f 100644 --- a/includes/class-webdecoy-cloud-policy.php +++ b/includes/class-webdecoy-cloud-policy.php @@ -26,6 +26,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-http.php'; + class WebDecoy_Cloud_Policy { /** The public config endpoint the edge sensor reads (nothing in it is secret). */ @@ -69,7 +71,8 @@ public function sync(): void ['aid' => $organization_id, 'host' => $host], self::CONFIG_ENDPOINT ); - $response = wp_remote_get($url, [ + $response = WebDecoy_HTTP::get($url, [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 5, 'headers' => ['Accept' => 'application/json'], ]); diff --git a/includes/class-webdecoy-detection-sender.php b/includes/class-webdecoy-detection-sender.php index 2c2d5a7..5cab4d8 100644 --- a/includes/class-webdecoy-detection-sender.php +++ b/includes/class-webdecoy-detection-sender.php @@ -6,6 +6,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-diagnostics.php'; + /** * Sends detections to WebDecoy Cloud after the visitor has their page * (WebDecoy/app#1245). @@ -99,7 +101,7 @@ public static function send_queued(): void if (self::is_refusal($e)) { self::note_refusal(); } - error_log('WebDecoy API error: ' . $e->getMessage()); + WebDecoy_Diagnostics::report('api_error'); } } } diff --git a/includes/class-webdecoy-detector.php b/includes/class-webdecoy-detector.php index 9320626..03d5736 100644 --- a/includes/class-webdecoy-detector.php +++ b/includes/class-webdecoy-detector.php @@ -142,6 +142,7 @@ private function get_request_path(): string */ private function has_wordpress_cookies(): bool { + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE -- Cookie presence is only a request-local detection signal, never authentication; cached page hits remain outside PHP coverage. foreach ($_COOKIE as $name => $value) { if (strpos($name, 'wordpress_') === 0 || strpos($name, 'wp-') === 0 || @@ -241,13 +242,14 @@ public function log_detection(\WebDecoy\DetectionResult $result, string $ip): vo $table = esc_sql($wpdb->prefix . 'webdecoy_detections'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $ip, 'user_agent' => $this->get_signal_collector()->getUserAgent(), 'score' => $result->getScore(), 'threat_level' => $result->getThreatLevel(), 'source' => 'wordpress_plugin', - 'flags' => json_encode($result->getFlags()), + 'flags' => wp_json_encode($result->getFlags()), // STORAGE CONVENTION (#55): every timestamp this plugin writes is UTC, // and conversion happens at the display boundary via get_date_from_gmt(). // It was previously current_time('mysql') (site-local) while the readers @@ -276,6 +278,7 @@ public function get_recent_detections(int $limit = 10): array $table = esc_sql($wpdb->prefix . 'webdecoy_detections'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Current operator audit rows are deliberately uncached so a setup test appears immediately; row limit is prepared. return $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$table} ORDER BY created_at DESC LIMIT %d", $limit @@ -290,38 +293,52 @@ public function get_recent_detections(int $limit = 10): array */ public function get_stats(int $days = 7): array { + // Presentation only: enforcement and velocity checks never read this cache. + $days = max(1, min(3650, $days)); + $cache_key = 'detection_stats' . '_' . $days; + $cached = wp_cache_get($cache_key, 'webdecoy_analytics'); + if (is_array($cached)) { + return $cached; + } + global $wpdb; $table = esc_sql($wpdb->prefix . 'webdecoy_detections'); $since = gmdate('Y-m-d H:i:s', strtotime("-{$days} days")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $total = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE created_at > %s", $since )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $by_level = $wpdb->get_results($wpdb->prepare( "SELECT threat_level, COUNT(*) as count FROM {$table} WHERE created_at > %s GROUP BY threat_level", $since ), OBJECT_K); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $by_day = $wpdb->get_results($wpdb->prepare( "SELECT DATE(created_at) as date, COUNT(*) as count FROM {$table} WHERE created_at > %s GROUP BY DATE(created_at) ORDER BY date", $since ), ARRAY_A); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $high_risk = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE created_at > %s AND threat_level IN ('HIGH', 'CRITICAL')", $since )); - return [ + $stats = [ 'total' => (int) $total, 'high_risk' => (int) $high_risk, 'by_level' => $by_level, 'by_day' => $by_day, 'period_days' => $days, ]; + wp_cache_set($cache_key, $stats, 'webdecoy_analytics', 60); + return $stats; } /** @@ -337,6 +354,7 @@ public function get_unique_ips(int $days = 7): int $table = esc_sql($wpdb->prefix . 'webdecoy_detections'); $since = gmdate('Y-m-d H:i:s', strtotime("-{$days} days")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Current operator distinct-IP total from the plugin detection table; not used on public enforcement paths. return (int) $wpdb->get_var($wpdb->prepare( "SELECT COUNT(DISTINCT ip_address) FROM {$table} WHERE created_at > %s", $since diff --git a/includes/class-webdecoy-diagnostics.php b/includes/class-webdecoy-diagnostics.php new file mode 100644 index 0000000..20ab8d2 --- /dev/null +++ b/includes/class-webdecoy-diagnostics.php @@ -0,0 +1,20 @@ + $this->timeout, 'headers' => [ 'Authorization' => 'Bearer ' . $this->apiKey, diff --git a/includes/class-webdecoy-pow.php b/includes/class-webdecoy-pow.php index 0e315aa..485e694 100644 --- a/includes/class-webdecoy-pow.php +++ b/includes/class-webdecoy-pow.php @@ -146,6 +146,7 @@ public function get_difficulty_for_ip( $ip, $base = 4 ) { } // Check for known bot UA patterns + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- UA changes only PoW challenge difficulty; the challenge response is sent no-cache. $ua = isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : ''; if ( $this->is_suspicious_ua( $ua ) ) { $difficulty++; diff --git a/includes/class-webdecoy-rate-limit-rule.php b/includes/class-webdecoy-rate-limit-rule.php index dd80261..526636f 100644 --- a/includes/class-webdecoy-rate-limit-rule.php +++ b/includes/class-webdecoy-rate-limit-rule.php @@ -163,6 +163,7 @@ private function checkSliding(string $key): array $curr = wp_cache_incr($currKey, 1, self::CACHE_GROUP); if ($curr === false) { + // phpcs:ignore WordPressVIPMinimum.Performance.LowExpiryCacheTime.CacheTimeUndetermined -- Security sliding-window bucket TTL is intentionally twice the configured window; raising it to 300 seconds changes counter lifetime. wp_cache_add($currKey, 1, self::CACHE_GROUP, $win * 2); $curr = 1; } diff --git a/includes/class-webdecoy-rate-limiter.php b/includes/class-webdecoy-rate-limiter.php index 0f809ee..18c6842 100644 --- a/includes/class-webdecoy-rate-limiter.php +++ b/includes/class-webdecoy-rate-limiter.php @@ -88,6 +88,7 @@ public function check_and_increment(string $key): array $now = current_time('mysql', true); $window_start_threshold = gmdate('Y-m-d H:i:s', strtotime("-{$this->window} seconds")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $existing = $wpdb->get_row($wpdb->prepare( "SELECT request_count, window_start FROM {$table} WHERE ip_address = %s AND window_start > %s", $key, @@ -96,10 +97,13 @@ public function check_and_increment(string $key): array if ($existing) { $current = (int) $existing['request_count'] + 1; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->update($table, ['request_count' => $current], ['ip_address' => $key]); $reset_at = strtotime($existing['window_start']) + $this->window; } else { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->delete($table, ['ip_address' => $key]); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $key, 'request_count' => 1, @@ -131,6 +135,7 @@ public function increment(string $ip): int $window_start = gmdate('Y-m-d H:i:s', strtotime("-{$this->window} seconds")); // Check for existing record in current window + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $existing = $wpdb->get_row($wpdb->prepare( "SELECT * FROM {$table} WHERE ip_address = %s AND window_start > %s", $ip, @@ -140,6 +145,7 @@ public function increment(string $ip): int if ($existing) { // Increment existing count $new_count = (int) $existing['request_count'] + 1; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->update( $table, ['request_count' => $new_count], @@ -148,7 +154,9 @@ public function increment(string $ip): int return $new_count; } else { // Delete old record if exists and create new + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->delete($table, ['ip_address' => $ip]); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $ip, 'request_count' => 1, @@ -171,6 +179,7 @@ public function get_count(string $ip): int $table = esc_sql($wpdb->prefix . 'webdecoy_rate_limits'); $window_start = gmdate('Y-m-d H:i:s', strtotime("-{$this->window} seconds")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $count = $wpdb->get_var($wpdb->prepare( "SELECT request_count FROM {$table} WHERE ip_address = %s AND window_start > %s", $ip, @@ -205,6 +214,7 @@ public function get_reset_time(string $ip): int $table = esc_sql($wpdb->prefix . 'webdecoy_rate_limits'); $window_start_threshold = gmdate('Y-m-d H:i:s', strtotime("-{$this->window} seconds")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $window_start = $wpdb->get_var($wpdb->prepare( "SELECT window_start FROM {$table} WHERE ip_address = %s AND window_start > %s", $ip, @@ -233,6 +243,7 @@ public function reset(string $ip): bool $table = esc_sql($wpdb->prefix . 'webdecoy_rate_limits'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. return $wpdb->delete($table, ['ip_address' => $ip]) !== false; } @@ -248,6 +259,7 @@ public function cleanup(): int $table = esc_sql($wpdb->prefix . 'webdecoy_rate_limits'); $threshold = gmdate('Y-m-d H:i:s', strtotime('-1 hour')); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. return $wpdb->query($wpdb->prepare( "DELETE FROM {$table} WHERE window_start < %s", $threshold @@ -341,16 +353,19 @@ public function get_stats(): array $table = esc_sql($wpdb->prefix . 'webdecoy_rate_limits'); $window_start = gmdate('Y-m-d H:i:s', strtotime("-{$this->window} seconds")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $active_ips = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(DISTINCT ip_address) FROM {$table} WHERE window_start > %s", $window_start )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $total_requests = $wpdb->get_var($wpdb->prepare( "SELECT SUM(request_count) FROM {$table} WHERE window_start > %s", $window_start )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live plugin rate-limit state/maintenance; stale cached counts or reset times must not control security decisions. $exceeded = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE window_start > %s AND request_count >= %d", $window_start, diff --git a/includes/class-webdecoy-request-counts.php b/includes/class-webdecoy-request-counts.php index 76c5531..f91c0ee 100644 --- a/includes/class-webdecoy-request-counts.php +++ b/includes/class-webdecoy-request-counts.php @@ -25,6 +25,7 @@ public static function mark(string $outcome): void if (PHP_SAPI === 'cli' || self::$flushed || (defined('WEBDECOY_DISABLE') && WEBDECOY_DISABLE)) { return; } + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. $ua = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : ''; if (self::is_setup_test($ua)) { return; @@ -97,8 +98,9 @@ public static function flush(): void return; } $table = self::table(); - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- trusted table prefix; outcome is a closed enum + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals. $wpdb->query($wpdb->prepare( + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Identifier derives only from the trusted WordPress table prefix; values remain prepared. "INSERT INTO {$table} (bucket, outcome, hits) VALUES (%s, %s, 1) ON DUPLICATE KEY UPDATE hits = hits + 1", gmdate('Y-m-d H:00:00'), self::$pending @@ -162,13 +164,15 @@ public static function summary(int $days): array global $wpdb; $table = self::table(); $detections = esc_sql($wpdb->prefix . 'webdecoy_detections'); - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- trusted table prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals. $rows = $wpdb->get_results($wpdb->prepare( + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Identifier derives only from the trusted WordPress table prefix; values remain prepared. "SELECT outcome, SUM(hits) AS hits FROM {$table} WHERE bucket >= %s AND bucket < %s GROUP BY outcome", $window['from'], $window['until'] ), ARRAY_A); - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- trusted table prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Plugin-owned outcome counters; writes/retention must persist and setup/status summaries deliberately read current receipt totals. $count = $wpdb->get_var($wpdb->prepare( + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Identifier derives only from the trusted WordPress table prefix; values remain prepared. "SELECT COUNT(*) FROM {$detections} WHERE created_at >= %s AND created_at < %s", $window['from'], $window['until'] )); @@ -186,7 +190,7 @@ public static function prune(): void global $wpdb; $table = self::table(); $window = self::window(self::RETENTION_DAYS); - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- trusted table prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table identifier comes only from the trusted WordPress prefix; cutoff is prepared. $wpdb->query($wpdb->prepare("DELETE FROM {$table} WHERE bucket < %s", $window['from'])); } diff --git a/includes/class-webdecoy-robots-txt.php b/includes/class-webdecoy-robots-txt.php index c0118f2..c3dd833 100644 --- a/includes/class-webdecoy-robots-txt.php +++ b/includes/class-webdecoy-robots-txt.php @@ -58,6 +58,9 @@ class WebDecoy_Robots_Txt */ public static function register($categories): void { + // Register even for an empty selection so enabling the first category + // also invalidates VIP's long-lived virtual robots.txt response. + add_action('update_option_webdecoy_options', [self::class, 'settings_updated'], 10, 2); if (defined('WEBDECOY_DISABLE') && WEBDECOY_DISABLE) { return; } @@ -69,6 +72,7 @@ public static function register($categories): void // only the output: the site's "discourage search engines" flag does // not decide this, because the owner chose these categories and the // noindex tag that setting adds does not keep training crawlers away. + // phpcs:ignore WordPressVIPMinimum.Hooks.RestrictedHooks.robots_txt -- Category changes queue a targeted VIP robots.txt purge in settings_updated(); deployment changes still require an operator purge. add_filter('robots_txt', static function ($output) use ($selected) { return self::append( (string) $output, @@ -78,6 +82,23 @@ public static function register($categories): void }, 100, 1); } + /** Queue a targeted VIP purge only when the robots policy changes. */ + public static function settings_updated($old, $new): void + { + $before = self::sanitize_categories(is_array($old) ? ($old[self::OPTION_KEY] ?? []) : []); + $after = self::sanitize_categories(is_array($new) ? ($new[self::OPTION_KEY] ?? []) : []); + sort($before); + sort($after); + if ($before === $after) { + return; + } + if (function_exists('wpvip_purge_edge_cache_for_url')) { + wpvip_purge_edge_cache_for_url(home_url('/robots.txt')); + } elseif (function_exists('wpcom_vip_purge_edge_cache_for_url')) { + wpcom_vip_purge_edge_cache_for_url(home_url('/robots.txt')); + } + } + /** * The categories an owner can choose, in registry order, each with the * number of distinct robots.txt names it covers. Categories with no named diff --git a/includes/class-webdecoy-updater.php b/includes/class-webdecoy-updater.php index b6fd9fa..f9f97dc 100644 --- a/includes/class-webdecoy-updater.php +++ b/includes/class-webdecoy-updater.php @@ -6,6 +6,8 @@ exit; } +require_once __DIR__ . '/class-webdecoy-http.php'; + /** * Self-hosted update mechanism (CDN distribution ONLY). * @@ -55,7 +57,8 @@ public function check_for_updates($transient) $update_info = get_transient('webdecoy_update_info'); if ($update_info === false) { - $response = wp_remote_get('https://cdn.webdecoy.com/wordpress/update-info.json', [ + $response = WebDecoy_HTTP::get('https://cdn.webdecoy.com/wordpress/update-info.json', [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 10, 'headers' => [ 'Accept' => 'application/json', @@ -180,7 +183,8 @@ public function plugin_info($result, $action, $args) return $result; } - $response = wp_remote_get('https://cdn.webdecoy.com/wordpress/plugin-info.json', [ + $response = WebDecoy_HTTP::get('https://cdn.webdecoy.com/wordpress/plugin-info.json', [ + // phpcs:ignore WordPressVIPMinimum.Performance.RemoteRequestTimeout.timeout_timeout -- WebDecoy_HTTP caps this to 3 seconds on VIP; retains the non-VIP caller budget. 'timeout' => 10, 'headers' => [ 'Accept' => 'application/json', diff --git a/includes/class-webdecoy-violation-reporter.php b/includes/class-webdecoy-violation-reporter.php index 6d34010..0b0d04d 100644 --- a/includes/class-webdecoy-violation-reporter.php +++ b/includes/class-webdecoy-violation-reporter.php @@ -105,6 +105,7 @@ public function report(array $events): void $now = current_time('mysql'); foreach ($events as $event) { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'payload' => wp_json_encode($event->toApiPayload()), 'attempts' => 0, @@ -216,6 +217,7 @@ private static function drain_locked(string $apiKey): void $ids[] = (int) $row->id; } else { // Unparseable row — drop it immediately. + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->delete($table, ['id' => (int) $row->id]); } } diff --git a/includes/class-webdecoy-woocommerce.php b/includes/class-webdecoy-woocommerce.php index cf6602d..9a0da24 100644 --- a/includes/class-webdecoy-woocommerce.php +++ b/includes/class-webdecoy-woocommerce.php @@ -235,6 +235,7 @@ public function track_attempt(int $order_id): void $table = esc_sql($wpdb->prefix . 'webdecoy_checkout_attempts'); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $this->get_client_ip(), 'order_id' => $order_id, @@ -292,7 +293,7 @@ public function resolve_attempt(int $order_id, string $status): void // address or empty — so an IP-scoped UPDATE matched nothing and silently left // the row open. The row was inserted with the customer's IP by track_attempt(); // order_id already identifies it. - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe, built from $wpdb->prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table name is safe, built from $wpdb->prefix $wpdb->query($wpdb->prepare( "UPDATE {$table} SET status = %s WHERE order_id = %d AND status = 'attempt'", $status, @@ -372,6 +373,7 @@ private function get_recent_attempts(string $ip, int $window, bool $include_succ $since = gmdate('Y-m-d H:i:s', strtotime("-{$window} seconds")); if ($include_successful) { + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window. return $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$table} WHERE ip_address = %s AND created_at > %s ORDER BY created_at DESC", $ip, @@ -381,6 +383,7 @@ private function get_recent_attempts(string $ip, int $window, bool $include_succ // NULL-safe: in MySQL `NULL <> 'success'` is NULL, not TRUE, so a bare // inequality would silently drop any row with no status rather than counting it. + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Live checkout velocity query on plugin attempts; cached failures would change the fraud decision window. return $wpdb->get_results($wpdb->prepare( "SELECT * FROM {$table} WHERE ip_address = %s AND created_at > %s AND (status IS NULL OR status <> 'success') ORDER BY created_at DESC", $ip, @@ -430,8 +433,10 @@ private function log_detection(string $ip, string $reason, ?int $score = null): $source = 'woocommerce_' . $reason; // Log locally + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $ip, + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'score' => $final_score, 'threat_level' => 'HIGH', @@ -489,7 +494,7 @@ private function forward_to_webdecoy(string $ip, string $source, int $score, arr 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $this->options['api_key'], ], - 'body' => json_encode($payload), + 'body' => wp_json_encode($payload), ]); } @@ -574,26 +579,38 @@ public function detect_card_testing_public(string $ip): bool */ public function get_stats(int $days = 7): array { + // Presentation only: enforcement and velocity checks never read this cache. + $days = max(1, min(3650, $days)); + $cache_key = 'checkout_stats' . '_' . $days; + $cached = wp_cache_get($cache_key, 'webdecoy_analytics'); + if (is_array($cached)) { + return $cached; + } + global $wpdb; $table = esc_sql($wpdb->prefix . 'webdecoy_checkout_attempts'); $since = gmdate('Y-m-d H:i:s', strtotime("-{$days} days")); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $total = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM {$table} WHERE created_at > %s", $since )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $by_status = $wpdb->get_results($wpdb->prepare( "SELECT status, COUNT(*) as count FROM {$table} WHERE created_at > %s GROUP BY status", $since ), OBJECT_K); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $unique_ips = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(DISTINCT ip_address) FROM {$table} WHERE created_at > %s", $since )); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Plugin-owned table aggregate; get_stats caches its complete presentation result for 60 seconds, separately from enforcement. $blocked = $wpdb->get_var($wpdb->prepare( "SELECT COUNT(*) FROM ( SELECT ip_address FROM {$table} @@ -603,13 +620,15 @@ public function get_stats(int $days = 7): array $since )); - return [ + $stats = [ 'total_attempts' => (int) $total, 'by_status' => $by_status, 'unique_ips' => (int) $unique_ips, 'blocked_ips' => (int) $blocked, 'period_days' => $days, ]; + wp_cache_set($cache_key, $stats, 'webdecoy_analytics', 60); + return $stats; } /** @@ -625,6 +644,7 @@ public function get_suspicious_ips(int $threshold = 3): array $table = esc_sql($wpdb->prefix . 'webdecoy_checkout_attempts'); $since = gmdate('Y-m-d H:i:s', strtotime('-24 hours')); + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Current suspicious-checkout IP list based on the moving 24-hour failure window; not a cached enforcement substitute. return $wpdb->get_results($wpdb->prepare( "SELECT ip_address, COUNT(*) as attempts, SUM(CASE WHEN status = 'declined' THEN 1 ELSE 0 END) as declined, diff --git a/sdk/src/BotDetector.php b/sdk/src/BotDetector.php index 66324d3..63ce389 100644 --- a/sdk/src/BotDetector.php +++ b/sdk/src/BotDetector.php @@ -586,6 +586,7 @@ public function cloudRefusal(array $botInfo, string $requestPath): ?array if ($behavior === '') { return null; } + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests. $path = (string) (parse_url($requestPath, PHP_URL_PATH) ?: '/'); $siteMode = (string) ($policy['mode'] ?? 'monitor'); $resolution = RouteResolution::resolve($path, RouteResolution::rulesFromConfig($policy), $siteMode); diff --git a/sdk/src/Exception/WebDecoyException.php b/sdk/src/Exception/WebDecoyException.php index 15e9386..45ddc6f 100644 --- a/sdk/src/Exception/WebDecoyException.php +++ b/sdk/src/Exception/WebDecoyException.php @@ -221,6 +221,7 @@ public function __toString(): string $str = "WebDecoyException: [{$this->code}] {$this->message}"; if (!empty($this->context)) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.json_encode_json_encode -- Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests. $str .= ' | Context: ' . json_encode($this->context); } diff --git a/sdk/src/LlmReferral.php b/sdk/src/LlmReferral.php index c6fcb4d..d5589a0 100644 --- a/sdk/src/LlmReferral.php +++ b/sdk/src/LlmReferral.php @@ -45,12 +45,14 @@ public static function classify(string $referer, string $pageUrl): string $platforms = self::platforms(); $referer = trim($referer); if ($referer !== '') { + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests. $host = parse_url($referer, PHP_URL_HOST); if (!is_string($host) || $host === '') { return ''; } return $platforms[strtolower($host)] ?? ''; } + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests. $query = parse_url($pageUrl, PHP_URL_QUERY); if (!is_string($query) || $query === '') { return ''; @@ -101,6 +103,7 @@ private static function platformForTag(string $raw): string return ''; } if (strpos($value, '://') !== false) { + // phpcs:ignore WordPress.WP.AlternativeFunctions.parse_url_parse_url -- Bundled SDK also runs without WordPress; native PHP parsing/serialization preserves its cross-framework contract and has standalone tests. $host = parse_url($value, PHP_URL_HOST); if (is_string($host) && $host !== '') { $value = strtolower($host); diff --git a/sdk/src/Rules/Filter/Parser.php b/sdk/src/Rules/Filter/Parser.php index 012aa76..32d5640 100644 --- a/sdk/src/Rules/Filter/Parser.php +++ b/sdk/src/Rules/Filter/Parser.php @@ -183,7 +183,7 @@ private function primary(): array $path[] = $this->advance()['value']; } - // Function call: req.header("x-api-key") + // Parse a request-header accessor function call. if ($this->match(TokenType::LPAREN)) { $method = array_pop($path); $args = []; diff --git a/sdk/src/SignalCollector.php b/sdk/src/SignalCollector.php index 124d007..ded8944 100644 --- a/sdk/src/SignalCollector.php +++ b/sdk/src/SignalCollector.php @@ -65,7 +65,7 @@ private function sanitizeString(?string $value): string } // Fallback sanitization for non-WordPress environments - $stripped = function_exists('wp_strip_all_tags') ? wp_strip_all_tags(trim($value)) : strip_tags(trim($value)); // phpcs:ignore WordPress.WP.AlternativeFunctions.strip_tags_strip_tags -- guarded fallback for non-WordPress (standalone SDK) use + $stripped = function_exists('wp_strip_all_tags') ? wp_strip_all_tags(trim($value)) : strip_tags(trim($value)); // phpcs:ignore WordPressVIPMinimum.Functions.StripTags.StripTagsOneParameter, WordPress.WP.AlternativeFunctions.strip_tags_strip_tags -- guarded fallback for non-WordPress (standalone SDK) use return htmlspecialchars($stripped, ENT_QUOTES, 'UTF-8'); } diff --git a/templates/block-page.php b/templates/block-page.php index ba74ccc..6ee21d9 100644 --- a/templates/block-page.php +++ b/templates/block-page.php @@ -13,6 +13,14 @@ exit; } +// This response is specific to a visitor and must never enter a shared cache. +nocache_headers(); +$wd_display_ip = filter_var($visitor_ip ?? '', FILTER_VALIDATE_IP) ?: ''; +if ($wd_display_ip === '') { + // phpcs:ignore WordPressVIPMinimum.Variables.ServerVariables.UserControlledHeaders, WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__ -- FILTER_VALIDATE_IP rejects invalid direct-peer addresses before canonicalization/comparison/display; never trust forwarded headers here. Address is validated with FILTER_VALIDATE_IP; used only for proxy safety checks or an explicitly no-cache block response. + $wd_display_ip = filter_var(wp_unslash($_SERVER['REMOTE_ADDR'] ?? ''), FILTER_VALIDATE_IP) ?: ''; +} + // Get options $options = get_option('webdecoy_options', []); // Saved setting key is 'block_page_message' (fall back to legacy 'block_message'). @@ -65,7 +73,7 @@ @@ -88,7 +96,7 @@

- +

diff --git a/tests/HttpTransportTest.php b/tests/HttpTransportTest.php new file mode 100644 index 0000000..494fd48 --- /dev/null +++ b/tests/HttpTransportTest.php @@ -0,0 +1,10 @@ +&1', $output, $status); + TestRunner::assertSame(0, $status, implode("\n", $output)); + }); +} diff --git a/tests/ProxyDetectionTest.php b/tests/ProxyDetectionTest.php index ff7544c..91dd851 100644 --- a/tests/ProxyDetectionTest.php +++ b/tests/ProxyDetectionTest.php @@ -40,6 +40,9 @@ function wp_unslash($s) // phpcs:ignore 'host resolved v4:port' => [['REMOTE_ADDR' => '203.0.113.5', 'HTTP_FORWARDED' => 'for=203.0.113.5:443'], ''], 'unresolved XFF' => [['REMOTE_ADDR' => '10.0.0.2', 'HTTP_X_FORWARDED_FOR' => '203.0.113.5'], 'X-Forwarded-For'], 'unresolved CF' => [['REMOTE_ADDR' => '172.70.1.1', 'HTTP_CF_CONNECTING_IP' => '203.0.113.5', 'HTTP_X_FORWARDED_FOR' => '203.0.113.5'], 'CF-Connecting-IP'], + 'invalid peer' => [['REMOTE_ADDR' => 'not-an-ip', 'HTTP_X_FORWARDED_FOR' => '203.0.113.5'], 'X-Forwarded-For'], + 'array peer' => [['REMOTE_ADDR' => ['203.0.113.5'], 'HTTP_X_FORWARDED_FOR' => '203.0.113.5'], 'X-Forwarded-For'], + 'peer with port' => [['REMOTE_ADDR' => '203.0.113.5:443', 'HTTP_X_FORWARDED_FOR' => '203.0.113.5'], 'X-Forwarded-For'], 'garbage header' => [['REMOTE_ADDR' => '10.0.0.2', 'HTTP_X_FORWARDED_FOR' => 'unknown'], 'X-Forwarded-For'], ]; try { diff --git a/tests/VipReadinessTest.php b/tests/VipReadinessTest.php new file mode 100644 index 0000000..ad749ec --- /dev/null +++ b/tests/VipReadinessTest.php @@ -0,0 +1,10 @@ +&1', $output, $status); + TestRunner::assertSame(0, $status, implode("\n", $output)); + }); +} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 739a837..2c1a71a 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -43,6 +43,11 @@ function __(string $text, string $domain = 'default'): string // phpcs:ignore } } +// Emulate the WordPress URL helper for WP adapter tests; SDK tests still run without WordPress. +if (!function_exists('wp_parse_url')) { + function wp_parse_url($url, $component = -1) { return parse_url($url, $component); } +} + final class TestRunner { /** @var int */ diff --git a/tests/vip/analytics-cache.php b/tests/vip/analytics-cache.php new file mode 100644 index 0000000..fb8d6f7 --- /dev/null +++ b/tests/vip/analytics-cache.php @@ -0,0 +1,50 @@ + $GLOBALS['wd_clock'] ? $entry[0] : false; +} +function wp_cache_set($key, $value, $group, $ttl) { + TestRunner::assertSame(60, $ttl); + $GLOBALS['wd_cache'][$GLOBALS['wd_blog']][$group][$key] = [$value, $GLOBALS['wd_clock'] + $ttl]; +} +function add_filter($hook, $callback, $priority = 10, $args = 1) {} +function add_action($hook, $callback, $priority = 10, $args = 1) {} +function esc_sql($value) { return $value; } +class WD_Stats_DB { + public $prefix = 'wp_'; public $calls = 0; + public function prepare($sql, ...$args) { return $sql; } + public function get_var($sql) { $this->calls++; return 10; } + public function get_results($sql, $type) { $this->calls++; return []; } +} +require dirname(__DIR__, 2) . '/includes/class-webdecoy-detector.php'; +require dirname(__DIR__, 2) . '/includes/class-webdecoy-blocker.php'; +require dirname(__DIR__, 2) . '/includes/class-webdecoy-woocommerce.php'; +foreach (['WebDecoy_Detector', 'WebDecoy_Blocker', 'WebDecoy_WooCommerce'] as $class) { + TestRunner::test($class . ' analytics reuse, expiration and site isolation', function () use ($class) { + global $wpdb; + $wpdb = new WD_Stats_DB(); + $GLOBALS['wd_blog'] = 1; $GLOBALS['wd_cache'] = []; $GLOBALS['wd_clock'] = 0; + $object = (new ReflectionClass($class))->newInstanceWithoutConstructor(); + $expected = $object->get_stats(); + $first = $wpdb->calls; + TestRunner::assertTrue($first > 0); + TestRunner::assertSame($expected, $object->get_stats()); + TestRunner::assertSame($first, $wpdb->calls, 'repeated display avoids all aggregate queries'); + $GLOBALS['wd_blog'] = 2; + $object->get_stats(); + TestRunner::assertSame($first * 2, $wpdb->calls, 'another site cannot reuse the first site cache'); + $GLOBALS['wd_blog'] = 1; + $GLOBALS['wd_clock'] = 61; + $object->get_stats(); + TestRunner::assertSame($first * 3, $wpdb->calls, 'expired presentation data is queried again'); + }); +} +exit(TestRunner::summary()); diff --git a/tests/vip/diagnostics.php b/tests/vip/diagnostics.php new file mode 100644 index 0000000..1f8951b --- /dev/null +++ b/tests/vip/diagnostics.php @@ -0,0 +1,19 @@ +code = $code; } } +function wp_remote_get($url, $args) { $GLOBALS['wd_http_call'] = [$url, $args]; return $GLOBALS['wd_http_result']; } +function wp_remote_post($url, $args) { $GLOBALS['wd_http_call'] = [$url, $args]; return $GLOBALS['wd_http_result']; } +$vip = ($argv[1] ?? '') === 'vip'; +if ($vip) { + function vip_safe_wp_remote_get($url, $fallback, $threshold, $timeout, $retry, $args) { + $GLOBALS['wd_http_vip_call'] = [$url, $fallback, $threshold, $timeout, $retry, $args]; + return $GLOBALS['wd_http_result'] ?? $fallback; + } +} +require dirname(__DIR__, 2) . '/includes/class-webdecoy-http.php'; +$headers = ['Authorization' => 'Bearer test-key', 'Accept' => 'application/json']; +$args = ['headers' => $headers, 'timeout' => 10]; +$GLOBALS['wd_http_result'] = ['response' => ['code' => 403], 'body' => '{"error":"forbidden"}']; +TestRunner::test('HTTP preserves non-success responses and authorization', function () use ($args, $vip, $headers) { + TestRunner::assertSame($GLOBALS['wd_http_result'], WebDecoy_HTTP::get('https://service.invalid/feed', $args)); + if ($vip) { + $call = $GLOBALS['wd_http_vip_call']; + TestRunner::assertSame('https://service.invalid/feed', $call[0]); + TestRunner::assertTrue($call[1] instanceof WP_Error); + TestRunner::assertSame(3, $call[2]); + TestRunner::assertSame(3.0, $call[3]); + TestRunner::assertSame(20, $call[4]); + TestRunner::assertSame($headers, $call[5]['headers']); + TestRunner::assertSame(3.0, $call[5]['timeout']); + TestRunner::assertTrue(!isset($GLOBALS['wd_http_call']), 'VIP must not use the ordinary GET fallback'); + } else { + TestRunner::assertSame(['https://service.invalid/feed', $args], $GLOBALS['wd_http_call']); + } +}); +TestRunner::test('transport failures stay WP_Error, never success-shaped cached data', function () use ($args, $vip) { + $GLOBALS['wd_http_result'] = $vip ? null : new WP_Error('timeout', 'Timeout'); + TestRunner::assertTrue(WebDecoy_HTTP::get('https://service.invalid/feed', $args) instanceof WP_Error); +}); +TestRunner::test('POST preserves one-time exchange body without replay or GET circuit breaking', function () use ($args, $vip) { + $GLOBALS['wd_http_result'] = ['response' => ['code' => 200]]; + $post = $args + ['body' => '{"connect_token":"one-time"}']; + TestRunner::assertSame($GLOBALS['wd_http_result'], WebDecoy_HTTP::post('https://service.invalid/exchange', $post)); + $expected = $post; + if ($vip) { $expected['timeout'] = 3.0; } + TestRunner::assertSame(['https://service.invalid/exchange', $expected], $GLOBALS['wd_http_call']); +}); +if ($vip) { + foreach ([0 => 0.1, 1 => 1.0, 2 => 2.0, 30 => 3.0, 'bad' => 3.0] as $input => $expected) { + TestRunner::test('VIP bounds timeout ' . $input, function () use ($input, $expected) { + WebDecoy_HTTP::get('https://service.invalid/feed', ['timeout' => $input]); + TestRunner::assertSame($expected, $GLOBALS['wd_http_vip_call'][3]); + }); + } +} +exit(TestRunner::summary()); diff --git a/tests/vip/robots-purge.php b/tests/vip/robots-purge.php new file mode 100644 index 0000000..3a078be --- /dev/null +++ b/tests/vip/robots-purge.php @@ -0,0 +1,27 @@ + [$category]]; +TestRunner::test('VIP purges only robots.txt when policy is enabled, changed or removed', function () use ($chosen) { + WebDecoy_Robots_Txt::settings_updated([], $chosen); + WebDecoy_Robots_Txt::settings_updated($chosen, $chosen + ['other_setting' => true]); + WebDecoy_Robots_Txt::settings_updated($chosen, []); + $all = array_merge($GLOBALS['wd_purges'], $GLOBALS['wd_legacy_purges']); + TestRunner::assertSame(['https://site.invalid/robots.txt', 'https://site.invalid/robots.txt'], $all); + if (function_exists('wpvip_purge_edge_cache_for_url')) { + TestRunner::assertSame([], $GLOBALS['wd_legacy_purges'], 'modern function takes precedence'); + } +}); +exit(TestRunner::summary()); diff --git a/uninstall.php b/uninstall.php index b158af7..cf46bfd 100644 --- a/uninstall.php +++ b/uninstall.php @@ -13,6 +13,8 @@ exit; } +global $wpdb; + // Load the activator class if not already loaded $activator_file = __DIR__ . '/includes/class-webdecoy-activator.php'; if (file_exists($activator_file)) { @@ -24,7 +26,6 @@ } } else { // Fallback: manually clean up if activator not available - global $wpdb; // Drop custom tables $tables = [ @@ -39,7 +40,7 @@ ]; foreach ($tables as $table) { - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Table name is safe, built from $wpdb->prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Table name is safe, built from $wpdb->prefix $wpdb->query("DROP TABLE IF EXISTS {$table}"); } @@ -65,15 +66,16 @@ } // Delete all transients with webdecoy_ prefix -global $wpdb; // Delete transients from options table +// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result. $wpdb->query( - "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%_transient_webdecoy_%'" + $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_webdecoy_') . '%') ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery +// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result. $wpdb->query( - "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%_transient_timeout_webdecoy_%'" + $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_timeout_webdecoy_') . '%') ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery // For multisite, clean up each site @@ -96,7 +98,7 @@ ]; foreach ($tables as $table) { - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Table name is safe, built from $wpdb->prefix + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Table name is safe, built from $wpdb->prefix $wpdb->query("DROP TABLE IF EXISTS {$table}"); } @@ -117,15 +119,17 @@ wp_clear_scheduled_hook('webdecoy_sync_blocked_ips'); wp_clear_scheduled_hook('webdecoy_sync_entitlements'); wp_clear_scheduled_hook('webdecoy_sync_actor_feed'); - wp_clear_scheduled_hook('webdecoy_flush_ai_referrals'); + wp_clear_scheduled_hook('webdecoy_flush_ai_referrals'); // Delete transients for this site + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result. $wpdb->query( - "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%_transient_webdecoy_%'" + $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_webdecoy_') . '%') ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Explicit uninstall cleanup of plugin-owned tables/transients; mutation cannot use a cached result. $wpdb->query( - "DELETE FROM {$wpdb->options} WHERE option_name LIKE '%_transient_timeout_webdecoy_%'" + $wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like('_transient_timeout_webdecoy_') . '%') ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery restore_current_blog(); diff --git a/webdecoy.php b/webdecoy.php index 090b9c4..805237c 100644 --- a/webdecoy.php +++ b/webdecoy.php @@ -50,6 +50,7 @@ function str_starts_with(string $haystack, string $needle): bool // Code-level configuration (wp-config.php constants). Loaded before anything // reads options, because WEBDECOY_DEFAULT_MODE participates in load_options(). require_once WEBDECOY_PLUGIN_DIR . 'includes/class-webdecoy-runtime-config.php'; +require_once WEBDECOY_PLUGIN_DIR . 'includes/class-webdecoy-diagnostics.php'; // Load the SDK (bundled) $sdk_paths = [ @@ -1267,7 +1268,7 @@ public function early_check(): void try { $this->submit_detection($result, $ip); } catch (\Exception $e) { - error_log('WebDecoy API error: ' . $e->getMessage()); + WebDecoy_Diagnostics::report('api_error'); } } @@ -1422,9 +1423,11 @@ public function register_wp_traps(): void public function record_synthetic_tripwire(string $rule, string $path, string $trap_kind = ''): void { $ip = $this->get_client_ip(); + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. $ua = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : ''; $clearance = null; if ($rule === 'tripwire' && isset($_COOKIE['wd_clearance'])) { + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE -- Sanitized clearance token is reported with this trap event; it is not rendered into cached content. $clearance = sanitize_text_field(wp_unslash($_COOKIE['wd_clearance'])); } @@ -1518,6 +1521,7 @@ private function build_rule_context(string $ip): \WebDecoy\Rules\RuleContext ? sanitize_text_field(wp_unslash($_SERVER['REQUEST_METHOD'])) : 'GET'; $userAgent = isset($_SERVER['HTTP_USER_AGENT']) + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : ''; @@ -1784,8 +1788,10 @@ private function log_decoy_served(string $path, string $ip, array $canaries): vo ], ]; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($wpdb->prefix . 'webdecoy_detections', [ 'ip_address' => $ip, + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'score' => 100, 'threat_level' => \WebDecoy\DetectionResult::THREAT_HIGH, @@ -1829,6 +1835,7 @@ private function log_rule_violations(array $violations): void ), ]; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($wpdb->prefix . 'webdecoy_detections', [ 'ip_address' => $violation->ip, 'user_agent' => $violation->userAgent ?? '', @@ -1905,13 +1912,19 @@ private function handle_blocking(\WebDecoy\DetectionResult $result, string $ip): */ private function is_challenge_verified(string $ip): bool { + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___COOKIE -- HMAC-matched clearance affects only this request; successful verification calls nocache_headers before continuing. $cookie = isset($_COOKIE['webdecoy_verified']) ? sanitize_text_field(wp_unslash($_COOKIE['webdecoy_verified'])) : ''; if (empty($cookie)) { return false; } $stored = get_transient('webdecoy_verified_' . md5($ip)); - return $stored !== false && hash_equals($stored, $cookie); + $verified = $stored !== false && hash_equals($stored, $cookie); + if ($verified) { + // A clearance-dependent response must not be reused for another visitor. + nocache_headers(); + } + return $verified; } /** @@ -1956,6 +1969,8 @@ private function block_request(string $message): void header('Expires: Thu, 01 Jan 1970 00:00:00 GMT'); if ($this->options['show_block_page']) { + // Display the same trusted-proxy-aware address used for enforcement. + $visitor_ip = $this->get_client_ip(); status_header(403); include WEBDECOY_PLUGIN_DIR . 'templates/block-page.php'; exit; @@ -1982,13 +1997,15 @@ private function log_detection(\WebDecoy\DetectionResult $result, string $ip): v 'metadata' => $result->getMetadata(), ]; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $ip, + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'score' => $result->getScore(), 'threat_level' => $result->getThreatLevel(), 'source' => 'wordpress_plugin', - 'flags' => json_encode($flags_data), + 'flags' => wp_json_encode($flags_data), 'created_at' => gmdate('Y-m-d H:i:s'), ]); @@ -2014,7 +2031,7 @@ private function submit_detection(\WebDecoy\DetectionResult $result, string $ip) $detection = \WebDecoy\Detection::fromArray([ 'scanner_id' => $this->get_scanner_id(), 'ip_address' => $ip, - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Used for logging only + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Used for logging only 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'url' => $this->get_current_url(), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Used for logging only @@ -2061,7 +2078,7 @@ private function get_detection_client(): ?\WebDecoy\Client 'timeout' => 3, ]); } catch (\Exception $e) { - error_log('WebDecoy client error: ' . $e->getMessage()); + WebDecoy_Diagnostics::report('client_error'); return null; } } @@ -2075,6 +2092,7 @@ private function is_test_trigger_request(): bool if (!isset($_SERVER['HTTP_USER_AGENT'])) { return false; } + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Reserved setup probe produces an explicit no-cache 403 receipt; does not personalize shared page content. $ua = ltrim(sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT']))); return stripos($ua, 'WebDecoy-Test/') === 0; } @@ -2099,20 +2117,22 @@ private function handle_test_trigger(string $ip): void // Local log, inlined rather than via log_detection(): that path also // queues the critical-moment alert for CRITICAL rows, and a test must // not page anyone. + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($wpdb->prefix . 'webdecoy_detections', [ 'ip_address' => $ip, + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'score' => $result->getScore(), 'threat_level' => $result->getThreatLevel(), 'source' => 'wordpress_plugin', - 'flags' => json_encode(['flags' => $result->getFlags(), 'metadata' => ['test' => true]]), + 'flags' => wp_json_encode(['flags' => $result->getFlags(), 'metadata' => ['test' => true]]), 'created_at' => gmdate('Y-m-d H:i:s'), ]); try { $this->submit_detection($result, $ip); } catch (\Exception $e) { - error_log('WebDecoy API error: ' . $e->getMessage()); + WebDecoy_Diagnostics::report('api_error'); } nocache_headers(); @@ -2194,8 +2214,10 @@ public function check_canary_login($user, string $username, string $password) $ip = $this->get_client_ip(); global $wpdb; + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($wpdb->prefix . 'webdecoy_detections', [ 'ip_address' => $ip, + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__ -- Sanitized UA is PHP-request detection/audit context, not proof of identity; cache hits that bypass PHP are explicitly outside coverage. 'user_agent' => isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : '', 'score' => 100, 'threat_level' => \WebDecoy\DetectionResult::THREAT_CRITICAL, @@ -2814,7 +2836,7 @@ public function inject_js_verification_token(): void $collector = new \WebDecoy\SignalCollector($this->get_trusted_proxies()); $ip = $collector->getIP(); - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized + // phpcs:ignore WordPressVIPMinimum.Variables.RestrictedVariables.cache_constraints___SERVER__HTTP_USER_AGENT__, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? sanitize_text_field(wp_unslash($_SERVER['HTTP_USER_AGENT'])) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized @@ -2959,6 +2981,7 @@ private function log_client_detection(array $detection, string $ip): void $threat_level = 'LOW'; } + // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery -- Persist a security event or state mutation in a plugin-owned table; a cached result cannot replace this write. $wpdb->insert($table, [ 'ip_address' => $ip, 'user_agent' => $user_agent, @@ -2989,7 +3012,7 @@ private function forward_to_ingest(array $detection, string $ip): void } if (empty($api_key)) { - error_log('WebDecoy: Cannot forward to ingest - API key not configured'); + WebDecoy_Diagnostics::report('ingest_unconfigured'); return; } @@ -3032,7 +3055,7 @@ private function forward_to_ingest(array $detection, string $ip): void 'Content-Type' => 'application/json', 'Authorization' => 'Bearer ' . $api_key, ], - 'body' => json_encode($payload), + 'body' => wp_json_encode($payload), ]); } @@ -3273,6 +3296,7 @@ public function ajax_pow_challenge(): void */ public function ajax_pow_verify(): void { + nocache_headers(); check_ajax_referer('webdecoy_pow', '_wpnonce'); $ip = $this->get_client_ip(); @@ -3325,7 +3349,14 @@ public function ajax_pow_verify(): void set_transient('webdecoy_verified_' . md5($ip), $cookie_value, $duration); // Set cookie on client - setcookie('webdecoy_verified', $cookie_value, time() + $duration, '/', '', is_ssl(), true); + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.cookies_setcookie -- Verified AJAX response is explicitly no-cache; this is an HttpOnly clearance cookie, never shared page content. + setcookie('webdecoy_verified', $cookie_value, [ + 'expires' => time() + $duration, + 'path' => '/', + 'secure' => is_ssl(), + 'httponly' => true, + 'samesite' => 'Lax', + ]); wp_send_json_success(['message' => __('Verified successfully.', 'webdecoy')]); } @@ -3343,7 +3374,7 @@ public function get_client(): ?\WebDecoy\Client 'api_key' => $this->options['api_key'], ]); } catch (\Exception $e) { - error_log('WebDecoy client error: ' . $e->getMessage()); + WebDecoy_Diagnostics::report('client_error'); return null; } }