From 4daa71b6be0b16dc3024badf1df7cdb7b17bc3fb Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 10 Mar 2025 11:41:09 +0800 Subject: [PATCH 01/12] fix: add 255 length password test case --- tests/army/cmdline/data/pwdMax.txt | 1 + tests/army/cmdline/taosCli.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 tests/army/cmdline/data/pwdMax.txt diff --git a/tests/army/cmdline/data/pwdMax.txt b/tests/army/cmdline/data/pwdMax.txt new file mode 100644 index 0000000000..fc4f96abba --- /dev/null +++ b/tests/army/cmdline/data/pwdMax.txt @@ -0,0 +1 @@ +abcdefghigklmnopqrstuvwxyz@ABC1234567aaaaaaaaaaeeeeeeeeeeAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDAAAAEND \ No newline at end of file diff --git a/tests/army/cmdline/taosCli.py b/tests/army/cmdline/taosCli.py index ba52ba97be..804f680c85 100644 --- a/tests/army/cmdline/taosCli.py +++ b/tests/army/cmdline/taosCli.py @@ -213,6 +213,26 @@ class TDTestCase(TBase): rlist = self.taos(arg[0]) if arg[1] != None: self.checkListString(rlist, arg[1]) + + # password + def checkPassword(self): + # 255 char max password + pwd = "" + pwdFile = "cmdline/data/pwdMax.txt" + with open(pwdFile) as file: + pwd = file.readline() + + sql = f"create user dkj pass '{pwd}' " + tdSql.execute(sql) + + cmds = [ + f"-udkj -p{pwd} -s show databases;", # command pass + f"-udkj -p < {pwdFile} -s show databases;" # input pass + ] + + for cmd in cmds: + rlist = self.taos(cmd) + self.checkListString("Query OK,") # run def run(self): @@ -236,6 +256,9 @@ class TDTestCase(TBase): # check data in/out self.checkDumpInOut() + # max password + self.checkPassword() + tdLog.success(f"{__file__} successfully executed") From 6c25d88f143c3e46b25bb2477db732821f45e766 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 10 Mar 2025 11:54:18 +0800 Subject: [PATCH 02/12] fix: scanf set length from 128 to 255 --- tests/army/cmdline/taosCli.py | 6 +++--- tools/shell/src/shellArguments.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/army/cmdline/taosCli.py b/tests/army/cmdline/taosCli.py index 804f680c85..179dfb6831 100644 --- a/tests/army/cmdline/taosCli.py +++ b/tests/army/cmdline/taosCli.py @@ -226,13 +226,13 @@ class TDTestCase(TBase): tdSql.execute(sql) cmds = [ - f"-udkj -p{pwd} -s show databases;", # command pass - f"-udkj -p < {pwdFile} -s show databases;" # input pass + f"-udkj -p{pwd} -s 'show databases;'", # command pass + f"-udkj -p < {pwdFile} -s 'show databases;'" # input pass ] for cmd in cmds: rlist = self.taos(cmd) - self.checkListString("Query OK,") + self.checkListString(rlist, "Query OK,") # run def run(self): diff --git a/tools/shell/src/shellArguments.c b/tools/shell/src/shellArguments.c index 93381b4f51..0c5a11d3b5 100644 --- a/tools/shell/src/shellArguments.c +++ b/tools/shell/src/shellArguments.c @@ -337,7 +337,7 @@ static void shellInitArgs(int argc, char *argv[]) { if (strlen(argv[i]) == 2) { printf("Enter password: "); taosSetConsoleEcho(false); - if (scanf("%128s", shell.args.password) > 1) { + if (scanf("%255s", shell.args.password) > 1) { fprintf(stderr, "password reading error\n"); } taosSetConsoleEcho(true); From 7c13d742c6ab1202d3c47a06df2e79925a82caa4 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 10 Mar 2025 14:15:08 +0800 Subject: [PATCH 03/12] enh: taosdump extend password length from 128 to 255 --- .../taosdump/native/taosdumpCommandline.py | 27 +++++++++++++++++++ tools/taos-tools/inc/bench.h | 2 +- tools/taos-tools/inc/dump.h | 3 ++- tools/taos-tools/inc/toolsdef.h | 2 +- tools/taos-tools/src/taosdump.c | 3 +-- 5 files changed, 32 insertions(+), 5 deletions(-) diff --git a/tests/army/tools/taosdump/native/taosdumpCommandline.py b/tests/army/tools/taosdump/native/taosdumpCommandline.py index c43ea0e9e7..a3ee8e55ed 100644 --- a/tests/army/tools/taosdump/native/taosdumpCommandline.py +++ b/tests/army/tools/taosdump/native/taosdumpCommandline.py @@ -214,6 +214,27 @@ class TDTestCase(TBase): self.checkExcept(taosdump + f" -t 2 -k 2 -z 1 -C https://not-exist.com:80/cloud -D test -o {tmpdir}") self.checkExcept(taosdump + f" -P 65536") + # password + def checkPassword(self, tmpdir): + # 255 char max password + pwd = "" + pwdFile = "cmdline/data/pwdMax.txt" + with open(pwdFile) as file: + pwd = file.readline() + + sql = f"create user dkj pass '{pwd}' " + tdSql.execute(sql) + + cmds = [ + f"-udkj -p{pwd} -D test -o {tmpdir}", # command pass + f"-udkj -p < {pwdFile} -D test -o {tmpdir}" # input pass + ] + + for cmd in cmds: + self.clearPath(tmpdir) + rlist = self.taosdump(cmd) + self.checkListString(rlist, "OK: Database test dumped") + # run def run(self): @@ -249,6 +270,12 @@ class TDTestCase(TBase): self.dumpInOutMode("", db , json, tmpdir) tdLog.info("4. native varbinary geometry ........................... [Passed]") + # + # long password + # + self.checkPassword(tmpdir) + tdLog.info("5. check long password ................................. [Passed]") + def stop(self): tdSql.close() diff --git a/tools/taos-tools/inc/bench.h b/tools/taos-tools/inc/bench.h index c413d953b7..17e381ffb5 100644 --- a/tools/taos-tools/inc/bench.h +++ b/tools/taos-tools/inc/bench.h @@ -152,7 +152,7 @@ typedef unsigned __int32 uint32_t; #define MAX_JSON_BUFF 6400000 -#define INPUT_BUF_LEN 256 +#define INPUT_BUF_LEN 512 #define EXTRA_SQL_LEN 256 #define DATATYPE_BUFF_LEN (TINY_BUFF_LEN * 3) #define SML_MAX_BATCH 65536 * 32 diff --git a/tools/taos-tools/inc/dump.h b/tools/taos-tools/inc/dump.h index b21dca4343..b76727fbef 100644 --- a/tools/taos-tools/inc/dump.h +++ b/tools/taos-tools/inc/dump.h @@ -39,6 +39,7 @@ #include #include #include +#include #ifdef WEBSOCKET #include @@ -336,7 +337,7 @@ typedef struct arguments { // connection option char *host; char *user; - char password[SHELL_MAX_PASSWORD_LEN]; + char password[TSDB_USET_PASSWORD_LONGLEN]; uint16_t port; // strlen(taosdump.) +1 is 10 char outpath[DUMP_DIR_LEN]; diff --git a/tools/taos-tools/inc/toolsdef.h b/tools/taos-tools/inc/toolsdef.h index ed17380251..b9c0c889ad 100644 --- a/tools/taos-tools/inc/toolsdef.h +++ b/tools/taos-tools/inc/toolsdef.h @@ -77,7 +77,7 @@ extern "C" { #define TSDB_DEFAULT_PASS "taosdata" #define TSDB_PASS_LEN 129 -#define SHELL_MAX_PASSWORD_LEN TSDB_PASS_LEN + #define TSDB_TIME_PRECISION_MILLI 0 #define TSDB_TIME_PRECISION_MICRO 1 diff --git a/tools/taos-tools/src/taosdump.c b/tools/taos-tools/src/taosdump.c index 35fae99c6a..e26d14aae1 100644 --- a/tools/taos-tools/src/taosdump.c +++ b/tools/taos-tools/src/taosdump.c @@ -784,8 +784,7 @@ static void parse_args( } setConsoleEcho(true); } else { - tstrncpy(arguments->password, (char *)(argv[i] + 2), - SHELL_MAX_PASSWORD_LEN); + strcpy(arguments->password, (char *)(argv[i] + 2)); strcpy(argv[i], "-p"); } } else if (strcmp(argv[i], "-n") == 0) { From 3418a1d6f5ab20fdbac4140262c2ff7ef0e82973 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 10 Mar 2025 14:20:09 +0800 Subject: [PATCH 04/12] fix: define TSDB_USET_PASSWORD_LONGLEN 256 --- tools/taos-tools/inc/dump.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/taos-tools/inc/dump.h b/tools/taos-tools/inc/dump.h index b76727fbef..9a30ebb9cd 100644 --- a/tools/taos-tools/inc/dump.h +++ b/tools/taos-tools/inc/dump.h @@ -39,7 +39,6 @@ #include #include #include -#include #ifdef WEBSOCKET #include @@ -59,6 +58,7 @@ #define NEED_CALC_COUNT UINT64_MAX #define HUMAN_TIME_LEN 28 #define DUMP_DIR_LEN (MAX_DIR_LEN - (TSDB_DB_NAME_LEN + 10)) +#define TSDB_USET_PASSWORD_LONGLEN 256 // come from tdef.h #define debugPrint(fmt, ...) \ From d3931bfb5f5c8f2fe4e14738b771ef5dbccc682c Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Mon, 10 Mar 2025 14:45:18 +0800 Subject: [PATCH 05/12] fix: taosdump scanf extend to 255 bytes --- tools/taos-tools/src/taosdump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/taos-tools/src/taosdump.c b/tools/taos-tools/src/taosdump.c index e26d14aae1..0d4369d71c 100644 --- a/tools/taos-tools/src/taosdump.c +++ b/tools/taos-tools/src/taosdump.c @@ -778,7 +778,7 @@ static void parse_args( || (strncmp(argv[i], "--password", 10) == 0)) { printf("Enter password: "); setConsoleEcho(false); - if (scanf("%20s", arguments->password) > 1) { + if (scanf("%255s", arguments->password) > 1) { errorPrint("%s() LN%d, password read error!\n", __func__, __LINE__); } From d0486fa7610aa56ec17e7d5d0a7c1e98e5e0beef Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 13 Mar 2025 09:14:57 +0800 Subject: [PATCH 06/12] move check password no 1 --- .../taosdump/native/taosdumpCommandline.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/tests/army/tools/taosdump/native/taosdumpCommandline.py b/tests/army/tools/taosdump/native/taosdumpCommandline.py index a3ee8e55ed..5680bc3483 100644 --- a/tests/army/tools/taosdump/native/taosdumpCommandline.py +++ b/tests/army/tools/taosdump/native/taosdumpCommandline.py @@ -245,20 +245,26 @@ class TDTestCase(TBase): # insert data with taosBenchmark db, stb, childCount, insertRows = self.insertData(json) + # + # long password + # + self.checkPassword(tmpdir) + tdLog.info("1. check long password ................................. [Passed]") + # dumpInOut modes = ["", "-R" , "--cloud=http://localhost:6041"] for mode in modes: self.dumpInOutMode(mode, db , json, tmpdir) - tdLog.info("1. native rest ws dumpIn Out .......................... [Passed]") + tdLog.info("2. native rest ws dumpIn Out .......................... [Passed]") # basic commandline self.basicCommandLine(tmpdir) - tdLog.info("2. basic command line .................................. [Passed]") + tdLog.info("3. basic command line .................................. [Passed]") # except commandline self.exceptCommandLine(taosdump, db, stb, tmpdir) - tdLog.info("3. except command line ................................. [Passed]") + tdLog.info("4. except command line ................................. [Passed]") # # varbinary and geometry for native @@ -268,13 +274,8 @@ class TDTestCase(TBase): db, stb, childCount, insertRows = self.insertData(json) # dump in/out self.dumpInOutMode("", db , json, tmpdir) - tdLog.info("4. native varbinary geometry ........................... [Passed]") + tdLog.info("5. native varbinary geometry ........................... [Passed]") - # - # long password - # - self.checkPassword(tmpdir) - tdLog.info("5. check long password ................................. [Passed]") def stop(self): From 88c562b3badb5d24ab3adb2a90b467ccb9d2795e Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 13 Mar 2025 09:56:42 +0800 Subject: [PATCH 07/12] test: with short password test --- tests/army/cmdline/data/pwdMax.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/army/cmdline/data/pwdMax.txt b/tests/army/cmdline/data/pwdMax.txt index fc4f96abba..650a40a133 100644 --- a/tests/army/cmdline/data/pwdMax.txt +++ b/tests/army/cmdline/data/pwdMax.txt @@ -1 +1 @@ -abcdefghigklmnopqrstuvwxyz@ABC1234567aaaaaaaaaaeeeeeeeeeeAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDAAAAEND \ No newline at end of file +abcdefghigklmnopqrstuvwxyz@ABC1234567a \ No newline at end of file From 4078c58ee712b1818d2c51b4337a975f4afc4029 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 13 Mar 2025 16:49:38 +0800 Subject: [PATCH 08/12] test: restore to default user password --- tests/army/cmdline/data/pwdMax.txt | 2 +- tests/army/tools/taosdump/native/taosdumpCommandline.py | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/army/cmdline/data/pwdMax.txt b/tests/army/cmdline/data/pwdMax.txt index 650a40a133..fc4f96abba 100644 --- a/tests/army/cmdline/data/pwdMax.txt +++ b/tests/army/cmdline/data/pwdMax.txt @@ -1 +1 @@ -abcdefghigklmnopqrstuvwxyz@ABC1234567a \ No newline at end of file +abcdefghigklmnopqrstuvwxyz@ABC1234567aaaaaaaaaaeeeeeeeeeeAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDAAAAEND \ No newline at end of file diff --git a/tests/army/tools/taosdump/native/taosdumpCommandline.py b/tests/army/tools/taosdump/native/taosdumpCommandline.py index 5680bc3483..cd9c6777c9 100644 --- a/tests/army/tools/taosdump/native/taosdumpCommandline.py +++ b/tests/army/tools/taosdump/native/taosdumpCommandline.py @@ -224,10 +224,11 @@ class TDTestCase(TBase): sql = f"create user dkj pass '{pwd}' " tdSql.execute(sql) - + + pwd = "taosdata" cmds = [ - f"-udkj -p{pwd} -D test -o {tmpdir}", # command pass - f"-udkj -p < {pwdFile} -D test -o {tmpdir}" # input pass + f"-uroot -p{pwd} -D test -o {tmpdir}", # command pass + f"-uroot -p < {pwdFile} -D test -o {tmpdir}" # input pass ] for cmd in cmds: From fbc274b41a4fd4780126dea7859987ceef0a90b3 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Thu, 13 Mar 2025 17:40:13 +0800 Subject: [PATCH 09/12] fix: create user no read privilage on enterprise version --- .../army/tools/taosdump/native/taosdumpCommandline.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/army/tools/taosdump/native/taosdumpCommandline.py b/tests/army/tools/taosdump/native/taosdumpCommandline.py index cd9c6777c9..6cf9acf4b2 100644 --- a/tests/army/tools/taosdump/native/taosdumpCommandline.py +++ b/tests/army/tools/taosdump/native/taosdumpCommandline.py @@ -217,18 +217,21 @@ class TDTestCase(TBase): # password def checkPassword(self, tmpdir): # 255 char max password + user = "dkj" pwd = "" pwdFile = "cmdline/data/pwdMax.txt" with open(pwdFile) as file: pwd = file.readline() - sql = f"create user dkj pass '{pwd}' " + sql = f"create user {user} pass '{pwd}' " + tdSql.execute(sql) + # enterprise must set + sql = f"grant read on test to {user}" tdSql.execute(sql) - pwd = "taosdata" cmds = [ - f"-uroot -p{pwd} -D test -o {tmpdir}", # command pass - f"-uroot -p < {pwdFile} -D test -o {tmpdir}" # input pass + f"-u{user} -p{pwd} -D test -o {tmpdir}", # command pass + f"-u{user} -p < {pwdFile} -D test -o {tmpdir}" # input pass ] for cmd in cmds: From 993015a8d5868567375f24027fb0a267900b0b18 Mon Sep 17 00:00:00 2001 From: Alex Duan <417921451@qq.com> Date: Fri, 14 Mar 2025 11:35:10 +0800 Subject: [PATCH 10/12] enh: password include special char --- tests/army/cmdline/data/pwdMax.txt | 2 +- tests/army/cmdline/taosCli.py | 7 ++++--- tests/army/tools/taosdump/native/taosdumpCommandline.py | 6 ++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/army/cmdline/data/pwdMax.txt b/tests/army/cmdline/data/pwdMax.txt index fc4f96abba..4fb9e048cb 100644 --- a/tests/army/cmdline/data/pwdMax.txt +++ b/tests/army/cmdline/data/pwdMax.txt @@ -1 +1 @@ -abcdefghigklmnopqrstuvwxyz@ABC1234567aaaaaaaaaaeeeeeeeeeeAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDAAAAEND \ No newline at end of file +abcdefghigklmnopqrstuvwxyz@ABCDEFGHIGKLMNOPQRSTUVWXYZ123456789!@#$%^&*()-_+=[]{}:;> Date: Fri, 14 Mar 2025 12:48:27 +0800 Subject: [PATCH 11/12] fix: -p must with single quotes --- tests/army/cmdline/data/pwdMax.txt | 2 +- tests/army/cmdline/taosCli.py | 2 +- tests/army/tools/taosdump/native/taosdumpCommandline.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/army/cmdline/data/pwdMax.txt b/tests/army/cmdline/data/pwdMax.txt index 4fb9e048cb..333b793fe8 100644 --- a/tests/army/cmdline/data/pwdMax.txt +++ b/tests/army/cmdline/data/pwdMax.txt @@ -1 +1 @@ -abcdefghigklmnopqrstuvwxyz@ABCDEFGHIGKLMNOPQRSTUVWXYZ123456789!@#$%^&*()-_+=[]{}:;> Date: Fri, 14 Mar 2025 13:17:32 +0800 Subject: [PATCH 12/12] fi: .gitignore remove *.txt taos-tools filter --- .gitignore | 2 -- tools/taos-tools/inc/toolsdef.h | 3 --- 2 files changed, 5 deletions(-) diff --git a/.gitignore b/.gitignore index ff27b53139..cd1cac4a6d 100644 --- a/.gitignore +++ b/.gitignore @@ -51,7 +51,6 @@ pysim/ tests/script/api/batchprepare taosadapter taosadapter-debug -tools/taos-tools/* tools/taosws-rs/* tools/taosadapter/* tools/upx* @@ -140,7 +139,6 @@ tags *CMakeCache* *CMakeFiles* .history/ -*.txt *.tcl *.pc contrib/geos diff --git a/tools/taos-tools/inc/toolsdef.h b/tools/taos-tools/inc/toolsdef.h index b9c0c889ad..cf982a773e 100644 --- a/tools/taos-tools/inc/toolsdef.h +++ b/tools/taos-tools/inc/toolsdef.h @@ -76,9 +76,6 @@ extern "C" { #define TSDB_DEFAULT_USER "root" #define TSDB_DEFAULT_PASS "taosdata" -#define TSDB_PASS_LEN 129 - - #define TSDB_TIME_PRECISION_MILLI 0 #define TSDB_TIME_PRECISION_MICRO 1 #define TSDB_TIME_PRECISION_NANO 2