Repository navigation
Keep the saved JSON source credentials out of the chart editor - #1428
Conversation
The chart editor and the chart_data REST field no longer return saved credentials. A save or a fetch with empty credential fields uses the saved credentials for the scheme and host they were saved for. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…in only A request from the chart editor gets the saved credentials only for the saved endpoint address, and the source sends credentials only to the origin of its endpoint when it follows a next page. The save fetches the chart data with the saved credentials. The form copies of an earlier submit are dropped before a new submit. Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
…credentials Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
Saved JSON credentials still follow a changed endpoint and still leave through export and XML-RPC. Fix the endpoint binding and the URL comparison before merge.
classes/Visualizer/Module/Setup.php:190-200—securityWordPress export still writes the saved JSON credentials. Charts keep the defaultcan_export, andexport_wp()prints every meta value raw, includingvisualizer-json-headerswithauth. Core skips only_edit_lock. This assumes a multisite site administrator, who hasexportbut cannot edit or install plugins. That user can now read credentials the chart editor no longer shows. Add awxr_export_skip_postmetacallback that skipsVisualizer_Plugin::CF_JSON_HEADERS, or stripsauthfrom it. Add a test that runs the callback for that key.classes/Visualizer/Module/Setup.php:327-328—securityXML-RPCwp.getPoststill returns the saved JSON credentials to a multisite super administrator.protect_chart_meta()marksvisualizer-keys as protected. Core then checks onlyedit_post_meta, which a super administrator always passes. The custom fields come back raw, includingauth. Add amap_meta_capcallback that returnsdo_not_allowforedit_post_metaonVisualizer_Plugin::CF_JSON_HEADERS. Add a case totests/test-chart-meta-protection.phpfor a super administrator.
Validation details
- Files reviewed: 11/11 changed files.
- The new credential tests fail on the base code and pass at the head, in the PHPUnit sandbox with PHP 8.3
cd /workspace/checks/runs; ls | tail -4; for f in $(ls R*.json | sort -V | tail -4); do echo "$f: $(python3 -c "import j…(run R10, exit 0). - The editor render tests needed a sandbox stub for
tsdk_utmify(). With it, they pass at the head and fail on the basecd /workspace/checks/runs; for f in R*.json; do echo "$f $(python3 -c "import json,sys;d=json.load(open('$f'));print(d.g…(run R9, exit 0). - A sandbox test reproduced the endpoint change and the bracket URL loss
cd /workspace/checks/R2; python3 - <<'EOF' p='/workspace/checks/R2/Test_R2_Rebinding.php' s=open(p).read() old=""" $_RE…(run R18, exit 0).
Untested areas
- Sensitive request headers must not cross an origin change: the additional headers on cross-origin next pages were not settled.
- The Pro add-on source was not available. Its JSON request filter and database query paths are unchecked.
- No JavaScript suite covers
js/frame.js. The site was not reachable, so no browser check ran. - The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Source/Json.php:461— unverified: visualizer_json_args receives the authenticated request arguments. No callback exists in this checkout; whether unavailable Pro code restores saved authentication after the origin …classes/Visualizer/Module/AIBuilder.php:370-423— unverified: The fourth database-query family member accepts SQL and returns getRawData(false). Its capability/Pro guard is372-374; query construction is378-390; response is420-423. The same un…classes/Visualizer/Source.php:439,473— unverified: Abilities places saved credentials inside source parameters (classes/Visualizer/Module/Abilities.php:972-981,1022-1024), which these events print in full. Local debug consumers wri…
🤖 Automated review · run code-review-agent_6b0fa786bddea6.83950812.
🤖 Review agent — review posted ✅ on f3d4be1e · changes requested · 5 findings · 31 min
Run code-review-agent_6b0fa786bddea6.83950812 · trail
…of export and XML-RPC Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
|
Review items M1 and V2 are fixed in a4b27ef: a |
There was a problem hiding this comment.
🟡 Changes requested
Overlapping saves can still pair saved credentials with a new endpoint. Fix that, the ability debug log path and the & address match.
Validation details
- Files reviewed: 13/13 changed files.
- The five tests added since the last review pass at the head and fail on the base code:
python3 -c " import re for f in ['/workspace/checks/R1b/ab-run2.log','/tmp/sandbox-phpunit-ab.celZZ7/base.log']: for…printedOK (5 tests, 11 assertions)(run R12). - The form round-trip matches
esc_url_raw()for brackets, spaces and quotes, but not for&cd /workspace/checks/R1 && sed -i 's/class Test_Url_Probe extends/class UrlProbeTest extends/' UrlProbeTest.php && cd /r…(run R4, exit 0). - The export and XML-RPC credential leaks are fixed in WordPress 5.2 and 7.1, by source reading.
Untested areas
- The overlapping-save race was traced in source, not executed.
- The Pro add-on is unavailable:
visualizer_json_argsconsumers and the scheduled refresh are unchecked. - An ability save that keeps credentials may strip their backslashes. The PR body says this predates the PR. It was not rechecked.
- No JavaScript suite covers
js/frame.js. No browser check ran. - The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Source/Json.php:449-461— unverified: visualizer_json_args receives authenticated arguments; repository-wide literal search found no consumer, but unavailable Pro callbacks could decide disclosure. Cross-origin paginat…classes/Visualizer/Module/Setup.php:71-73,345-361— unverified: core-output guards are present. WXR omission is confirmed for WordPress 5.2/7.1 (/deps/wordpress/5.2/wp-admin/includes/export.php:597-603; /deps/wordpress/7.1/wp-admin/includes/exp…
🤖 Automated review · run code-review-agent_6b0fb36cea8964.34868281.
🤖 Review agent — review posted ✅ on a4b27ef0 · changes requested · 2 findings · 29 min
Run code-review-agent_6b0fb36cea8964.34868281 · trail
… form address of an endpoint Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes requested
The log and & fixes work. Overlapping saves can still pair saved credentials with a new endpoint, so bind auth to its endpoint.
Validation details
- Files reviewed: 3/3 files changed since the last review.
- The credential suite passes at the head:
cd /repo && set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Visualizer_Json_Credent…printedOK (18 tests, 38 assertions)(run R5). - The two changed tests pass at the head:
cd /repo && set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Visualizer_Json_Credent…printedOK (3 tests, 7 assertions)(run R9). - The same tests fail on the earlier code:
set -o pipefail; P=/var/www/html/wp-content/plugins/visualizer; restore(){ rm -f $P && ln -s /repo $P; readlink $P; }; t…printedTests: 3, Assertions: 5, Failures: 2.(run R8). - The race is still present by source reading.
Chart.phpis unchanged since the last review.
Untested areas
- The overlapping-save race was traced in source, not executed.
- The Pro add-on is unavailable. The
visualizer_json_argsconsumers and the scheduled refresh are unchecked. - WordPress versions between 5.2 and 7.1 were not read for the export and XML-RPC guards.
- No JavaScript suite covers
js/frame.js. No browser check ran. - The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Source/Json.php:232-233,297,349-370,449-457— unverified: pagination and redirects retain credentials for a different same-origin URL. Missing: a supported saved endpoint response/contract establishing that trigger. Cross-origin paginatio…classes/Visualizer/Remote/Fetch.php:73-89,387-396— unverified: pagination and redirects retain credentials for a different same-origin URL. Missing: a supported saved endpoint response/contract establishing that trigger. Cross-origin paginatio…classes/Visualizer/Source/Json.php:461— unverified: visualizer_json_args receives authenticated arguments; no consumer found in the checkout, and Pro consumer source remains unavailable.classes/Visualizer/Module/Setup.php:72,345-348— unverified: formerly OPEN XML-RPC route is blocked in inspected WordPress 5.2 and 7.1: /deps/wordpress/5.2/wp-includes/class-wp-xmlrpc-server.php:351-355, /deps/wordpress/7.1/wp-includes/class…classes/Visualizer/Module/Setup.php:73,360-361— unverified: formerly OPEN WXR route skips the credential key in inspected WordPress 5.2 and 7.1 (/deps/wordpress/5.2/wp-admin/includes/export.php:597-603; /deps/wordpress/7.1/wp-admin/includes…
🤖 Automated review · run code-review-agent_6b0fc22e2293b4.05387947.
🤖 Review agent — review posted ✅ on 1cc2ae91 · changes requested · 0 findings · 13 min
Run code-review-agent_6b0fc22e2293b4.05387947 · trail
Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approved
The PR passes: saved JSON credentials now stay bound to the endpoint of their save, which closes the overlapping-save gap.
Validation details
- Files reviewed: 5/5 files changed since the last review.
- The credential suite passes at the head:
cd /repo && set -o pipefail; timeout 600 vendor/bin/phpunit --do-not-cache-result --filter 'Test_Visualizer_Json_Credent…printedOK (19 tests, 40 assertions)(run R2) - The new case fails on the earlier code at its
auth_urlassertion:set -o pipefail; B=/workspace/checks/R1/base-1cc2; rm -rf $B; mkdir -p $B && cd /repo && git archive HEAD | tar -x -C $B…printedFailed asserting that null is identical to 'https://example.com/api'.(run R3) - Every reader of the saved headers in this repository checks
auth_url, strips it, or reads only a flag.
Untested areas
- The Pro add-on is unavailable. Its scheduled refresh and
visualizer_json_argsconsumers are unchecked. - Same-origin next pages and redirects still receive credentials. This is unchanged since the last review.
- The overlapping-save race was traced in source, not run concurrently.
- WordPress versions between 5.2 and 7.1 were not read for the export and XML-RPC guards.
- No JavaScript suite or browser check covers
js/frame.js. - The variant pass did not settle these places, where the fixed cause may still reach:
classes/Visualizer/Source/Json.php:349-370,448-457— unverified: retained pagination/redirect gap: same-origin checks permit another path or query while retaining auth. Missing evidence remains an actual supported endpoint response leading to th…classes/Visualizer/Remote/Fetch.php:73-89,387-396— unverified: retained pagination/redirect gap: same-origin checks permit another path or query while retaining auth. Missing evidence remains an actual supported endpoint response leading to th…classes/Visualizer/Source/Json.php:461— unverified: retained visualizer_json_args gap: filters receive the Authorization-bearing arguments; no consumer was found in the checkout, and unavailable Pro source prevents ruling its output…
🤖 Automated review · run code-review-agent_6b0fc63c1943a8.52074859.
🤖 Review agent — review posted ✅ on 0c661153 · approved · 0 findings · 8 min
Run code-review-agent_6b0fc63c1943a8.52074859 · trail
The chart editor filled the credential fields of a JSON source with the saved values, and the block editor data carried them too. The saved credentials now stay on the server, and a save without new credentials keeps them.
What changed
JSON source form — the fields Credentials and Authorization are always empty. When the chart has saved credentials, the form says so and shows the checkbox Remove the saved credentials.
Save of the JSON source — empty credential fields keep the saved credentials when the endpoint address does not change, and the save fetches the data with them. New credentials replace them. The checkbox removes them. A new endpoint address removes them too, from each place that saves the address. The save stores its endpoint address beside the credentials, and only a request to that address uses them.
Fetch Endpoint and Parse Endpoint — with empty credential fields, the request uses the saved credentials. The rule is the same: the endpoint address does not change, and the user can edit the chart. The form prints the saved address with some characters changed, for example
[as%5B. That form of the address is the same address.Next pages — the JSON source sends credentials only to the origin of its endpoint. A next-page address on another origin gets none.
Other outputs — the REST field
chart_datareturnsvisualizer-json-headerswithoutauth. A WordPress export leaves that meta out, and the WordPress meta capabilities refuse it for each user.Abilities — the JSON source ability reads the saved credentials through the same new helper,
Visualizer_Module::get_saved_json_auth(). It now keeps them for the same endpoint address only, not for each address of the same host. It does not write them to the plugin debug log, and its save keeps their backslashes.Note
A user who changes the endpoint address must type the credentials again. A user who does not know them can then not send them to another address. A scheduled refresh uses the saved credentials as before.
Note
Tracked in Codeinwp/visualizer-pro#666.
QA
Log in as an administrator. Go to
WP Admin → Visualizer → Chart Library → Add New Chart, select the classic builder and a chart type. In the editor, openSource → Import from JSONand click Create Parameters.Enter an endpoint that needs HTTP Basic credentials, for example
https://httpbin.org/basic-auth/user/TEST-PASSWORD. Open Headers, enteruserandTEST-PASSWORDin Credentials, and click Fetch Endpoint. Select a root, click Parse Endpoint, select one column type, click Show Chart and save the chart.Expect: the chart saves with the data of the endpoint.
Open the chart for edit again and open
Source → Import from JSON → Modify Parameters.Expect: Headers is open. The fields Credentials and Authorization are empty. A note says that credentials are saved, and the checkbox Remove the saved credentials shows. The page source does not contain
TEST-PASSWORD.Leave the credential fields empty. Click Fetch Endpoint, then Parse Endpoint, select one column type, click Show Chart and save.
Expect: both requests return data, and the chart saves. Open the parameters again: the note still shows.
Open the parameters again. Select Remove the saved credentials and click Fetch Endpoint.
Expect: the request fails, because it has no credentials.
In a post, add a Visualizer block with this chart. In the browser network panel, open the response of
/wp-json/wp/v2/visualizer/<chart id>.Expect:
chart_data.visualizer-json-headershasmethodand noauth.🤖 Generated with Claude Code