Skip to content

Commit aadf7d3

Browse files
committed
feat(ast): add hook argument mismatch detection and docs updates
1 parent e7bc40b commit aadf7d3

6 files changed

Lines changed: 781 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file.
44

55
## [Unreleased]
66

7+
### Added
8+
9+
- AST hook analysis: new `HookRegistrationVisitor` (`dist/bin/ast/HookRegistrationVisitor.php`) extracts `add_action`, `add_filter`, `do_action`, `apply_filters`, `remove_action`, and `remove_filter` calls from the AST, along with function/method parameter counts for cross-referencing
10+
- New AST rule `hook-arg-mismatch` with three checks:
11+
- `arg_count`: detects callbacks that require more parameters than `accepted_args` will provide, or define extra parameters that will never receive values
12+
- `priority_conflict`: flags multiple different callbacks registered on the same hook at the same priority within the scanned codebase
13+
- `fire_arg_count`: detects `do_action`/`apply_filters` fire points that pass fewer arguments than registered callbacks expect
14+
- New AST rule `hook-inventory`: outputs all hook registrations and fire points found in scanned files, sorted by hook name and priority — no findings, just structured data for audit and exploration
15+
- Test fixture `dist/tests/fixtures/ast-hook-mismatch.php` covering all three hook-arg-mismatch checks including class-based `[$this, 'method']` callbacks
16+
- Example config `dist/bin/ast/config/hook-arg-mismatch.example.json` with `target_hooks` and `checks` options
17+
718
### Changed
819

920
- Admin-only hook whitelist for `spo-004-missing-cap-check`: `add_action()` calls using inherently-admin-only hooks (`admin_notices`, `admin_init`, `admin_menu`, `admin_head`, `admin_footer`, `admin_enqueue_scripts`, `admin_print_styles`, `admin_print_scripts`, `network_admin_menu`, `user_admin_menu`, `network_admin_notices`, `admin_bar_init`, `admin_action_*`, `load-*`) are now downgraded to INFO severity instead of HIGH, reducing false positives for capability check findings

ask_self/WPCC-AI-DDTK-INTEGRATION.md

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ the current and planned architecture.
8686
│ ┌─────────────────── Step 4: Runtime Verification (optional) ────────────┐ │
8787
│ │ (requires running WP site) │ │
8888
│ │ │ │
89+
│ │ ┌───────────────────────────────────────────────────────────────────┐ │ │
90+
│ │ │ Playwright + Passwordless Login (pw_auth) │ │ │
91+
│ │ │ │ │ │
92+
│ │ │ mu-plugin auto-login · no credentials in agent context │ │ │
93+
│ │ │ Authenticated page loads at near-manual-operator quality │ │ │
94+
│ │ │ Drives all runtime tools below (QM, HookTrace, DOM checks) │ │ │
95+
│ │ └───────────────────────────────────────────────────────────────────┘ │ │
96+
│ │ │ authenticated browser sessions │ │
97+
│ │ ▼ │ │
8998
│ │ ┌─────────────────────┐ ┌──────────────────────┐ │ │
9099
│ │ │ Query Monitor │ │ HookTrace │ │ │
91100
│ │ │ │ │ │ │ │
@@ -113,9 +122,9 @@ the current and planned architecture.
113122
│ ┌───────────────────────────────────────────────────────────────────────────┐ │
114123
│ │ MCP Server (26 tools) │ │
115124
│ │ │ │
116-
│ │ local_wp_* · wpcc_* · qm_* · pw_auth_* · tmux_* │ │
117-
│ │ ask_self_query · ask_self_review · wpcc_ast_check │ │
118-
│ │ hooktrace_* (planned) │ │
125+
│ │ pw_auth_* (passwordless login) · qm_* (profiling) · wpcc_* (scan) │ │
126+
│ │ local_wp_* (site mgmt) · tmux_* (sessions) · wpcc_ast_check │ │
127+
│ │ ask_self_query · ask_self_review · hooktrace_* (planned) │ │
119128
│ └───────────────────────────────────────────────────────────────────────────┘ │
120129
│ │
121130
└─────────────────────────────────────────────────────────────────────────────────┘
@@ -142,18 +151,20 @@ COMPONENT OWNERSHIP
142151
│ │ │ │ │ │
143152
│ · Scanner │ │ · RAG engine │ │ · MCP server │
144153
│ · 54 grep │ │ · Ingest │ │ · Loop ctrl │
145-
│ patterns │ │ · Query │ │ · QM bridge │
146-
│ · Semgrep │ │ · Review │ │ · HookTrace │
147-
│ rules │ │ (planned) │ │ bridge │
148-
│ · AST checker│ │ · Harness │ │ (planned) │
149-
│ · Pattern │ │ config │ │ · Playwright │
150-
│ library │ │ · System │ │ auth │
151-
│ │ │ instruct. │ │ · LocalWP │
154+
│ patterns │ │ · Query │ │ · Playwright │
155+
│ · Semgrep │ │ · Review │ │ + password-│
156+
│ rules │ │ (planned) │ │ less login │
157+
│ · AST checker│ │ · Harness │ │ mu-plugin │
158+
│ · Pattern │ │ config │ │ · QM bridge │
159+
│ library │ │ · System │ │ · HookTrace │
160+
│ │ │ instruct. │ │ (planned) │
161+
│ │ │ │ │ · LocalWP │
152162
│ │ │ │ │ · Recipes │
153163
└──────┬───────┘ └──────┬───────┘ └──────┬───────┘
154164
│ │ │
155165
│ detection │ understanding │ orchestration
156-
│ + structure │ + enrichment │ + runtime
166+
│ + structure │ + enrichment │ + runtime +
167+
│ │ │ auth
157168
│ │ │
158169
└───────────────────┴───────────────────┘
159170

0 commit comments

Comments
 (0)