Skip to content
This repository has been archived by the owner on Nov 24, 2023. It is now read-only.

feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database #633

Conversation

Kuri-su
Copy link
Contributor

@Kuri-su Kuri-su commented Apr 23, 2020

What problem does this PR solve?

UCP #506
fix #506

What is changed and how it works?

add and use 'decryptOrPlaintext' function

@sre-bot
Copy link

sre-bot commented Apr 23, 2020

Thanks for your contribution. If your PR get merged, you will be rewarded 600 points.

@sre-bot sre-bot added the contribution For contributor label Apr 23, 2020
@Kuri-su Kuri-su changed the title feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database [WIP]feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database Apr 27, 2020
@Kuri-su Kuri-su force-pushed the feature/kurisu-support-unencrypted-pw-in-toml-200423 branch from f670199 to b2a7f56 Compare April 28, 2020 12:26
@Kuri-su Kuri-su marked this pull request as draft April 28, 2020 12:26
@Kuri-su Kuri-su force-pushed the feature/kurisu-support-unencrypted-pw-in-toml-200423 branch from b2a7f56 to bc8bac5 Compare April 28, 2020 12:36
@Kuri-su Kuri-su changed the title [WIP]feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database feat(encrypt): Support both encrypted and unencrypted passwords for the upstream and downstream database Apr 28, 2020
@Kuri-su Kuri-su marked this pull request as ready for review April 28, 2020 12:36
@Kuri-su
Copy link
Contributor Author

Kuri-su commented Apr 28, 2020

@csuzhangxc PTAL, thx , I have no idea about this issue 😂

Copy link
Member

@csuzhangxc csuzhangxc left a comment

Choose a reason for hiding this comment

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

I think you can update some integration test cases (under ./tests directory) to use plaintext password (123456) now.

ciphertext, err1 := utils.Encrypt(c.encrypt)
if err1 != nil {
return true, err1
ciphertext, err := utils.Encrypt(c.encrypt)
Copy link
Member

Choose a reason for hiding this comment

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

rename err1 to err will report some warning by make check.

dm/ctl/common/config.go:94:15: declaration of "err" shadows declaration at line 82
dm/ctl/common/config.go:103:14: declaration of "err" shadows declaration at line 82

return ciphertextB64, nil
}
return plaintext, nil
}
Copy link
Member

Choose a reason for hiding this comment

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

another new line is needed here (with go fmt).

@csuzhangxc
Copy link
Member

@csuzhangxc PTAL, thx , I have no idea about this issue 😂

This PR is what I want. 👍

@Kuri-su
Copy link
Contributor Author

Kuri-su commented May 6, 2020

@csuzhangxc OK, i'm done, but i don't found the reason of test case failed, can you help me see this problem, THX ; )

@Kuri-su
Copy link
Contributor Author

Kuri-su commented May 6, 2020

@csuzhangxc OK, i'm done, but i don't found the reason of test case failed, can you help me see this problem, THX ; )

it said the failed point in https://github.com/pingcap/dm/blob/master/dm/master/server_test.go#L994 , But I did not find the connection between it and cryption modules

@csuzhangxc
Copy link
Member

csuzhangxc commented May 6, 2020

@csuzhangxc OK, i'm done, but i don't found the reason of test case failed, can you help me see this problem, THX ; )

it said the failed point in https://github.com/pingcap/dm/blob/master/dm/master/server_test.go#L994 , But I did not find the connection between it and cryption modules

our CI is not stable now, you may simply re-/run-all-tests if you can confirm no connection between it and cryption modules.

@csuzhangxc
Copy link
Member

/run-all-tests

@Kuri-su
Copy link
Contributor Author

Kuri-su commented May 6, 2020

/run-all-tests

yes.....In fact... i have tried /run-all-tests many times..... i delete comments when Jenkins job started.

but the error still exists, let me see this error later of today 😹

@Kuri-su Kuri-su force-pushed the feature/kurisu-support-unencrypted-pw-in-toml-200423 branch from e0611fe to eb8f7e1 Compare May 7, 2020 01:02
@Kuri-su
Copy link
Contributor Author

