diff --git a/CHANGELOG.md b/CHANGELOG.md index d1cb0d61..22d37024 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,17 @@ # pipes-fittings Shared Pipes Component + +## v1.6.2 [2024-10-22] + +_Bug fixes_ + +* Removed buggy database connection string redaction that may cause some JSON string to be invalid. ([#594](https://github.com/turbot/pipe-fittings/issues/594)). + ## v1.6.1 [2024-10-22] _What's new_ + * Support setting a variable of type Connection using a connection string or cloud workspace handle. ([#592](https://github.com/turbot/pipe-fittings/issues/592)). diff --git a/sanitize/sanitizer.go b/sanitize/sanitizer.go index 886fbc6d..fa111dd7 100644 --- a/sanitize/sanitizer.go +++ b/sanitize/sanitizer.go @@ -228,13 +228,15 @@ func (s *Sanitizer) SanitizeString(v string) string { v = v[:r.start] + RedactedStr + v[r.end:] } - v = redactDbConnectionPassword(v) + // found some cases that it causes a JSON string to be invalid, removing for now. The db connection string + // should be redacted by Basic Auth redaction anyway. + // v = redactDbConnectionPassword(v) return v } // The database connection string is also redacted by the Basic Auth redaction, it will actually redact more than the // plain db redaction -func redactDbConnectionPassword(connectionString string) string { +func RedactDbConnectionPassword(connectionString string) string { // Define the regex to match and capture only the password part re := regexp.MustCompile(`(?P[^:]+://)(?P[^:]+):(?P[^@]+)(?P@.+)`) // Replace only the password part with "REDACTED" diff --git a/sanitize/sanitizer_test.go b/sanitize/sanitizer_test.go index 011e4a9f..4361c5a1 100644 --- a/sanitize/sanitizer_test.go +++ b/sanitize/sanitizer_test.go @@ -37,14 +37,14 @@ func TestSanitizer_SanitizeString(t *testing.T) { }, // The database connection string is also redacted by the Basic Auth redaction, it will actually redact more than the // plain db redaction - { - name: "database connection string", - opts: SanitizerOptions{ - ImportCodeMatchers: false, - }, - input: `{"connection":"mysql://user:1234abcd@localhost:3306/db"}`, - want: `{"connection":"mysql://user:` + RedactedStr + `@localhost:3306/db"}`, - }, + // { + // name: "database connection string", + // opts: SanitizerOptions{ + // ImportCodeMatchers: false, + // }, + // input: `{"connection":"mysql://user:1234abcd@localhost:3306/db"}`, + // want: `{"connection":"mysql://user:` + RedactedStr + `@localhost:3306/db"}`, + // }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) {