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

logutil, *: implement log desensitization #3011

Merged
merged 15 commits into from
Sep 24, 2020

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Sep 22, 2020

What problem does this PR solve?

close #2852

Implement log desensitization to omit the region key information from the log.

What is changed and how it works?

Check List

Tests

  • Unit test

Code changes

  • Has configuration change

Related changes

Release note

  • Support configuration enable-redact-log to enable log desensitization or not.

Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
@rleungx
Copy link
Member

rleungx commented Sep 23, 2020

BTW, I think there are more logs which need to be handled.

cmd/pd-server/main.go Outdated Show resolved Hide resolved
@@ -144,6 +144,8 @@ type Config struct {
Dashboard DashboardConfig `toml:"dashboard" json:"dashboard"`

ReplicationMode ReplicationModeConfig `toml:"replication-mode" json:"replication-mode"`
// EnableRedactLog indicates that whether redact log, 0 is disable. 1 is enable.
EnableRedactLog int32 `toml:"enable-redact-log" json:"enable-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.

why not use boolean?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

They use int32 because they need to do atomic operations but we don't. I think we don't have to follow them.

pkg/logutil/log_test.go Outdated Show resolved Hide resolved
pkg/logutil/log.go Outdated Show resolved Hide resolved
@Yisaer
Copy link
Contributor Author

Yisaer commented Sep 23, 2020

BTW, I think there are more logs which need to be handled.

After discussion, only start-key and end-key of the region need to be redacted in the log. @rleungx

server/cluster/cluster.go Outdated Show resolved Hide resolved
@rleungx
Copy link
Member

rleungx commented Sep 23, 2020

BTW, I think there are more logs which need to be handled.

After discussion, only start-key and end-key of the region need to be redacted in the log. @rleungx

Does RegionToHexMeta need to be changed to ??

@nolouch nolouch added the component/log Log. label Sep 23, 2020
@Yisaer Yisaer added the component/security Security logic. label Sep 23, 2020
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
}

// RedactBytesArgIfNeeded receives []byte argument and return omitted information if redact log enabled
func RedactBytesArgIfNeeded(arg []byte) []byte {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks verbose. How about just RedactBytes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated.

Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
@ti-srebot ti-srebot added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 23, 2020
Signed-off-by: Song Gao <disxiaofei@163.com>
Copy link
Member

@HunDunDM HunDunDM left a comment

Choose a reason for hiding this comment

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

How about using a function like func ZapRedact(key string, val interface{}) zap.Field?

pkg/logutil/log.go Outdated Show resolved Hide resolved
pkg/logutil/log.go Show resolved Hide resolved
Signed-off-by: Song Gao <disxiaofei@163.com>
@Yisaer
Copy link
Contributor Author

Yisaer commented Sep 24, 2020

How about using a function like func ZapRedact(key string, val interface{}) zap.Field?

good idea.

@Yisaer Yisaer requested review from rleungx and HunDunDM September 24, 2020 06:10
Signed-off-by: Song Gao <disxiaofei@163.com>
Signed-off-by: Song Gao <disxiaofei@163.com>
Copy link
Member

@HunDunDM HunDunDM 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 removed the status/LGT1 Indicates that a PR has LGTM 1. label Sep 24, 2020
@ti-srebot ti-srebot added the status/LGT2 Indicates that a PR has LGTM 2. label Sep 24, 2020
@Yisaer
Copy link
Contributor Author

Yisaer commented Sep 24, 2020

/merge

@ti-srebot ti-srebot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 24, 2020
@ti-srebot
Copy link
Contributor

/run-all-tests

@ti-srebot ti-srebot merged commit 941b5fe into tikv:master Sep 24, 2020
@Yisaer Yisaer added the needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. label Dec 11, 2020
@Yisaer
Copy link
Contributor Author

Yisaer commented Dec 11, 2020

/cherry-picker

ti-srebot pushed a commit to ti-srebot/pd that referenced this pull request Dec 11, 2020
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
@ti-srebot
Copy link
Contributor

cherry pick to release-4.0 in PR #3266

ti-chi-bot added a commit that referenced this pull request Dec 31, 2020
* cherry pick #3011 to release-4.0

Signed-off-by: ti-srebot <ti-srebot@pingcap.com>

* fix conflict

Signed-off-by: Song Gao <disxiaofei@163.com>

* fix conflict

Signed-off-by: Song Gao <disxiaofei@163.com>

Co-authored-by: Song Gao <disxiaofei@163.com>
Co-authored-by: Ti Prow Robot <71242396+ti-community-prow-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/log Log. component/security Security logic. needs-cherry-pick-release-4.0 The PR needs to cherry pick to release-4.0 branch. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

log: requesting log desensitization
6 participants