Skip to content

master(dm): require the password when the source endpoint changes - #13010

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
GMHDBJD:fix/update-source-password
Nov 26, 2026
Merged

ti-chi-bot[bot] merged 1 commit into
pingcap:masterfrom
GMHDBJD:fix/update-source-password

Conversation

@GMHDBJD

@GMHDBJD GMHDBJD commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Issue Number: close #13009

What problem does this PR solve?

updateSource (dm/master/openapi_controller.go) treats an absent password in the request as "keep the stored one" no matter what else changes. A caller can change host/port/user and omit password; dm-master then runs CheckAndAdjustSourceConfigFunc, which connects to the new endpoint — sending the stored upstream password to whoever controls it.

What is changed and how it works?

Reject the update when the source connection parameters change and no password is supplied, with a clear error (the password must be provided explicitly when changing the source host, port or user). The controller test covers host, port and user changes and asserts the stored source is untouched.

Check List

Tests

  • Unit test
  • go test ./dm/master/ -run TestOpenAPIControllerSuite/TestSourceController

Questions

Will it cause performance regression or break compatibility?

No. Callers that change the endpoint have to resubmit the password, which is what the request already does when it rotates it.

Release note

DM: updating a source's host, port or user now requires the password to be provided explicitly instead of reusing the stored one.

Summary by CodeRabbit

  • Bug Fixes
    • Updating a source’s host, port, or user now requires the password to be provided explicitly. If it is omitted, the update is rejected and the existing host remains unchanged.
    • Password reuse continues when those connection details are unchanged.

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed area/dm Issues or PRs related to DM. labels Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0ee59a13-9902-475d-8b80-1523e2c1cd5a
Commits

Reviewing files that changed from the base of the PR and between 2bd7c43 and 7222f0e.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

updateSource now rejects requests that omit a password when the source host, port, or user changes. Controller tests verify the error and confirm that the stored host remains unchanged.

Changes: Source password reuse guard

Layer / File(s) Summary
Password reuse guard and validation
dm/master/openapi_controller.go, dm/master/openapi_controller_test.go
updateSource rejects updates without a password when the host, port, or user changes. Tests check the error and confirm that the stored host remains unchanged.

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested reviewers: d3hunter, 3aceshowhand, joechenrh

Merge Risk: Minimal · previous review 2bd7c

Updating a source's host, port, or user without resubmitting the password is now rejected, so the stored upstream password cannot be used against a caller-chosen endpoint. Callers that change the endpoint must now send the password explicitly. No merge-blocking risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: dm-master now requires an explicit password when the source host, port, or user changes. It matches the raw summary, the PR objectives, and the linked issue #13009. Th…
Description check Passed The description follows the repository template. It has an 'Issue Number: close #13009' line and a 'What problem does this PR solve?' section that explains the security risk. It also has a 'What is ch…
Linked Issues check Passed Issue #13009 requires that PUT /api/v1/sources/{source-name} reject an update that changes host, port, or user without a password. The diff to dm/master/openapi_controller.go (`updateSourc…
Out of Scope Changes check Passed The whole-PR change set has two files: dm/master/openapi_controller.go (+9 lines) and dm/master/openapi_controller_test.go (+19 lines, per the summary). The production change is limited to the pas…
Full details: Title check

Explanation

The title names the main change: dm-master now requires an explicit password when the source host, port, or user changes. It matches the raw summary, the PR objectives, and the linked issue #13009. The title uses the repository's usual 'master(dm):' prefix. At 65 characters it is within a typical length limit, and it is specific enough for a teammate scanning history.

Full details: Description check

Explanation

The description follows the repository template. It has an 'Issue Number: close #13009' line and a 'What problem does this PR solve?' section that explains the security risk. It also has a 'What is changed and how it works?' section, a checklist with a unit test entry and the exact test command, answers to the compatibility question, and a release note. The template's 'Will it cause performance regression...' answer is present. The 'Do you need to update user documentation...' question is not answered. This is a minor gap and does not block the check.

Full details: Linked Issues check

Explanation

Issue #13009 requires that PUT /api/v1/sources/{source-name} reject an update that changes host, port, or user without a password. The diff to dm/master/openapi_controller.go (updateSource) adds a check inside the req.Source.Password == nil branch. It compares newCfg.From.Host, Port, and User with oldCfg.From. On any difference, it returns terror.ErrOpenAPICommonError with the message the password must be provided explicitly when changing the source host, port or user. The stored password is reused only when these fields are unchanged. This blocks the credential reuse path that #13009 describes, before CheckAndAdjustSourceConfigFunc runs. The PR summary also reports a controller test for host, port, and user changes. I did not inspect the test file, so the test coverage claim rests on the summary.

Full details: Out of Scope Changes check

Explanation

The whole-PR change set has two files: dm/master/openapi_controller.go (+9 lines) and dm/master/openapi_controller_test.go (+19 lines, per the summary). The production change is limited to the password-reuse decision in updateSource, which is the scope named by #13009. The test change supports that behavior. No unrelated change appears in the reviewed diff.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit guards the password tight
No changed host gets it by surprise
A port or user changed must show
The password first, before we go
The stored source stays as it was

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 05fe2dfb-5d53-433b-a2d9-86dc9ed8da03
Commits

Reviewing files that changed from the base of the PR and between ba08022 and 2bd7c43.

Files selected for processing: 2

  • dm/master/openapi_controller.go
  • dm/master/openapi_controller_test.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@ti-chi-bot ti-chi-bot Bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. needs-cherry-pick-release-nextgen-202609 Should cherry pick this PR to release-nextgen-202609 branch. and removed do-not-merge/needs-triage-completed labels Nov 19, 2026
@wuhuizuo

Copy link
Copy Markdown
Contributor

/test pull-syncdiff-integration-test
/test pull-verify
/test pull-dm-compatibility-test
/test pull-dm-integration-test-next-gen
/test pull-dm-integration-test

@GMHDBJD

GMHDBJD commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/retest

updateSource reuses the stored upstream password whenever the request omits
it. A caller could change host/port/user and let dm-master check the new
endpoint (CheckAndAdjustSourceConfigFunc connects to it) with the stored
password, which hands that credential to whoever controls the endpoint.

Reject the update when the connection parameters change and no password is
supplied, and cover host/port/user changes in the controller test.
@GMHDBJD
GMHDBJD force-pushed the fix/update-source-password branch from 2bd7c43 to 7222f0e Compare November 26, 2026 08:29
@GMHDBJD

GMHDBJD commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

/retest

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Nov 26, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: D3Hunter, joechenrh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 26, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-11-26 08:37:36.501213701 +0000 UTC m=+170721.178795700: ☑️ agreed by joechenrh.
  • 2026-11-26 09:33:00.553400654 +0000 UTC m=+174045.230982664: ☑️ agreed by D3Hunter.

@ti-chi-bot
ti-chi-bot Bot merged commit d675629 into pingcap:master Nov 26, 2026
31 of 32 checks passed
@ti-chi-bot

ti-chi-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

In response to a cherrypick label: new pull request created: #13028

@ti-chi-bot

ti-chi-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

In response to a cherrypick label: new pull request created: #13029

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/dm Issues or PRs related to DM. lgtm needs-cherry-pick-release-nextgen-202603 Should cherry pick this PR to release-nextgen-202603 branch. needs-cherry-pick-release-nextgen-202609 Should cherry pick this PR to release-nextgen-202609 branch. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

master(dm): update-source reuses the stored password against a caller-chosen host

4 participants