[personal-wp] Ask before applying blueprints to your site#3195
Draft
[personal-wp] Ask before applying blueprints to your site#3195
Conversation
9f8eaa3 to
41ba1a3
Compare
Enhances the blueprint confirmation system with: - TypeScript-based PHP tokenizer for static analysis - Detection of dangerous function calls (eval, system, curl, etc.) - Detection of variable function calls ($func()) - Detection of superglobal access ($_GET, $_POST, etc.) - Detection of backtick shell execution - File content analysis for malicious patterns - Comprehensive test suite (152 tests) Removes data:application/json;base64 URLs from trusted sources as they can contain arbitrary content like inline hash fragments.
- Add source property to BlueprintResolvedFromUrl interface - Update resolveUrlParamsForExistingSite to return both blueprint and source - Fix type error in analyzer by removing redundant token type checks This fixes a runtime TypeError when accessing urlBlueprint.source.type where source was undefined because it wasn't being passed through the URL resolution pipeline.
- For remote URLs: display the URL - For inline/data URLs: show expandable "View blueprint contents" section - Format blueprint JSON for readability
- Add severity icons to steps that have warnings in the overview - Fix cancel to properly reject blueprint, clear URL params, and boot without it - Remove focus border from modal - Hide "Steps" separator line when no properties are shown above - Remove confusing "no recognized operations" message - Fix TypeScript types (use BlueprintV1Declaration)
- Wrap case block with lexical declaration in braces - Remove unnecessary escape characters in regex patterns - Remove unused imports
faded1b to
0dbe893
Compare
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.
Motivation for the change, related issues
Adds a security confirmation system for blueprints applied to persistent WordPress installations. When a user has an existing WordPress site and tries to apply an external blueprint, they should be warned about what the blueprint will do before it executes.
Screenshots
Security Concerns Addressed
runPHPsteps can execute any PHP codeTrust Model
Blueprints from these sources bypass confirmation:
https://raw.githubusercontent.com/WordPress/blueprints/- Official blueprints repohttps://wordpress.org/plugins/wp-json/plugins/v1/plugin- WordPress.org plugin API?plugin=friendsstyle query params (type: 'none') - Resolves to wordpress.orgNot trusted (requires confirmation):
data:application/json;base64,...URLs - Can contain arbitrary content#{...}Implementation details
Architecture
Rule-based Analysis System
run-phprunPHP,runPHPWithOptionsstepsfilesystem-operationswriteFile,rm,mkdir, etc.external-plugin-sourceinstallPluginstepsexternal-theme-sourceinstallThemestepswp-cliwp-clistepsrequestPHP Tokenizer (TypeScript)
Custom synchronous tokenizer that parses PHP code:
PHP Code Analysis
Detects dangerous patterns:
eval,system,exec,shell_exec,curl_exec,fsockopen, variable function calls ($func())file_get_contents,base64_decode,wp_remote_get,wp_insert_user, superglobals ($_GET,$_POST)phpinfo,update_option,getenvFile Content Analysis
Analyzes
writeFilestep content:eval(base64_decode(...)))Test Coverage
152 unit tests covering:
Testing Instructions (or ideally a Blueprint)
Run the test suite:
npx nx test playground-personal-wp --testFile=blueprint-confirmationManual testing: