Repository navigation
Limit the stored rows of an unpublished post-type chart to users who can read the post type - #1430
Conversation
…sers who can read every post of the type Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…tor reads Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…nual editor Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The new rule still lets refused users read the rows through revision diffs and saved chart images, and a crafted upload skips the refusal.
classes/Visualizer/Module/Chart.php:1763-1811—securityThe saved chart image stays public while the chart is unpublished. With the image option on, the editor writesvisualization-<id>.pnginto uploads. It registers an attachment with statusinheritand no parent. The media REST API lets any visitor read such an attachment and its URL. The labels in the image can show private post titles. This assumes that the site serves its uploads folder publicly. Do not keep a public image of an unpublished chart that has a post-type query, including images saved before. Add a case totests/test-chart-rows-permissions.phpthat reads the media REST route as a visitor.
Validation details
- Files reviewed: 4/4 changed files. Two history questions stay open: background runs without a user, and editing paths that keep stored values.
- PHPUnit with WordPress 7.1.5 on PHP 8.3 ran the new test class:
cd /repo && set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Visualizer_Chart_Rows_P…printedTests: 9, Assertions: 25, Errors: 2(run R3) - Against
pr-base, the reader and manual-editor cases fail on the private title. That base run has no record. - A revision diff as the Author returned the private title [R9].
- The block REST settings kept
chart-imgfor the refused Author [R13].
Untested areas
- Background runs without a logged-in user, and editing paths that must keep stored values: not settled.
- Pro readers and Pro data filters: Pro source is not available.
- The chart editor and chart library test cases error on
tsdk_utmify()in the sandbox. - Elementor output and WordPress versions between 5.2 and 7.1 were not checked.
- The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Elementor/Widget.php:304-335,358-422— unverified: Another settings-output route embeds all settings, including saved chart-img, despite guarded row data. The selector lists only published charts (:204-208); an existing selection c…classes/Visualizer/Module/Sources.php:91-100,115-121— unverified: The REST field runs source/filter callbacks after substituting empty rows. Whether a Pro source restores refused stored rows requires unavailable Pro source.
🤖 Automated review · run code-review-agent_6b0fccfa051e73.19755403.
🤖 Review agent — review posted ✅ on f05ac707 · changes requested · 4 findings · 37 min
Run code-review-agent_6b0fccfa051e73.19755403 · trail
…t image setting Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
# Conflicts: # classes/Visualizer/Module/Setup.php
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
|
Review item M1 (saved chart image): fixed in 8f6eb6c. |
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The three earlier findings are fixed, but XML-RPC still returns the rows, and a refused user's settings save deletes pie slice settings.
Validation details
- Files reviewed: 6/6 changed files. One checklist question stays open: Caps and limits: Realistic volume.
- PHPUnit on WordPress 7.1 and PHP 8.3, with a
tsdk_utmify()stub, passes all 18 cases of the new test class at HEAD [R9]. - The same cases run on
pr-basecode: 17 of 18 fail or error [R19]. - A direct
wp_xmlrpc_servercall as the Author returned the private title [R14]. - An Author settings save dropped the stored
slicesof a pie chart [R16].
Untested areas
- Caps and limits: Realistic volume: no site volume data for the upgrade sweep.
- Pro readers (Pro source filters, the Pro sidebar hook) and the time Pro writes the query: Pro source is not available. If Pro writes the query first, a new chart may lose its first saved image.
- A failed file removal after the attachment row is deleted was not checked.
- XML-RPC over HTTP, and WordPress versions between 5.2 and 7.1, were not checked.
- The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Gutenberg/Block.php:330-337— unverified: Gutenberg applies source filters after substituting empty rows. Missing Pro source implementation decides whether repopulateData() restores protected rows; that dependency is unava…classes/Visualizer/Module/Sources.php:91-100,115-121— unverified: Gutenberg applies source filters after substituting empty rows. Missing Pro source implementation decides whether repopulateData() restores protected rows; that dependency is unava…
🤖 Automated review · run code-review-agent_6b0fefdabd0e96.51319874.
🤖 Review agent — review posted ✅ on 56fb503f · changes requested · 4 findings · 48 min
Run code-review-agent_6b0fefdabd0e96.51319874 · trail
…refused user Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…it reads Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approved
The PR passes: the four earlier findings are fixed, and no new problem was found.
Validation details
- Files reviewed: 6/6 changed files. One checklist question stays open: Caps and limits: Realistic volume.
- The new test class passes at HEAD on PHP 8.3 with a
tsdk_utmify()stub:cd /repo && export PHP_INI_SCAN_DIR=/etc/php/8.3/cli/conf.d:/workspace/phpini; set -o pipefail; timeout 280 vendor/bin/p…printedOK (25 tests, 70 assertions)(run R3) - The tests added since the last review fail on
pr-basecode [R9]. - The earlier XML-RPC repro now gets error 401 for the Author [R5].
- The earlier pie repro now keeps
slicesafter the Author's save [R8].
Untested areas
- Caps and limits: Realistic volume: no site volume data for the upgrade sweep.
- Pro sidebars and Pro source filters were not checked, because the Pro source is not available.
- A file that WordPress fails to remove inside
wp_delete_attachment()was not checked. - XML-RPC over HTTP and WordPress versions between 5.2 and 7.1 were not checked.
- Most plugins that apply
xmlrpc_enabledoutside XML-RPC were not read. - The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Module.php:924-933,1107-1113— unverified: former Module.php:1000-1009 saved-image output: status/query hooks and the upgrade sweep remove existing images (Setup.php:404-422; Upgrade.php:48-67), but deletion-failure behavio…classes/Visualizer/Module/Setup.php:199-207— unverified: core REST chart/revision content is excluded without editor support in the inspected WordPress 5.2 and 7.1 schemas: /deps/wordpress/5.2/wp-includes/rest-api/endpoints/class-wp-rest…classes/Visualizer/Gutenberg/Block.php:330-337— unverified: unchanged prior limitation: unavailable Pro source prevents ruling whether its source filter restores refused rows after Gutenberg’s check.classes/Visualizer/Module/Sources.php:91-100,115-121— unverified: unchanged prior limitation: unavailable Pro source prevents ruling whether its source filter restores refused rows after Gutenberg’s check.
🤖 Automated review · run code-review-agent_6b103673a08ca2.45041463.
🤖 Review agent — review posted ✅ on 4fb6d130 · approved · 0 findings · 36 min
Run code-review-agent_6b103673a08ca2.45041463 · trail
A post-type chart of the Pro plugin stores the rows of its last query. The free plugin gave these stored rows to each user who can edit the chart. The rows of an unpublished post-type chart now go only to users who can read every post of that post type.
What changed
Stored rows rule — new
Visualizer_Module::can_read_chart_rows(). It applies to a chart that has a post-type query (visualizer-filter-config) and is not published. The user must be able to read every post of the type: the post type has an admin screen, and the user has itsedit_others_postsandread_private_postscapabilities. This is the rule that the Pro plugin has for the query.Visualizer_Module::get_chart_data()— returns an empty array when the rule refuses the user. The chart editor, the chart library, theget-chartability, the exports, the shortcode and the Elementor widget read the rows through this method.Block editor data — the REST field
chart_datareturns emptyvisualizer-datain the same case.Revisions — a chart revision follows the status of its chart. The revision comparison screen of WordPress shows no chart content when the rule refuses the user for one of the two compared versions.
XML-RPC — the XML-RPC methods of WordPress refuse a chart and its revisions when the rule refuses the user.
Chart image — the chart settings come without the rendered picture (
chart-img) when the rule refuses the user. An unpublished chart with a post-type query keeps no saved image. The image is not saved, and it is deleted when the chart is unpublished or gets the query. After each plugin update, an upgrade step deletes such images that an earlier version kept.Data uploads — when the rule refuses the user, a manual editor save, a file upload or a URL import shows a message and changes nothing. The post-type query stays until a user who can read the rows replaces it. A settings save of that user keeps the stored slice settings of a pie chart.
Note
A published chart is not changed: it shows its stored rows to each user who can see it. A chart without a post-type query is not changed. The chart type, series and settings still load for a refused user; only the rows are empty.
Note
A chart with a post-type query loses its saved image when it is unpublished, also when it is moved to the trash. The next save of the published chart creates the image again.
Note
Tracked in Codeinwp/visualizer-pro#669.
Review responses
Visualizer_Module_Admin::addRevision()copies the query to each chart revision, so the rule reads it from the revision. No reader of the free plugin gives the rows of a revision.QA
This needs Visualizer Pro with a license that has the post-type data source (Import from WordPress).
Log in as an administrator. Go to
WP Admin → Postsand add a post with the titlePRIVATE-TITLEand the visibility Private.Go to
WP Admin → Usersand add the userrows-testwith the role Editor.Log in as
rows-test. Go toWP Admin → Visualizer → Chart Library → Add New Chartand create a chart. In the chart editor, openSource → Import from WordPress, click Create Parameters, select the post type Posts and the field post_title, and save the chart. Note the chart ID.As the administrator, make the chart unpublished and change the role of
rows-testto Author:Log in as
rows-test. Go toWP Admin → Visualizer → Chart Library, and open the chart for edit.Expect: the library and the chart editor show the chart without data. The page source does not contain
PRIVATE-TITLE.In the chart editor, open
Source → Manual Data. Select the Text editor and click Edit Data. Then click Show Chart.Expect: a message says that you cannot change the data of this chart.
Log in as the administrator and open the same chart.
Expect: the chart shows its data, with
PRIVATE-TITLE.Publish the chart again (
wp post update <chart id> --post_status=publish). Log in asrows-testand open the library.Expect: the chart shows its stored data, as before this change.
🤖 Generated with Claude Code