1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-05-28 12:41:31 +03:00

Add --unsafe-testing invocation option to CLI. Needs some tests added and changed.

FossilOrigin-Name: b3d9ac052d5c2dd1afeeeb5c9cfac9dd91a1b8d6a74a2ef10aa2037ca505abce
This commit is contained in:
larrybr 2023-04-22 16:46:38 +00:00
parent a9c4c82ef1
commit e945b29359
3 changed files with 36 additions and 8 deletions

View File

@ -1,5 +1,5 @@
C Fix\san\sincorrect\sassert()\sstatement\sin\sbtree.c\sas\sfound\sby\n[forum:/info/d03345d572713fe6|forum\spost\sd03345d572713fe6].
D 2023-04-22T12:47:16.752
C Add\s--unsafe-testing\sinvocation\soption\sto\sCLI.\sNeeds\ssome\stests\sadded\sand\schanged.
D 2023-04-22T16:46:38.465
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -633,7 +633,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
F src/resolve.c 3e53e02ce87c9582bd7e7d22f13f4094a271678d9dc72820fa257a2abb5e4032
F src/rowset.c ba9515a922af32abe1f7d39406b9d35730ed65efab9443dc5702693b60854c92
F src/select.c f879cef11c462a2c37a8c906932781e384c3bb32042c355a704a043029c90d27
F src/shell.c.in dffb9fd88cd10b64267077edb98cb6792a014dc89dd34891b8f3a45906b6a16d
F src/shell.c.in f85b07dc6d75d17217f6a842fa9c43c6ef6db6551b51be76055b814fe7a24376
F src/sqlite.h.in 4fff9c6cc5d4cbba9532a668112efb6dc469c425e1a2196664d7c07d508363ef
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h da473ce2b3d0ae407a6300c4a164589b9a6bfdbec9462688a8593ff16f3bb6e4
@ -2059,8 +2059,11 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 53a61f7423a7f057568a1d8a1e63be01a2328997850dc32e3d8c6d51f1c5ab0b
R 5677d2da177f240210053dffbed7c16a
U drh
Z c7873e11c59de450a8f61d4742b32434
P cd485b302c54aef066d751a153df34eea0cd23e54a414e291f636ad9929fe78a
R be58d94e52d56c14dee82adb68874a9b
T *branch * shell-for-test
T *sym-shell-for-test *
T -sym-trunk *
U larrybr
Z a5e6fd5b494a63d53c430515997654b1
# Remove this line to create a well-formed Fossil manifest.

View File

@ -1 +1 @@
cd485b302c54aef066d751a153df34eea0cd23e54a414e291f636ad9929fe78a
b3d9ac052d5c2dd1afeeeb5c9cfac9dd91a1b8d6a74a2ef10aa2037ca505abce

View File

@ -1526,6 +1526,7 @@ static ShellState shellState;
#define SHFLG_HeaderSet 0x00000080 /* showHeader has been specified */
#define SHFLG_DumpDataOnly 0x00000100 /* .dump show data only */
#define SHFLG_DumpNoSys 0x00000200 /* .dump omits system tables */
#define SHFLG_TestingMode 0x00000400 /* allow unsafe testing features */
/*
** Macros for testing and setting shellFlgs
@ -5351,6 +5352,13 @@ static void open_db(ShellState *p, int openFlags){
}
sqlite3_db_config(p->db, SQLITE_DBCONFIG_STMT_SCANSTATUS, (int)0, (int*)0);
/* Reflect the use or absence of --unsafe-testing invocation. */
{
int testmode_on = ShellHasFlag(p,SHFLG_TestingMode);
sqlite3_db_config(p->db, SQLITE_DBCONFIG_TRUSTED_SCHEMA, testmode_on,0);
sqlite3_db_config(p->db, SQLITE_DBCONFIG_DEFENSIVE, !testmode_on,0);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
sqlite3_enable_load_extension(p->db, 1);
#endif
@ -8960,6 +8968,12 @@ static int do_meta_command(char *zLine, ShellState *p){
int isWO = 0; /* True if making an imposter of a WITHOUT ROWID table */
int lenPK = 0; /* Length of the PRIMARY KEY string for isWO tables */
int i;
if( !ShellHasFlag(p,SHFLG_TestingMode) ){
utf8_printf(stderr, ".%s unavailable without --unsafe-testing\n",
"imposter");
rc = 1;
goto meta_command_exit;
}
if( !(nArg==3 || (nArg==2 && sqlite3_stricmp(azArg[1],"off")==0)) ){
utf8_printf(stderr, "Usage: .imposter INDEX IMPOSTER\n"
" .imposter off\n");
@ -10759,6 +10773,12 @@ static int do_meta_command(char *zLine, ShellState *p){
int i, n2;
const char *zCmd = 0;
if( !ShellHasFlag(p,SHFLG_TestingMode) ){
utf8_printf(stderr, ".%s unavailable without --unsafe-testing\n",
"testctrl");
rc = 1;
goto meta_command_exit;
}
open_db(p, 0);
zCmd = nArg>=2 ? azArg[1] : "help";
@ -11758,6 +11778,7 @@ static const char zOptions[] =
" -stats print memory stats before each finalize\n"
" -table set output mode to 'table'\n"
" -tabs set output mode to 'tabs'\n"
" -unsafe-testing allow unsafe commands and modes for testing\n"
#if SHELL_WIN_UTF8_OPT
" -utf8 setup interactive console code page for UTF-8\n"
#endif
@ -12138,6 +12159,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
}else if( cli_strcmp(z,"-nonce")==0 ){
free(data.zNonce);
data.zNonce = strdup(argv[++i]);
}else if( cli_strcmp(z,"-unsafe-testing")==0 ){
ShellSetFlag(&data,SHFLG_TestingMode);
}else if( cli_strcmp(z,"-safe")==0 ){
/* no-op - catch this on the second pass */
}
@ -12374,6 +12397,8 @@ int SQLITE_CDECL wmain(int argc, wchar_t **wargv){
#endif
}else if( cli_strcmp(z,"-safe")==0 ){
data.bSafeMode = data.bSafeModePersist = 1;
}else if( cli_strcmp(z,"-unsafe-testing")==0 ){
/* Acted upon in first pass. */
}else{
utf8_printf(stderr,"%s: Error: unknown option: %s\n", Argv0, z);
raw_printf(stderr,"Use -help for a list of options.\n");