Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

*: redact log and error messages, add log-redact parameter #538

Merged
merged 7 commits into from
Dec 28, 2020

Conversation

lichunzhu
Copy link
Contributor

@lichunzhu lichunzhu commented Dec 25, 2020

What problem does this PR solve?

Current tidb-lightning will print some sensitive information in log and error messages.

What is changed and how it works?

  1. add redact-log parameter. When it's set to true, all sensitive info will be deleted from logs.
  2. Remove sensitive info in error messages and print them to logs.

Check List

Tests

  • Unit test
  • Integration test

Side effects

  • Has exported function/method change
  • Has exported variable/fields change

Related changes

  • Need to cherry-pick to the release branch
  • Need to update the documentation

Release Note

  • support --redact-log parameter to redact sensitive info in log

@lichunzhu lichunzhu added the status/PTAL This PR is ready for review. Add this label back after committing new changes label Dec 25, 2020
@@ -359,7 +359,7 @@ func (be *tidbBackend) WriteRows(ctx context.Context, _ uuid.UUID, tableName str
_, err := be.db.ExecContext(ctx, insertStmt.String())
if err != nil {
log.L().Error("execute statement failed", zap.String("stmt", insertStmt.String()),
zap.Array("rows", rows), zap.Error(err))
log.ZapRedactArray("rows", rows), zap.Error(err))
Copy link
Contributor

Choose a reason for hiding this comment

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

The stmt should be redacted too since it contains the rawData

@@ -44,6 +44,8 @@ type Config struct {
FileMaxDays int `toml:"max-days" json:"max-days"`
// Maximum number of old log files to retain.
FileMaxBackups int `toml:"max-backups" json:"max-backups"`
// Redact sensitive logs during the whole process
RedactLog bool `toml:"redact-log" json:"redact-log"`
Copy link
Contributor

Choose a reason for hiding this comment

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

We should allow config this field from toml too

// See the License for the specific language governing permissions and
// limitations under the License.

package log
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we directly shall the package in br? Since they should be almost the same

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Some functions are not implemented in br's package. Since these two repositories are going to be merged together, I think we can do the refactor at that time to avoid update the dependencies now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@overvenus FYI about this task.

@glorv
Copy link
Contributor

glorv commented Dec 28, 2020

Please also fix the failed unit test

@lichunzhu
Copy link
Contributor Author

@glorv PTAL again

Copy link
Collaborator

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-srebot ti-srebot added the status/LGT1 One reviewer already commented LGTM (LGTM1) label Dec 28, 2020
@glorv
Copy link
Contributor

glorv commented Dec 28, 2020

LGTM

@ti-srebot ti-srebot removed the status/LGT1 One reviewer already commented LGTM (LGTM1) label Dec 28, 2020
@ti-srebot ti-srebot added the status/LGT2 Two reviewers already commented LGTM, ready for merge (LGTM2) label Dec 28, 2020
@glorv glorv added the Should Update Docs Should update docs after this PR is merged. Remove this label once the docs are updated label Dec 28, 2020
@glorv
Copy link
Contributor

glorv commented Dec 28, 2020

@lichunzhu please add Release Note to the pr description

@lichunzhu
Copy link
Contributor Author

updated

@lichunzhu lichunzhu merged commit 1c04266 into pingcap:master Dec 28, 2020
@lichunzhu lichunzhu deleted the desentilize-log branch December 28, 2020 09:49
glorv pushed a commit that referenced this pull request Jan 29, 2021
* add --redact-log parameter and redact sensitive log
* remove sensitive info in error
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Should Update Docs Should update docs after this PR is merged. Remove this label once the docs are updated status/LGT2 Two reviewers already commented LGTM, ready for merge (LGTM2) status/PTAL This PR is ready for review. Add this label back after committing new changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants