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

executor, sessionctx: add checks for system variable validate_password_xxxx #8227

Merged
merged 9 commits into from Nov 26, 2018

Conversation

Projects
None yet
6 participants
@alapha23
Contributor

alapha23 commented Nov 7, 2018

What problem does this PR solve?

Corresponding to Issue #7195, I added correctness check for system variables: validate_password_number_count, validate_password_special_char_count, validate_password_length, validate_password_mixed_case_count, validate_password_policy.

What is changed and how it works?

Executor and sessionctx are modified according to the framework mentioned in #7117

Tests

  • Unit test

This change is Reviewable

@sre-bot

This comment has been minimized.

sre-bot commented Nov 7, 2018

Hi contributor, thanks for your PR.

This patch needs to be approved by someone of admins. They should reply with "/ok-to-test" to accept this PR for running test automatically.

@shenli shenli added the contribution label Nov 7, 2018

@shenli

This comment has been minimized.

Member

shenli commented Nov 7, 2018

@alapha23 Thanks for your contribution!
Please fix the CI.

@shenli

This comment has been minimized.

Member

shenli commented Nov 20, 2018

@alapha23 A friendly ping. Any update?

@lysu lysu self-requested a review Nov 21, 2018

@lysu lysu force-pushed the alapha23:check_sysvar branch from 6094dc8 to 16ae0a1 Nov 21, 2018

@lysu

This comment has been minimized.

Member

lysu commented Nov 21, 2018

/run-all-tests

Show resolved Hide resolved go.mod Outdated

@alapha23 alapha23 force-pushed the alapha23:check_sysvar branch from 16ae0a1 to 71e3df1 Nov 21, 2018

@lysu

This comment has been minimized.

Member

lysu commented Nov 22, 2018

@alapha23 please fix CI caused by new testcase, thanks

set_test.go:529:
    tk.MustExec("set @@global.validate_password_policy=-1")
/go/src/github.com/pingcap/tidb/util/testkit/testkit.go:167:
    tk.c.Assert(err, check.IsNil, check.Commentf("sql:%s, %v, error stack %v", sql, args, errors.ErrorStack(err)))
... value *errors.withStack = [variable:1231]Variable 'validate_password_policy' can't be set to the value of '-1' ("[variable:1231]Variable 'validate_password_policy' can't be set to the value of '-1'")
... sql:set @@global.validate_password_policy=-1, [], error stack [variable:1231]Variable 'validate_password_policy' can't be set to the value of '-1'

https://dev.mysql.com/doc/refman/8.0/en/validate-password-options-variables.html#sysvar_validate_password_policy

@alapha23 alapha23 force-pushed the alapha23:check_sysvar branch from c9b47e7 to 6d70839 Nov 22, 2018

@alapha23 alapha23 force-pushed the alapha23:check_sysvar branch from abd2502 to 54302f2 Nov 22, 2018

alapha23 added some commits Nov 22, 2018

fmt
@lysu

This comment has been minimized.

Member

lysu commented Nov 22, 2018

/run-all-tests

@XuHuaiyu XuHuaiyu changed the title from Add checks for system variable validate_password_xxxx to executor, sessionctx: add checks for system variable validate_password_xxxx Nov 22, 2018

@@ -269,7 +270,6 @@ var defaultSysVars = []*SysVar{
{ScopeNone, "performance_schema_max_file_classes", "50"},
{ScopeGlobal, "expire_logs_days", "0"},
{ScopeGlobal | ScopeSession, "binlog_rows_query_log_events", "OFF"},
{ScopeGlobal, "validate_password_policy", "1"},

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Nov 22, 2018

Contributor

why do we remove this?

This comment has been minimized.

@alapha23

alapha23 Nov 22, 2018

Contributor

According to mysql reference, This validate_password plugin system variable is deprecated and will be removed in a future version of MySQL.
So I presume we will not need it in the future. What do you think?

This comment has been minimized.

@zz-jason

zz-jason Nov 26, 2018

Member

@alapha23 I think we can discuss whether to remove these unused variables in another PR. For this PR, let's focused on the validation of validate_password_number_count and validate_password_length.

@zz-jason

This comment has been minimized.

Member

zz-jason commented Nov 26, 2018

@alapha23 pingcap/parser#25 has been merged, could you update go.mod to point to the latest pingcap/parser?

tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect validate_password_number_count value: '-1'"))
tk.MustExec("set @@global.validate_password_length=-1")
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect validate_password_length value: '-1'"))

This comment has been minimized.

@zz-jason

zz-jason Nov 26, 2018

Member

It's better to add some positive test cases. For example: set @@global.validate_password_number_count=8

This comment has been minimized.

@alapha23

alapha23 Nov 26, 2018

Contributor

Thank you. I'll do that

This comment has been minimized.

@alapha23

alapha23 Nov 26, 2018

Contributor

I am quite confused since reference doesn't set an upper bound on validate_password_number_count, are you suggesting that it is an error when validate_password_number_count=8?

This comment has been minimized.

@zz-jason

zz-jason Nov 26, 2018

Member

No, I mean you can add some following tests:

tk.MustExec("set @@global.validate_password_length=8")
tk.MustQuery("show warnings").Check(testutil.Rows())
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect validate_password_number_count value: '-1'"))
tk.MustExec("set @@global.validate_password_length=-1")
tk.MustQuery("show warnings").Check(testutil.RowsWithSep("|", "Warning|1292|Truncated incorrect validate_password_length value: '-1'"))

This comment has been minimized.

@zz-jason

zz-jason Nov 26, 2018

Member

No, I mean you can add some following tests:

tk.MustExec("set @@global.validate_password_length=8")
tk.MustQuery("show warnings").Check(testutil.Rows())

it's a mistake ..

@alapha23 alapha23 force-pushed the alapha23:check_sysvar branch from 4bb4150 to 2d47a00 Nov 26, 2018

go.mod Outdated
@@ -52,3 +52,5 @@ require (
sourcegraph.com/sourcegraph/appdash v0.0.0-20180531100431-4c381bd170b4
sourcegraph.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
)
replace github.com/pingcap/parser => github.com/alapha23/parser v0.0.0-20181126070418-f5119577d517

This comment has been minimized.

@zz-jason

zz-jason Nov 26, 2018

Member

pingcap/parser#25 is merged, this line should be removed. We should use the latest github.com/pingcap/parser.

@alapha23 alapha23 force-pushed the alapha23:check_sysvar branch from d0f85b3 to b21ba66 Nov 26, 2018

@zz-jason

LGTM

@zz-jason zz-jason added status/LGT2 and removed status/LGT1 labels Nov 26, 2018

@zz-jason zz-jason merged commit 5035e48 into pingcap:master Nov 26, 2018

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment