Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redacting password while logging connection params in import data to target #2097

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

priyanshi-yb
Copy link
Contributor

@priyanshi-yb priyanshi-yb commented Dec 17, 2024

Describe the changes in this pull request

Fixes #2095

Describe if there are any user-facing changes

N/A

How was this pull request tested?

Manually, password is no more coming up in log

2024-12-17 12:26:25.722074 INFO yugabytedb.go:247 Initialized connection pool with settings: (*tgtdb.ConnectionParams)(0x14000983700)({
 NumConnections: (int) 2,
 NumMaxConnections: (int) 4,
 ConnUriList: ([]string) (len=1 cap=1) {
  (string) (len=74) "postgresql://yugabyte:[email protected]:5433/pg_constraints?sslmode=prefer"
 },
 SessionInitScript: ([]string) (len=3 cap=4) {
  (string) (len=29) "SET client_encoding TO 'UTF8'",
  (string) (len=39) "SET session_replication_role TO replica",
  (string) (len=53) "SET default_transaction_isolation = 'repeatable read'"
 }
})

Does your PR have changes that can cause upgrade issues?

Component Breaking changes?
MetaDB No
Name registry json No
Data File Descriptor Json No
Export Snapshot Status Json No
Import Data State No
Export Status Json No
Data .sql files of tables No
Export and import data queue No
Schema Dump No
AssessmentDB No
Sizing DB No
Migration Assessment Report Json No
Callhome Json No
YugabyteD Tables No
TargetDB Metadata Tables No

@@ -431,7 +431,7 @@ func GetRedactedURLs(urlList []string) []string {
for _, u := range urlList {
obj, err := url.Parse(u)
if err != nil {
ErrExit("invalid URL: %q", u)
Copy link
Collaborator

Choose a reason for hiding this comment

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

previously we were printing u but can we now print err ?
can the error message also have the url in it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes, an error can include the URL in some cases, as I see url.Parse() is including the rawURL in the error msg.

func Parse(rawURL string) (*URL, error) {
	...
	if err = url.setFragment(frag); err != nil {
		return nil, &Error{"parse", rawURL, err}
	}

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, what we can do here is instead of using ErrExit() -> log + console
We print different messages for log vs console.
console can have error message(containing url)
log should have a generic msg like you added

Copy link
Collaborator

@sanyamsinghal sanyamsinghal left a comment

Choose a reason for hiding this comment

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

lgtm with a nit comment

@@ -431,7 +431,7 @@ func GetRedactedURLs(urlList []string) []string {
for _, u := range urlList {
obj, err := url.Parse(u)
if err != nil {
ErrExit("invalid URL: %q", u)
Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, what we can do here is instead of using ErrExit() -> log + console
We print different messages for log vs console.
console can have error message(containing url)
log should have a generic msg like you added

@priyanshi-yb priyanshi-yb merged commit d22fbdc into main Dec 17, 2024
42 checks passed
@priyanshi-yb priyanshi-yb deleted the priyanshi/fix-redacting-pass branch December 17, 2024 10:10
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.

[Voyager] Redact password while logging connection param details during import data
2 participants