@@ -5,6 +5,198 @@ All notable changes to this project will be documented in this file.
55The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
66and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
77
8+ ## [ 1.0.69] - 2026-01-01
9+
10+ ### Added
11+ - ** Pattern Library JSON Files** - Created 3 new pattern definition files
12+ - ` dist/patterns/unsanitized-superglobal-read.json ` - Direct superglobal access without sanitization (HIGH severity)
13+ - ` dist/patterns/wpdb-query-no-prepare.json ` - Database queries without prepare() (CRITICAL severity)
14+ - ` dist/patterns/get-users-no-limit.json ` - Unbounded user queries (CRITICAL severity)
15+ - ** Purpose:** Separate pattern definitions from scanner logic for modularity and community contributions
16+ - ** Schema:** Each includes detection logic, test fixtures, IRL examples, remediation guidance, references
17+ - ** IRL Examples:** All 3 patterns include real-world examples from WP Activity Log v5.5.4
18+ - ** Total Patterns:** 4 JSON files (including existing ` unsanitized-superglobal-isset-bypass.json ` )
19+
20+ - ** WP Activity Log IRL Examples** - 3 annotated files from production security plugin
21+ - ` dist/tests/irl/wp-security-audit-log/class-select2-wpws-irl.php ` (530 lines)
22+ - 2 unbounded get_users() violations (lines 230, 444)
23+ - AJAX user search without limits - can crash sites with 10k+ users
24+ - ` dist/tests/irl/wp-security-audit-log/class-wp-security-audit-log-irl.php ` (1,517 lines)
25+ - 1 unsanitized superglobal read (line 1261)
26+ - Type juggling vulnerability in plugin visibility control
27+ - ` dist/tests/irl/wp-security-audit-log/class-migration-irl.php ` (1,527 lines)
28+ - 1 direct database query without prepare() (line 226)
29+ - SQL injection risk in migration function
30+ - ** Total:** 3,574 lines of annotated production code
31+ - ** Detection Rate:** 100% - Scanner found all 3 documented violations plus 57 additional issues
32+ - ** Summary Document:** ` PROJECT/WP-SECURITY-AUDIT-LOG-IRL-SUMMARY.md `
33+
34+ ### Changed
35+ - ** Pattern JSON Files:** Now 4 total pattern definitions (was 1)
36+ - Existing: ` unsanitized-superglobal-isset-bypass.json ` (isset-bypass variant)
37+ - New: ` unsanitized-superglobal-read.json ` (direct read variant)
38+ - New: ` wpdb-query-no-prepare.json ` (SQL injection)
39+ - New: ` get-users-no-limit.json ` (performance)
40+ - ** Note:** These are distinct patterns, not duplicates
41+
42+ ### Documentation
43+ - ** Pattern JSON Schema:** Each file includes:
44+ - Pattern ID, version, severity, category
45+ - Detection logic (grep patterns, exclusions, post-processing)
46+ - Test fixture path and expected violation counts
47+ - IRL examples with file, line, plugin, code, context, risk assessment
48+ - Remediation examples (bad vs good code)
49+ - References to WordPress documentation
50+ - Performance impact analysis (for performance patterns)
51+ - False positive guidance
52+
53+ ## [ 1.0.68] - 2026-01-01
54+
55+ ### Added
56+ - ** IRL (In Real Life) Examples System** - Real-world code examples from production plugins/themes
57+ - ** Purpose:** Validate patterns exist in production, discover new anti-patterns, document real vulnerabilities
58+ - ** Structure:** ` dist/tests/irl/plugin-name/filename-irl.php ` with inline audit annotations
59+ - ** Filename Conventions:**
60+ - ` -irl.php ` = Fully audited with annotations and pattern library updated
61+ - ` -inbox.php ` = Quick capture for later processing (no annotations yet)
62+ - ** Annotation Format:** File header summary + inline comments at each anti-pattern
63+ - ** Examples Added:**
64+ - WooCommerce All Products for Subscriptions v6.0.6 - ` class-wcs-att-admin-irl.php ` (1 violation)
65+ - KISS Woo Coupon Debugger v2.1.0 - ` AdminUI-irl.php ` (2 violations)
66+ - ** User-Submitted Code:** Users can copy PHP/JS files from their own projects for AI analysis
67+ - ** Documentation:** ` dist/tests/irl/README.md ` and ` dist/tests/irl/_AI_AUDIT_INSTRUCTIONS.md `
68+
69+ - ** Baseline Files Generated** - Suppress known issues for ongoing monitoring
70+ - KISS Debugger: 22 findings baselined
71+ - WooCommerce All Products for Subscriptions: 73 findings baselined
72+ - Purpose: Track new issues without noise from existing known issues
73+
74+ - ** Pattern Library Separation (Integrated!)** - First pattern now loads from JSON
75+ - ** Pattern Definitions:** JSON files in ` dist/patterns/ ` directory
76+ - ** Pattern Loader:** ` dist/lib/pattern-loader.sh ` - Bash library to load patterns from JSON
77+ - ** First Pattern:** ` unsanitized-superglobal-isset-bypass.json ` with full metadata
78+ - ** Schema:** Pattern ID, version, severity, detection logic, test fixtures, IRL examples, remediation
79+ - ** Integration:** Scanner now loads ` unsanitized-superglobal-isset-bypass ` pattern from JSON (line 1529-1540)
80+ - ** Fallback:** If JSON not found, falls back to hardcoded values (graceful degradation)
81+ - ** Benefits:** Modularity, versioning, easier testing, community contributions
82+ - ** Status:** ✅ Integrated - one pattern using JSON, remaining 32 patterns still hardcoded
83+
84+ ### Changed
85+ - ** Pattern JSON:** Updated ` unsanitized-superglobal-isset-bypass.json ` with 3 IRL examples
86+ - WooCommerce All Products for Subscriptions: Line 451 (isset bypass in admin scripts)
87+ - KISS Debugger: Line 434 (boolean cast without sanitization)
88+ - KISS Debugger: Line 472 (string comparison without sanitization)
89+ - Each includes: plugin name, version, context, original line number
90+ - ** Gitignore:** Added rules for IRL folder
91+ - Keeps: ` dist/tests/irl/ ` , ` README.md ` , ` _AI_AUDIT_INSTRUCTIONS.md ` , ` .gitkeep `
92+ - Ignores: All user-created IRL example files (may contain proprietary code)
93+ - Rationale: Users can collect real-world examples without committing them to public repo
94+
95+ ### Fixed
96+ - ** Version Number:** Updated SCRIPT_VERSION to 1.0.68 (was showing 1.0.66)
97+ - ** Bash Error:** Removed ` local ` keyword outside function (line 434) - was causing error on script start
98+
99+ ## [ 1.0.67] - 2026-01-01
100+
101+ ### Fixed
102+ - ** CRITICAL BUG: Path Quoting in Grep Commands** - Fixed all 16 grep commands to properly quote ` $PATHS ` variable
103+ - ** Impact:** Scanner was completely broken for any project path containing spaces (e.g., ` /Users/name/Local Sites/project/ ` )
104+ - ** Root Cause:** Unquoted ` $PATHS ` variable caused shell to split paths on spaces, breaking grep searches
105+ - ** Affected Checks:** ALL pattern-based checks (unsanitized superglobals, SQL injection, N+1 queries, etc.)
106+ - ** Fix:** Added quotes around all ` $PATHS ` references in grep commands: ` $PATHS ` → ` "$PATHS" `
107+ - ** Verification:** Tested with WooCommerce All Products for Subscriptions plugin in path with spaces - now correctly detects 7 errors + 1 warning (previously reported 0 issues)
108+ - ** Files Changed:** ` dist/bin/check-performance.sh ` (lines 1373, 1541, 1647, 1719, 1798, 1862, 1926, 1987, 2057, 2122, 2188, 2228, 2272, 2627, 2676, 2759)
109+ - ** Safeguards Added:** Inline comments at each grep command referencing SAFEGUARDS.md to prevent future regressions
110+
111+ ### Improved
112+ - ** Enhanced Pattern: Unsanitized Superglobal Read** - Now catches ` isset() ` bypass pattern
113+ - ** Pattern:** ` isset( $_GET['x'] ) && $_GET['x'] === 'value' ` (isset check + direct usage on same line)
114+ - ** Detection Logic:** Counts superglobal occurrences per line - skips if only 1 occurrence with isset/empty (existence check), reports if 2+ occurrences (isset + usage)
115+ - ** Example Violations Found:**
116+ - ` isset( $_GET['tab'] ) && $_GET['tab'] === 'subscriptions' ` (line 451, class-wcs-att-admin.php)
117+ - ` isset( $_GET['switch-subscription'] ) && isset( $_GET['item'] ) ` (line 86, class-wcs-att-manage-switch.php)
118+ - ` ! empty( $_REQUEST['add-to-cart'] ) && is_numeric( $_REQUEST['add-to-cart'] ) ` (line 108, class-wcs-att-manage-switch.php)
119+ - ** Test Fixture:** ` dist/tests/fixtures/unsanitized-superglobal-isset-bypass.php ` (5 violations, 6 valid examples)
120+
121+ ### Added
122+ - ** SAFEGUARDS.md** - Critical implementation safeguards documentation
123+ - ** Purpose:** Prevent catastrophic regressions by documenting critical implementation details that must not be changed
124+ - ** Contents:**
125+ - Path variable quoting rules (with line numbers for all 16 affected grep commands)
126+ - isset() bypass detection logic explanation
127+ - Version increment checklist
128+ - Critical test cases for verification
129+ - Debugging guide for silent failures
130+ - ** Inline References:** Added safeguard comments at all 16 grep commands pointing to SAFEGUARDS.md
131+
132+ ## [ 1.0.66] - 2026-01-01
133+
134+ ### Added
135+ - ** Enhancement #10 : WooCommerce N+1 Query Patterns** - Detects WC-specific N+1 performance issues
136+ - ** Rule ID:** ` wc-n-plus-one-pattern `
137+ - ** Severity:** HIGH (customizable via severity config)
138+ - ** Category:** performance
139+ - ** Rationale:** WooCommerce functions called inside loops cause query multiplication (100 orders × 3 meta queries = 300 queries per page)
140+ - ** Detection:** Finds ` wc_get_order() ` , ` wc_get_product() ` , ` get_post_meta() ` , ` get_user_meta() ` , ` ->get_meta() ` called inside loops over WC orders/products
141+ - ** Test Fixture:** Added ` dist/tests/fixtures/wc-n-plus-one.php ` with examples of violations and valid code (pre-fetching, caching)
142+
143+ ### Changed
144+ - ** Check Count:** Increased from 32 to 33 checks (+1 new WooCommerce-specific check)
145+ - ** Documentation:** Updated README files to reflect new check and count
146+ - ** Severity Config:** Updated ` severity-levels.json ` to include new rule ID
147+
148+ ## [ 1.0.65] - 2026-01-01
149+
150+ ### Added
151+ - ** Enhanced Pattern #2 : Admin Functions Without Capability Checks** - Expanded detection coverage
152+ - ** Rule ID:** ` admin-no-capability-check `
153+ - ** Severity:** HIGH (customizable via severity config)
154+ - ** Enhancement:** Now detects ` add_menu_page ` , ` add_submenu_page ` , ` add_options_page ` , and ` add_management_page ` callbacks missing capability checks (in addition to existing AJAX handler detection)
155+ - ** Test Fixture:** Added ` dist/tests/fixtures/admin-no-capability.php ` with examples of violations and valid code
156+
157+ - ** New Pattern #5 : WooCommerce Subscriptions Queries Without Limits** - Prevents performance issues
158+ - ** Rule ID:** ` wcs-get-subscriptions-no-limit `
159+ - ** Severity:** MEDIUM (customizable via severity config)
160+ - ** Category:** performance
161+ - ** Rationale:** WooCommerce Subscriptions functions should include 'limit' parameter to prevent performance degradation with large subscription counts
162+ - ** Detection:** Finds ` wcs_get_subscriptions ` , ` wcs_get_subscriptions_for_order ` , ` wcs_get_subscriptions_for_product ` , ` wcs_get_subscriptions_for_user ` called without 'limit' parameter
163+ - ** Test Fixture:** Added ` dist/tests/fixtures/wcs-no-limit.php ` with examples of violations and valid code
164+
165+ ### Changed
166+ - ** Check Count:** Increased from 31 to 32 checks (+1 new check, +1 enhanced check)
167+ - ** Documentation:** Updated README files to reflect new checks and count
168+ - ** Severity Config:** Updated ` severity-levels.json ` to include new rule ID
169+
170+ ## [ 1.0.64] - 2026-01-01
171+
172+ ### Added
173+ - ** New Check: Direct Database Queries Without $wpdb->prepare()** - Detects SQL injection vulnerabilities
174+ - ** Rule ID:** ` wpdb-query-no-prepare `
175+ - ** Severity:** CRITICAL (customizable via severity config)
176+ - ** Category:** security
177+ - ** Rationale:** All database queries using ` $wpdb->query ` , ` get_var ` , ` get_row ` , ` get_results ` , or ` get_col ` must use ` $wpdb->prepare() ` to prevent SQL injection attacks
178+ - ** Detection:** Finds direct database calls without ` $wpdb->prepare() ` in the same statement
179+ - ** Test Fixture:** Added ` dist/tests/fixtures/wpdb-no-prepare.php ` with examples of violations and valid code
180+
181+ - ** New Check: Unsanitized Superglobal Read** - Detects XSS and parameter tampering vulnerabilities
182+ - ** Rule ID:** ` unsanitized-superglobal-read `
183+ - ** Severity:** HIGH (customizable via severity config)
184+ - ** Category:** security
185+ - ** Rationale:** All access to ` $_GET ` , ` $_POST ` , and ` $_REQUEST ` must be sanitized using WordPress functions to prevent XSS and parameter tampering
186+ - ** Detection:** Finds direct superglobal access without sanitization wrappers (` sanitize_* ` , ` esc_* ` , ` absint ` , ` intval ` , ` wc_clean ` , ` wp_unslash ` , ` isset ` , ` empty ` )
187+ - ** Test Fixture:** Added ` dist/tests/fixtures/unsanitized-superglobal-read.php ` with examples of violations and valid code
188+
189+ ### Changed
190+ - ** Check Count:** Increased from 29 to 31 checks (+2 new security checks)
191+ - ** Documentation:** Updated README files to reflect new checks and count
192+ - ** Severity Config:** Updated ` severity-levels.json ` to include new rule IDs
193+
194+ ### Technical Details
195+ - Both checks use custom implementation (not ` run_check ` function) to support complex filtering logic
196+ - Implements allowlist patterns to reduce false positives (e.g., ` isset ` , ` empty ` , sanitization functions)
197+ - Follows the same pattern as admin capability check (manual grep → filter → display → count)
198+ - Correctly excludes comments and safe patterns from detection
199+
8200## [ 1.0.63] - 2025-12-31
9201
10202### Added
0 commit comments