Repository navigation
Scope chart data access boundaries - #1411
Conversation
There was a problem hiding this comment.
🟡 Changes requested
The sanitizer misses tags without a closing > and skips the import previews, and the new WooCommerce gate can wipe live-refresh charts.
classes/Visualizer/Module/Chart.php:225—securityThe new cell boundary skips the import previews.getJsonData()passesgetRawData()straight toVisualizer_Render_Layout::show().Layout.php:511-515echoes non-editable cells raw, andjs/frame.jsinserts them with.html(). The JSON save, CSV/URL upload and query save previews passgetRawData()toVisualizer_Render_Page_Update, and DataTables writes the cells withinnerHTML. A remote endpoint or CSV file with<img src=x onerror=…>runs script in the importing user's admin session. Pass the rows throughVisualizer_Module::sanitize_chart_data()before each preview atChart.php:218-225,306-310,1423-1426and1680-1688. Add atests/test-ajax.phpcase that checks the preview table has no event attribute.js/render-datatables.js:141—commentsThe comment// remove this so that the eval does not fail.abovedelete chart.settings['internal_title']is now false. This change removes theeval. Delete the comment, or state the real reasoninternal_titleis dropped before the settings loop.
Validation details
- Files reviewed: 12/12 changed files. One open question remains: how
format_chart_data()handles the sanitized cells. - The sanitizer ran on PHP 8.3.36 and WordPress 7.1.4:
cp /repo/classes/Visualizer/Module.php /workspace/checks/LC1/Module.php; timeout 30 wp eval 'require "/workspace/checks/…(run R5, exit 0) andgit rev-parse HEAD; cp classes/Visualizer/Module.php /workspace/checks/LC2/Module.php; timeout 30 php /workspace/checks/…(run R7, exit 0). - The base-tree PHPUnit runs show that the new denial, sanitization and contributor-token tests fail without the change.
- The node test of nested settings fails on the base renderer
cd /repo; D=/workspace/checks/R1/jsbase; rm -rf $D; mkdir -p $D/js $D/tests/js; git show pr-base:js/render-datatables.js…(run R3, exit 0). - The
merge2.1.1 anduuid11.1.1 imports match their documented exports.
Untested areas
- The consumer question "
format_chart_data()receives the changed data" was not settled. The formatter was read, but its effect was not run. - Visualizer Pro DataTable setting names were not checked. The Pro source is outside this repository.
- The print-button exploit is traced in source only.
- No CI job runs
tests/js.
🤖 Automated review · run code-review-agent_6af70662c81753.78352976.
🤖 Review agent — review posted ✅ on 6f437694 · changes requested · 8 findings · 41 min
Run code-review-agent_6af70662c81753.78352976 · trail
…n failed refreshes Normalize every tag opening in rendered cells, sanitize import and query previews, and keep exports and the data editor on the stored values. Record the user who sets a JSON endpoint as its report user, and keep the stored data when a WooCommerce report fetch fails.
There was a problem hiding this comment.
🟡 Changes requested
The earlier findings are fixed, but imported markup still reaches the text editor and JSON preview, and three data paths need fixes.
Validation details
- Files reviewed: 9/9 files changed since the prior review. The other 5 reuse run code-review-agent_6af70662c81753.78352976, not rerun.
- The 14 new or changed tests pass at HEAD on PHP 8.3.36 (run R6).
- Sandbox probes on WordPress 7.1.4 show the raw JSON key header, the textarea breakout and the
Q1Q4reads (run R14). - The import preview cell fix and the
internal_titlecomment fix from the prior review are confirmed in source. - Visualizer Pro #646 checks the recorded user's report capability before it grants access.
Untested areas
- The second-fetch failure is traced in source only.
- The pr-base and prior-head test runs have no run record.
- Chart duplication meta order was not checked.
- Question: the PR text says
format_chart_data()converts date columns, but the code has no date case.
🤖 Automated review · run code-review-agent_6af7afa251cd93.89987607.
🤖 Review agent — review posted ✅ on f407907a · changes requested · 5 findings · 49 min
Run code-review-agent_6af7afa251cd93.89987607 · trail
Return stored rows to the AI builder and the chart ability, escape the text editor and preview headers, check refresh errors after the last read, and record the report user only when a user saves a different endpoint. Copies of a chart do not carry the original report user.
There was a problem hiding this comment.
🟢 Approved
This approves the PR because the five earlier findings are fixed. One note asks whether an ability save should keep the report user.
Validation details
- Files reviewed: 9/9 files changed since the prior review. Other files reuse run code-review-agent_6af7afa251cd93.89987607, not rerun.
- The 9 new tests pass at HEAD on PHP 8.3.36.
- Each new test fails at the prior head f407907.
- Every JSON endpoint writer goes through
update_json_url(). Clone, translation copy and revision restore only copy stored meta. - The text editor and preview header outputs are escaped.
Untested areas
- Visualizer Pro #646 at its latest commit was not read. The coordinated release was not verified.
- Four report-user tests cannot run at pr-base, because the meta constant is missing there.
- The row "Visualizer_Source_Query::html() return changed" reuses the prior run's test result and was not rerun.
🤖 Automated review · run code-review-agent_6af7bff4d71f07.37444990.
🤖 Review agent — review posted ✅ on 765ab3b2 · approved · 0 findings · 15 min
Run code-review-agent_6af7bff4d71f07.37444990 · trail
| update_post_meta( $chart->ID, Visualizer_Plugin::CF_EDITABLE_TABLE, true ); | ||
| $this->persistSource( $chart->ID, $source ); | ||
| update_post_meta( $chart->ID, Visualizer_Plugin::CF_JSON_URL, $params['url'] ); | ||
| self::update_json_url( $chart->ID, $params['url'] ); |
There was a problem hiding this comment.
note The set-data-source ability deletes the stored JSON URL in clearSourceMeta() before it calls update_json_url(). So a save with the same endpoint always records the calling user as the report user. If that user lacks report access, the scheduled WooCommerce refresh stops and keeps old data. Is this call meant to re-authorize the schedule it recreates? If yes, it is safe. If not, compare against the URL read before clearSourceMeta().
|
🎉 This PR is included in version 4.0.11 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Chart rendering and report imports now keep data and settings inside their supported boundaries.
What changed
Chart settings — maps supported nested DataTables settings without dynamic evaluation.
Chart cells — applies the WordPress post-markup boundary after source filters, on the front end, in the block editor, in the print view and in the import and query previews. CSV and Excel exports, the text editor, the editable data table, the AI builder and the chart ability keep the stored values; the text editor and preview headers are escaped.
Report imports — retains the user who authorized scheduled report access. Saving a different JSON endpoint records the saving user instead; copies of a chart do not carry it.
Schedules — WooCommerce report fetches need report access. Visualizer Pro (Codeinwp/visualizer-pro#646) supplies it for scheduled refreshes. A failed WooCommerce report fetch keeps the stored chart data and records the error.
Dependencies — refreshes the directly used merge and UUID packages.
Note
Release together with Codeinwp/visualizer-pro#646. Pro keeps scheduled WooCommerce charts refreshing with this version and with older Visualizer versions.
Review responses
Visualizer_Module::sanitize_chart_data().test_json_preview_removes_event_attributes,test_json_save_preview_removes_event_attributes,test_csv_upload_preview_removes_event_attributesandtest_query_preview_removes_event_attributeseach fail with their change reverted and pass at HEAD. The query save preview has no test:saveQuery()reads the chart ID withfilter_input( INPUT_GET ), which the PHPUnit AJAX harness cannot set (the existing import test is skipped for the same reason); it uses the same call as the CSV upload preview.internal_titlecomment (F4) — fixed in f407907; the comment now says why the label is dropped.format_chart_data()— it runs on the block editor data after sanitizing, for tabular charts, and converts number, boolean and time-of-day columns by series type; string columns pass through unchanged (corrected: there is no date case).inc/types/DataTable.phpin Pro. After the_bool/_intsuffix is stripped its fields areselect_style,select_items,select_info(nestedselect) and single names such assearchingandlengthChange; all of them still map._getDataAs( …, 'print' )now reads sanitized rows (test_exports_and_editor_keep_stored_cells).tests/js— no CI job runs it; it passes locally withnode --test tests/js/.test_refresh_keeps_stored_data_when_second_woocommerce_read_fails(fails with the old order).visualizer/set-data-sourceability clears the source meta before it writes the endpoint, so saving through the ability always records the saving user, even for the same URL. That is deliberate: an ability save replaces the whole source configuration, so the saving user takes over report access. The editor's same-URL re-save keeps the earlier user because it edits columns of the existing source.