Update rules to align with WordPress Coding Standards 3.4.0/3.4.1 - #2
Open
ai-anant wants to merge 2 commits into
Open
Update rules to align with WordPress Coding Standards 3.4.0/3.4.1#2ai-anant wants to merge 2 commits into
ai-anant wants to merge 2 commits into
Conversation
Changes based on WPCS v3.4.0 (2026-07-14) and v3.4.1 security release (2026-07-27):
1. Add WP 7.0.0 deprecated functions to deprecated.yaml
- addslashes_gpc() -> wp_slash()
- block_core_navigation_block_contains_core_navigation()
-> block_core_navigation_block_tree_has_block_type()
- wp_sanitize_script_attributes()
-> wp_get_script_tag() or wp_get_inline_script_tag()
2. New rule: silenced-errors/parse_url.yaml
- WPCS 3.4.0 removed parse_url() from the allowed error suppression list
- Flags @parse_url() usage
- Also includes @unserialize() detection
3. Enqueued-resources.yaml: add user-controlled version param rule
- Detects user input (//) in
wp_enqueue_script() and wp_enqueue_style() version params
- Related to EnqueuedResourceParametersSniff security advisory (GHSA-3pwp-g2mj-5p3v)
- Fix inline_script_tag/inline_style_tag: patterns were using unterminated PHP string literals and HTML-entity-corrupted versions, both non-functional. Switched to pattern-regex for <script and <link detection. - Fix enqueued-resources message: user input in ANY argument position is detected (not just version param), so message now reflects that. - Fix @unserialize rule: WPCS still allows it in its suppression list; added notes field documenting this is defense-in-depth. - Remove duplicate get_user_by_email pattern in deprecated.yaml (pre-existing)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Updates semgrep rules to align with the recent WordPress Coding Standards v3.4.0 (released 2026-07-14) and v3.4.1 (security release 2026-07-27).
Changes Made
1. New WP 7.0.0 deprecated functions (
deprecated.yaml)Added the three functions deprecated in WordPress 7.0.0 per WPCS v3.4.0:
addslashes_gpc()wp_slash()block_core_navigation_block_contains_core_navigation()block_core_navigation_block_tree_has_block_type()wp_sanitize_script_attributes()wp_get_script_tag()/wp_get_inline_script_tag()2. New rule:
@parse_url()error suppression (silenced-errors/parse_url.yaml)WPCS v3.4.0 removed
parse_url()from the NoSilencedErrors allowed list, meaning@parse_url()is now flagged. Also includes@unserialize()detection.3. User-controlled version parameters in enqueued resources (
enqueued-resources.yaml)Related to the GHSA-3pwp-g2mj-5p3v security advisory fixed in v3.4.1. Detects user input in
wp_enqueue_script()/wp_enqueue_style()version parameters.Validation
semgrep --validate— zero errors