-
Notifications
You must be signed in to change notification settings - Fork 66
*: redact log and error messages, add log-redact parameter #538
Conversation
@@ -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)) |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Please also fix the failed unit test |
@glorv PTAL again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
LGTM |
@lichunzhu please add |
updated |
* add --redact-log parameter and redact sensitive log * remove sensitive info in error
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?
redact-log
parameter. When it's set totrue
, all sensitive info will be deleted from logs.Check List
Tests
Side effects
Related changes
Release Note