Kuri-su commented May 15, 2020

I will finish this issue in this weekend 😂

@csuzhangxc
Copy link
Member

@Kuri-su now, we are moving our internal work to #sig-tools and #sig-tools-zh now, if you have interests, you can join one or two.

@csuzhangxc csuzhangxc added the type/feature New feature label May 20, 2020
@csuzhangxc csuzhangxc requested a review from WangXiangUSTC May 20, 2020 02:34
@csuzhangxc csuzhangxc added this to the v2.0.0 beta.2 milestone May 20, 2020
@Kuri-su
Copy link
Contributor Author

Kuri-su commented May 20, 2020

Finally 😂

Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

rest LGTM

func() *SourceConfig {
cfg := newConfig()
cfg.From.Password = "123456" // plaintext password
return cfg
Copy link
Contributor

Choose a reason for hiding this comment

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

how about adding test case config with encrypt password?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, i have added a testCase about encrypt password

if err1 != nil {
return true, err1
}
fmt.Println(plaintext)
Copy link
Contributor

Choose a reason for hiding this comment

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

this line should be deleted

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps we are shouldn't delete these lines, because the Decrypt method is called instead of DecryptOrPlaintext in L103 , the function may return a error

@@ -43,3 +43,12 @@ func Decrypt(ciphertextB64 string) (string, error) {
}
return string(plaintext), nil
}

// DecryptOrPlaintext tries to decrypt base64 encoded ciphertext to plaintext or return plaintext
func DecryptOrPlaintext(ciphertextB64 string) (string, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

seems that dosen't need to return error

Copy link
Contributor Author

@Kuri-su Kuri-su May 20, 2020

Choose a reason for hiding this comment

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

ok, i have cleaned the extra error variables

Copy link
Contributor

@WangXiangUSTC WangXiangUSTC left a comment

Choose a reason for hiding this comment

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

LGTM

@WangXiangUSTC WangXiangUSTC added status/LGT2 Two reviewers already commented LGTM, ready for merge and removed status/LGT1 One reviewer already commented LGTM labels May 20, 2020
@csuzhangxc
Copy link
Member

@Kuri-su please update this branch with the base branch.

@csuzhangxc csuzhangxc added the needs-cherry-pick-release-1.0 This PR should be cherry-picked to release-1.0. Remove this label after cherry-picked to release-1.0 label May 20, 2020
@csuzhangxc csuzhangxc merged commit 9a4a5ba into pingcap:master May 20, 2020
@sre-bot
Copy link

sre-bot commented May 20, 2020

Team □□□□□ complete task #506 and get 600 score, current score 1550

@csuzhangxc
Copy link
Member

@Kuri-su thank you, ❤️

@sre-bot
Copy link

sre-bot commented May 20, 2020

cherry pick to release-1.0 failed

Kuri-su added a commit to Kur-Public/dm that referenced this pull request May 20, 2020
@csuzhangxc csuzhangxc added already-cherry-pick-1.0 The related PR is already cherry-picked to release-1.0. Add this label once the PR is cherry-picked and removed needs-cherry-pick-release-1.0 This PR should be cherry-picked to release-1.0. Remove this label after cherry-picked to release-1.0 labels May 21, 2020
csuzhangxc pushed a commit that referenced this pull request May 22, 2020
@csuzhangxc csuzhangxc added already-update-release-note The release note is updated. Add this label once the release note is updated already-update-docs The docs related to this PR already updated. Add this label once the docs are updated and removed needs-update-release-note This PR should be added into release notes. Remove this label once the release notes are updated needs-update-docs Should update docs after this PR is merged. Remove this label once the docs are updated labels Jun 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
already-cherry-pick-1.0 The related PR is already cherry-picked to release-1.0. Add this label once the PR is cherry-picked already-update-docs The docs related to this PR already updated. Add this label once the docs are updated already-update-release-note The release note is updated. Add this label once the release note is updated contribution For contributor priority/normal Minor change, requires approval from ≥1 primary reviewer status/LGT2 Two reviewers already commented LGTM, ready for merge type/feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UCP: Support both encrypted and unencrypted passwords for the upstream and downstream database
4 participants