Skip to content

Keep the saved JSON source credentials out of the chart editor - #1428

Merged
vytisbulkevicius merged 8 commits into
developmentfrom
bugfix/pro/666
Dec 2, 2026
Merged

vytisbulkevicius merged 8 commits into
developmentfrom
bugfix/pro/666

Conversation

@vytisbulkevicius

@vytisbulkevicius vytisbulkevicius commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

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_data returns visualizer-json-headers without auth. 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

  1. 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, open Source → Import from JSON and click Create Parameters.

  2. Enter an endpoint that needs HTTP Basic credentials, for example https://httpbin.org/basic-auth/user/TEST-PASSWORD. Open Headers, enter user and TEST-PASSWORD in 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.

  3. 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.

  4. 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.

  5. Open the parameters again. Select Remove the saved credentials and click Fetch Endpoint.

    Expect: the request fails, because it has no credentials.

  6. 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-headers has method and no auth.

🤖 Generated with Claude Code

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>
@pirate-bot

pirate-bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Plugin build for 2fb7ef9 is ready 🛎️!

vytisbulkevicius and others added 3 commits December 1, 2026 22:12
…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>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 — security WordPress export still writes the saved JSON credentials. Charts keep the default can_export, and export_wp() prints every meta value raw, including visualizer-json-headers with auth. Core skips only _edit_lock. This assumes a multisite site administrator, who has export but cannot edit or install plugins. That user can now read credentials the chart editor no longer shows. Add a wxr_export_skip_postmeta callback that skips Visualizer_Plugin::CF_JSON_HEADERS, or strips auth from it. Add a test that runs the callback for that key.
  • classes/Visualizer/Module/Setup.php:327-328 — security XML-RPC wp.getPost still returns the saved JSON credentials to a multisite super administrator. protect_chart_meta() marks visualizer- keys as protected. Core then checks only edit_post_meta, which a super administrator always passes. The custom fields come back raw, including auth. Add a map_meta_cap callback that returns do_not_allow for edit_post_meta on Visualizer_Plugin::CF_JSON_HEADERS. Add a case to tests/test-chart-meta-protection.php for 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 base cd /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

Comment thread classes/Visualizer/Module.php Resolved
Comment thread classes/Visualizer/Module/Chart.php Resolved
Comment thread classes/Visualizer/Module/Abilities.php Resolved
…of export and XML-RPC

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@vytisbulkevicius

Copy link
Copy Markdown
Contributor Author

Review items M1 and V2 are fixed in a4b27ef: a wxr_export_skip_postmeta callback leaves visualizer-json-headers out of the export, and a map_meta_cap callback returns do_not_allow for the three meta capabilities on that key. Both have a test in tests/test-chart-meta-protection.php. The super administrator case needs a network, so the test gives the user the primitive capability instead.

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

Overlapping saves can still pair saved credentials with a new endpoint. Fix that, the ability debug log path and the &amp; 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… printed OK (5 tests, 11 assertions) (run R12).
  • The form round-trip matches esc_url_raw() for brackets, spaces and quotes, but not for &amp; 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_args consumers 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

Comment thread classes/Visualizer/Module/Abilities.php Resolved
Comment thread classes/Visualizer/Module.php Resolved
… form address of an endpoint

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes requested

The log and &amp; 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… printed OK (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… printed OK (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… printed Tests: 3, Assertions: 5, Failures: 2. (run R8).
  • The race is still present by source reading. Chart.php is 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_args consumers 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>

@pirate-bot pirate-bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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… printed OK (19 tests, 40 assertions) (run R2)
  • The new case fails on the earlier code at its auth_url assertion: set -o pipefail; B=/workspace/checks/R1/base-1cc2; rm -rf $B; mkdir -p $B && cd /repo && git archive HEAD | tar -x -C $B… printed Failed 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_args consumers 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

@vytisbulkevicius
vytisbulkevicius merged commit 03a2b67 into development Dec 2, 2026
9 checks passed
@vytisbulkevicius
vytisbulkevicius deleted the bugfix/pro/666 branch December 2, 2026 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants