-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
*: hide secure information in SHOW PROCESSLIST #4451
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
da72bc3
*: hide secure information in SHOW PROCESSLIST
tiancaiamao 91658b5
address comment
tiancaiamao a27e5fe
Merge branch 'master' into processlist-password
tiancaiamao 5e453ff
update comment
tiancaiamao fed8aa6
address comment
tiancaiamao 26f3f35
Merge branch 'master' into processlist-password
tiancaiamao e36e8e8
Merge branch 'master' into processlist-password
tiancaiamao 54ed5c3
Merge branch 'master' into tiancaiamao/processlist-password
zimulala 3f68d3f
Merge branch 'master' into tiancaiamao/processlist-password
tiancaiamao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,9 @@ | |
package ast | ||
|
||
import ( | ||
"bytes" | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/pingcap/tidb/context" | ||
"github.com/pingcap/tidb/model" | ||
|
@@ -406,6 +408,11 @@ type SetPwdStmt struct { | |
Password string | ||
} | ||
|
||
// SecureString overloads Node interface method. | ||
func (n *SetPwdStmt) SecureString() string { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SecureText or SecureString? |
||
return fmt.Sprintf("set password for user %s", n.User) | ||
} | ||
|
||
// Accept implements Node Accept interface. | ||
func (n *SetPwdStmt) Accept(v Visitor) (Node, bool) { | ||
newNode, skipChildren := v.Enter(n) | ||
|
@@ -455,6 +462,17 @@ func (n *CreateUserStmt) Accept(v Visitor) (Node, bool) { | |
return v.Leave(n) | ||
} | ||
|
||
// SecureString overloads Node interface method. | ||
func (n *CreateUserStmt) SecureString() string { | ||
var buf bytes.Buffer | ||
buf.WriteString("create user") | ||
for _, user := range n.Specs { | ||
buf.WriteString(" ") | ||
buf.WriteString(user.SecurityString()) | ||
} | ||
return buf.String() | ||
} | ||
|
||
// AlterUserStmt modifies user account. | ||
// See https://dev.mysql.com/doc/refman/5.7/en/alter-user.html | ||
type AlterUserStmt struct { | ||
|
@@ -465,6 +483,17 @@ type AlterUserStmt struct { | |
Specs []*UserSpec | ||
} | ||
|
||
// SecureString overloads Node interface method. | ||
func (n *AlterUserStmt) SecureString() string { | ||
var buf bytes.Buffer | ||
buf.WriteString("alter user") | ||
for _, user := range n.Specs { | ||
buf.WriteString(" ") | ||
buf.WriteString(user.SecurityString()) | ||
} | ||
return buf.String() | ||
} | ||
|
||
// Accept implements Node Accept interface. | ||
func (n *AlterUserStmt) Accept(v Visitor) (Node, bool) { | ||
newNode, skipChildren := v.Enter(n) | ||
|
@@ -649,6 +678,17 @@ type GrantStmt struct { | |
WithGrant bool | ||
} | ||
|
||
// SecureString overloads Node interface method. | ||
func (n *GrantStmt) SecureString() string { | ||
text := n.text | ||
// Filter "identified by xxx" because it would expose password information. | ||
idx := strings.Index(strings.ToLower(text), "identified") | ||
if idx > 0 { | ||
text = text[:idx] | ||
} | ||
return text | ||
} | ||
|
||
// Accept implements Node Accept interface. | ||
func (n *GrantStmt) Accept(v Visitor) (Node, bool) { | ||
newNode, skipChildren := v.Enter(n) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think this method should not be put in Node interface.
How about defining a CrusialStmt interface which only has a SecureText method?
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.
So we implement
SecureText()
for so manyand most of those implemention is just ... ?
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.
Well, not all crucial statement need to have secure text.
Then how about define a
SensitiveStatement
which hasSecureText
?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.
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.
Could we add SecureText to StmtNode interface?
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.
@shenli
SecureText
only needed by 4 statements, I think adding it to all StmtNode is not worthy.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.
ok