-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
infoschema: improve the security vunerability of TABLE_CONSTRAINTS infoschema #14037
Conversation
/run all tests |
Codecov Report
@@ Coverage Diff @@
## master #14037 +/- ##
===========================================
Coverage 80.2241% 80.2241%
===========================================
Files 482 482
Lines 121087 121087
===========================================
Hits 97141 97141
Misses 16215 16215
Partials 7731 7731 |
/run-all-tests |
infoschema/tables_test.go
Outdated
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.gc_delete_range TO r_gc_delete_range;") | ||
tk.MustExec("GRANT r_gc_delete_range TO constraints_tester;") | ||
constraintsTester.MustExec("set role r_gc_delete_range") | ||
constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='gc_delete_range';").Check(testkit.Rows("def mysql delete_range_index mysql gc_delete_range UNIQUE")) |
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 can check that the result is no empty? The rows may change if we update TABLE_CONSTRAINTS
in future.
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.
Addressed, PTAL
var rows [][]types.Datum | ||
for _, schema := range schemas { | ||
for _, tbl := range schema.Tables { | ||
if checker != nil && !checker.RequestVerification(ctx.GetSessionVars().ActiveRoles, schema.Name.L, tbl.Name.L, "", mysql.AllPrivMask) { |
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.
Use .O
instead of .L
?
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.
it doesn't matter, both can lead to the same thing, the schema.Name.L, tbl.Name.L will be converted to capital letters in this func.
/run-all-tests |
/run-all-tests |
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
tk.MustExec("GRANT ALL PRIVILEGES ON mysql.gc_delete_range TO r_gc_delete_range;") | ||
tk.MustExec("GRANT r_gc_delete_range TO constraints_tester;") | ||
constraintsTester.MustExec("set role r_gc_delete_range") | ||
c.Assert(len(constraintsTester.MustQuery("select * from information_schema.TABLE_CONSTRAINTS where TABLE_NAME='gc_delete_range';").Rows()), Greater, 0) |
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.
What's the exact count of rows? Is it unpredictable?
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 the count of rows doesn't matter here. We want to check that we can read something here but don't care what it is.
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.
it can be predicted, but may be changed in the future, and what we want is whether the data can be query, not what it is.
/run-all-tests |
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
/run-all-tests |
/run-all-tests tidb-test=pr/973 |
What problem does this PR solve?
What is changed and how it works?
before:new user can get the whole data of information_schema.TABLE_CONSTRAINTS
after:the new user can only get an empty set.
Check List
Tests
Code changes
Side effects
None
Related changes
None