• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #3546

03 Dec 2024 10:02AM UTC coverage: 60.691% (-0.1%) from 60.839%
#3546

push

travis-ci

web-flow
Merge pull request #29015 from taosdata/fix/TS-5668

[TS-5668] fix(keeper): fix endpoint value too long for column/tag and eliminate warnings

120577 of 253823 branches covered (47.5%)

Branch coverage included in aggregate %.

201666 of 277134 relevant lines covered (72.77%)

18719900.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.86
/source/libs/parser/src/parAuthenticator.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the GNU Affero General Public License, version 3
6
 * or later ("AGPL"), as published by the Free Software Foundation.
7
 *
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
9
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10
 * FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * You should have received a copy of the GNU Affero General Public License
13
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14
 */
15

16
#include "catalog.h"
17
#include "cmdnodes.h"
18
#include "parInt.h"
19

20
typedef struct SAuthCxt {
21
  SParseContext*   pParseCxt;
22
  SParseMetaCache* pMetaCache;
23
  int32_t          errCode;
24
} SAuthCxt;
25

26
typedef struct SSelectAuthCxt {
27
  SAuthCxt*    pAuthCxt;
28
  SSelectStmt* pSelect;
29
} SSelectAuthCxt;
30

31
typedef struct SAuthRewriteCxt {
32
  STableNode* pTarget;
33
} SAuthRewriteCxt;
34

35
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt);
36

37
static int32_t setUserAuthInfo(SParseContext* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
739✔
38
                               bool isView, bool effective, SUserAuthInfo* pAuth) {
39
  if (effective) {
739✔
40
    snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pEffectiveUser ? pCxt->pEffectiveUser : "");
51!
41
  } else {
42
    snprintf(pAuth->user, sizeof(pAuth->user), "%s", pCxt->pUser);
688✔
43
  }
44

45
  if (NULL == pTabName) {
739✔
46
    int32_t code = tNameSetDbName(&pAuth->tbName, pCxt->acctId, pDbName, strlen(pDbName));
74✔
47
    if (TSDB_CODE_SUCCESS != code) return code;
74!
48
  } else {
49
    toName(pCxt->acctId, pDbName, pTabName, &pAuth->tbName);
665✔
50
  }
51
  pAuth->type = type;
739✔
52
  pAuth->isView = isView;
739✔
53
  return TSDB_CODE_SUCCESS;
739✔
54
}
55

56
static int32_t checkAuthImpl(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond,
1,157,923✔
57
                             bool isView, bool effective) {
58
  SParseContext* pParseCxt = pCxt->pParseCxt;
1,157,923✔
59
  if (pParseCxt->isSuperUser) {
1,157,923✔
60
    return TSDB_CODE_SUCCESS;
1,157,182✔
61
  }
62

63
  AUTH_RES_TYPE auth_res_type = isView ? AUTH_RES_VIEW : AUTH_RES_BASIC;
741✔
64
  SUserAuthInfo authInfo = {0};
741✔
65
  int32_t       code = setUserAuthInfo(pCxt->pParseCxt, pDbName, pTabName, type, isView, effective, &authInfo);
741✔
66
  if (TSDB_CODE_SUCCESS != code) return code;
739!
67
  SUserAuthRes authRes = {0};
739✔
68
  if (NULL != pCxt->pMetaCache) {
739!
69
    code = getUserAuthFromCache(pCxt->pMetaCache, &authInfo, &authRes);
739✔
70
#ifdef TD_ENTERPRISE
71
    if (isView && TSDB_CODE_PAR_INTERNAL_ERROR == code) {
739✔
72
      authInfo.isView = false;
80✔
73
      code = getUserAuthFromCache(pCxt->pMetaCache, &authInfo, &authRes);
80✔
74
    }
75
#endif
76
  } else {
77
    SRequestConnInfo conn = {.pTrans = pParseCxt->pTransporter,
×
78
                             .requestId = pParseCxt->requestId,
×
79
                             .requestObjRefId = pParseCxt->requestRid,
×
80
                             .mgmtEps = pParseCxt->mgmtEpSet};
81
    code = catalogChkAuth(pParseCxt->pCatalog, &conn, &authInfo, &authRes);
×
82
  }
83
  if (TSDB_CODE_SUCCESS == code && NULL != pCond) {
739!
84
    *pCond = authRes.pCond[auth_res_type];
536✔
85
  }
86
  return TSDB_CODE_SUCCESS == code ? (authRes.pass[auth_res_type] ? TSDB_CODE_SUCCESS : TSDB_CODE_PAR_PERMISSION_DENIED)
739✔
87
                                   : code;
739!
88
}
89

90
static int32_t checkAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
1,157,394✔
91
  return checkAuthImpl(pCxt, pDbName, pTabName, type, pCond, false, false);
1,157,394✔
92
}
93

94
static int32_t checkEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
35✔
95
                                  SNode** pCond) {
96
  return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, false, true);
35✔
97
}
98

99
static int32_t checkViewAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type, SNode** pCond) {
479✔
100
  return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, false);
479✔
101
}
102

103
static int32_t checkViewEffectiveAuth(SAuthCxt* pCxt, const char* pDbName, const char* pTabName, AUTH_TYPE type,
16✔
104
                                      SNode** pCond) {
105
  return checkAuthImpl(pCxt, pDbName, pTabName, type, NULL, true, true);
16✔
106
}
107

108
static EDealRes authSubquery(SAuthCxt* pCxt, SNode* pStmt) {
210,584✔
109
  return TSDB_CODE_SUCCESS == authQuery(pCxt, pStmt) ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
210,584!
110
}
111

112
static int32_t mergeStableTagCond(SNode** pWhere, SNode* pTagCond) {
1✔
113
  SLogicConditionNode* pLogicCond = NULL;
1✔
114
  int32_t              code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCond);
1✔
115
  if (NULL == pLogicCond) {
1!
116
    return code;
×
117
  }
118
  pLogicCond->node.resType.type = TSDB_DATA_TYPE_BOOL;
1✔
119
  pLogicCond->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes;
1✔
120
  pLogicCond->condType = LOGIC_COND_TYPE_AND;
1✔
121
  code = nodesListMakeStrictAppend(&pLogicCond->pParameterList, pTagCond);
1✔
122
  if (TSDB_CODE_SUCCESS == code) {
1!
123
    code = nodesListMakeAppend(&pLogicCond->pParameterList, *pWhere);
1✔
124
  }
125
  if (TSDB_CODE_SUCCESS == code) {
1!
126
    *pWhere = (SNode*)pLogicCond;
1✔
127
  } else {
128
    nodesDestroyNode((SNode*)pLogicCond);
×
129
  }
130
  return code;
1✔
131
}
132

133
EDealRes rewriteAuthTable(SNode* pNode, void* pContext) {
60✔
134
  if (QUERY_NODE_COLUMN == nodeType(pNode)) {
60✔
135
    SColumnNode*     pCol = (SColumnNode*)pNode;
19✔
136
    SAuthRewriteCxt* pCxt = (SAuthRewriteCxt*)pContext;
19✔
137
    strcpy(pCol->tableName, pCxt->pTarget->tableName);
19✔
138
    strcpy(pCol->tableAlias, pCxt->pTarget->tableAlias);
19✔
139
  }
140

141
  return DEAL_RES_CONTINUE;
60✔
142
}
143

144
static int32_t rewriteAppendStableTagCond(SNode** pWhere, SNode* pTagCond, STableNode* pTable) {
16✔
145
  SNode*  pTagCondCopy = NULL;
16✔
146
  int32_t code = nodesCloneNode(pTagCond, &pTagCondCopy);
16✔
147
  if (NULL == pTagCondCopy) {
16!
148
    return code;
×
149
  }
150

151
  SAuthRewriteCxt cxt = {.pTarget = pTable};
16✔
152
  nodesWalkExpr(pTagCondCopy, rewriteAuthTable, &cxt);
16✔
153

154
  if (NULL == *pWhere) {
16✔
155
    *pWhere = pTagCondCopy;
15✔
156
    return TSDB_CODE_SUCCESS;
15✔
157
  }
158

159
  if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pWhere) &&
1!
160
      LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pWhere)->condType) {
×
161
    return nodesListStrictAppend(((SLogicConditionNode*)*pWhere)->pParameterList, pTagCondCopy);
×
162
  }
163

164
  return mergeStableTagCond(pWhere, pTagCondCopy);
1✔
165
}
166

167
static EDealRes authSelectImpl(SNode* pNode, void* pContext) {
15,544,554✔
168
  SSelectAuthCxt* pCxt = pContext;
15,544,554✔
169
  SAuthCxt*       pAuthCxt = pCxt->pAuthCxt;
15,544,554✔
170
  bool            isView = false;
15,544,554✔
171
  if (QUERY_NODE_REAL_TABLE == nodeType(pNode)) {
15,544,554✔
172
    SNode*      pTagCond = NULL;
962,337✔
173
    STableNode* pTable = (STableNode*)pNode;
962,337✔
174
#ifdef TD_ENTERPRISE
175
    SName name = {0};
962,337✔
176
    toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name);
962,337✔
177
    STableMeta* pTableMeta = NULL;
962,337✔
178
    toName(pAuthCxt->pParseCxt->acctId, pTable->dbName, pTable->tableName, &name);
962,337✔
179
    int32_t code = getTargetMetaImpl(
962,339✔
180
        pAuthCxt->pParseCxt, pAuthCxt->pMetaCache, &name, &pTableMeta, true);
181
    if (TSDB_CODE_SUCCESS == code && TSDB_VIEW_TABLE == pTableMeta->tableType) {
962,327✔
182
      isView = true;
336✔
183
    }
184
    taosMemoryFree(pTableMeta);
962,327✔
185
#endif
186
    if (!isView) {
962,338✔
187
      pAuthCxt->errCode = checkAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, &pTagCond);
962,002✔
188
      if (TSDB_CODE_SUCCESS != pAuthCxt->errCode && NULL != pAuthCxt->pParseCxt->pEffectiveUser) {
962,003✔
189
        pAuthCxt->errCode = checkEffectiveAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL);
35✔
190
      }
191
      if (TSDB_CODE_SUCCESS == pAuthCxt->errCode && NULL != pTagCond) {
962,003✔
192
        pAuthCxt->errCode = rewriteAppendStableTagCond(&pCxt->pSelect->pWhere, pTagCond, pTable);
16✔
193
      }
194
    } else {
195
      pAuthCxt->errCode = checkViewAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL);
336✔
196
      if (TSDB_CODE_SUCCESS != pAuthCxt->errCode && NULL != pAuthCxt->pParseCxt->pEffectiveUser) {
336✔
197
        pAuthCxt->errCode = checkViewEffectiveAuth(pAuthCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_READ, NULL);
16✔
198
      }
199
    }
200
    return TSDB_CODE_SUCCESS == pAuthCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR;
962,339✔
201
  } else if (QUERY_NODE_TEMP_TABLE == nodeType(pNode)) {
14,582,217✔
202
    return authSubquery(pAuthCxt, ((STempTableNode*)pNode)->pSubquery);
210,584✔
203
  }
204
  return DEAL_RES_CONTINUE;
14,371,633✔
205
}
206

207
static int32_t authSelect(SAuthCxt* pCxt, SSelectStmt* pSelect) {
1,163,699✔
208
  SSelectAuthCxt cxt = {.pAuthCxt = pCxt, .pSelect = pSelect};
1,163,699✔
209
  nodesWalkSelectStmt(pSelect, SQL_CLAUSE_FROM, authSelectImpl, &cxt);
1,163,699✔
210
  return pCxt->errCode;
1,163,698✔
211
}
212

213
static int32_t authSetOperator(SAuthCxt* pCxt, SSetOperator* pSetOper) {
62,563✔
214
  int32_t code = authQuery(pCxt, pSetOper->pLeft);
62,563✔
215
  if (TSDB_CODE_SUCCESS == code) {
62,563!
216
    code = authQuery(pCxt, pSetOper->pRight);
62,563✔
217
  }
218
  return code;
62,563✔
219
}
220

221
static int32_t authDropUser(SAuthCxt* pCxt, SDropUserStmt* pStmt) {
49✔
222
  if (!pCxt->pParseCxt->isSuperUser || 0 == strcmp(pStmt->userName, TSDB_DEFAULT_USER)) {
49!
223
    return TSDB_CODE_PAR_PERMISSION_DENIED;
1✔
224
  }
225
  return TSDB_CODE_SUCCESS;
48✔
226
}
227

228
static int32_t authDelete(SAuthCxt* pCxt, SDeleteStmt* pDelete) {
56,534✔
229
  SNode*      pTagCond = NULL;
56,534✔
230
  STableNode* pTable = (STableNode*)pDelete->pFromTable;
56,534✔
231
  int32_t     code = checkAuth(pCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_WRITE, &pTagCond);
56,534✔
232
  if (TSDB_CODE_SUCCESS == code && NULL != pTagCond) {
56,535!
233
    code = rewriteAppendStableTagCond(&pDelete->pWhere, pTagCond, pTable);
×
234
  }
235
  return code;
56,535✔
236
}
237

238
static int32_t authInsert(SAuthCxt* pCxt, SInsertStmt* pInsert) {
158✔
239
  SNode*      pTagCond = NULL;
158✔
240
  STableNode* pTable = (STableNode*)pInsert->pTable;
158✔
241
  // todo check tag condition for subtable
242
  int32_t code = checkAuth(pCxt, pTable->dbName, pTable->tableName, AUTH_TYPE_WRITE, &pTagCond);
158✔
243
  if (TSDB_CODE_SUCCESS == code) {
158!
244
    code = authQuery(pCxt, pInsert->pQuery);
158✔
245
  }
246
  return code;
158✔
247
}
248

249
static int32_t authShowTables(SAuthCxt* pCxt, SShowStmt* pStmt) {
1,911✔
250
  return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, NULL, AUTH_TYPE_READ_OR_WRITE, NULL);
1,911✔
251
}
252

253
static int32_t authShowUsage(SAuthCxt* pCxt, SShowStmt* pStmt) {
×
254
  return checkAuth(pCxt, ((SValueNode*)pStmt->pDbName)->literal, NULL, AUTH_TYPE_READ_OR_WRITE, NULL);
×
255
}
256

257
static int32_t authShowCreateTable(SAuthCxt* pCxt, SShowCreateTableStmt* pStmt) {
143✔
258
  SNode* pTagCond = NULL;
143✔
259
  // todo check tag condition for subtable
260
  return checkAuth(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_READ, &pTagCond);
143✔
261
}
262

263
static int32_t authShowCreateView(SAuthCxt* pCxt, SShowCreateViewStmt* pStmt) {
×
264
#ifndef TD_ENTERPRISE
265
  return TSDB_CODE_OPS_NOT_SUPPORT;
266
#endif
267

268
  return TSDB_CODE_SUCCESS;
×
269
}
270

271
static int32_t authCreateTable(SAuthCxt* pCxt, SCreateTableStmt* pStmt) {
20,081✔
272
  SNode* pTagCond = NULL;
20,081✔
273
  // todo check tag condition for subtable
274
  return checkAuth(pCxt, pStmt->dbName, NULL, AUTH_TYPE_WRITE, &pTagCond);
20,081✔
275
}
276

277
static int32_t authCreateMultiTable(SAuthCxt* pCxt, SCreateMultiTablesStmt* pStmt) {
49,119✔
278
  int32_t code = TSDB_CODE_SUCCESS;
49,119✔
279
  SNode*  pNode = NULL;
49,119✔
280
  FOREACH(pNode, pStmt->pSubTables) {
132,137!
281
    if (pNode->type == QUERY_NODE_CREATE_SUBTABLE_CLAUSE) {
83,021!
282
      SCreateSubTableClause* pClause = (SCreateSubTableClause*)pNode;
83,021✔
283
      code = checkAuth(pCxt, pClause->dbName, NULL, AUTH_TYPE_WRITE, NULL);
83,021✔
284
      if (TSDB_CODE_SUCCESS != code) {
83,019✔
285
        break;
1✔
286
      }
287
    } else {
288
      SCreateSubTableFromFileClause* pClause = (SCreateSubTableFromFileClause*)pNode;
×
289
      code = checkAuth(pCxt, pClause->useDbName, NULL, AUTH_TYPE_WRITE, NULL);
×
290
      if (TSDB_CODE_SUCCESS != code) {
×
291
        break;
×
292
      }
293
    }
294
  }
295
  return code;
49,117✔
296
}
297

298
static int32_t authDropTable(SAuthCxt* pCxt, SDropTableStmt* pStmt) {
17,605✔
299
  int32_t code = TSDB_CODE_SUCCESS;
17,605✔
300
  if (pStmt->withOpt && !pCxt->pParseCxt->isSuperUser) {
17,605✔
301
    return TSDB_CODE_PAR_PERMISSION_DENIED;
2✔
302
  }
303
  SNode* pNode = NULL;
17,603✔
304
  FOREACH(pNode, pStmt->pTables) {
36,111!
305
    SDropTableClause* pClause = (SDropTableClause*)pNode;
18,509✔
306
    code = checkAuth(pCxt, pClause->dbName, pClause->tableName, AUTH_TYPE_WRITE, NULL);
18,509✔
307
    if (TSDB_CODE_SUCCESS != code) {
18,509✔
308
      break;
1✔
309
    }
310
  }
311
  return code;
17,603✔
312
}
313

314
static int32_t authDropStable(SAuthCxt* pCxt, SDropSuperTableStmt* pStmt) {
337✔
315
  if (pStmt->withOpt && !pCxt->pParseCxt->isSuperUser) {
337✔
316
    return TSDB_CODE_PAR_PERMISSION_DENIED;
1✔
317
  }
318
  return checkAuth(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_WRITE, NULL);
336✔
319
}
320

321
static int32_t authAlterTable(SAuthCxt* pCxt, SAlterTableStmt* pStmt) {
14,477✔
322
  SNode* pTagCond = NULL;
14,477✔
323
  // todo check tag condition for subtable
324
  return checkAuth(pCxt, pStmt->dbName, pStmt->tableName, AUTH_TYPE_WRITE, NULL);
14,477✔
325
}
326

327
static int32_t authCreateView(SAuthCxt* pCxt, SCreateViewStmt* pStmt) {
226✔
328
#ifndef TD_ENTERPRISE
329
  return TSDB_CODE_OPS_NOT_SUPPORT;
330
#endif
331
  return checkAuth(pCxt, pStmt->dbName, NULL, AUTH_TYPE_WRITE, NULL);
226✔
332
}
333

334
static int32_t authDropView(SAuthCxt* pCxt, SDropViewStmt* pStmt) {
143✔
335
#ifndef TD_ENTERPRISE
336
  return TSDB_CODE_OPS_NOT_SUPPORT;
337
#endif
338
  return checkViewAuth(pCxt, pStmt->dbName, pStmt->viewName, AUTH_TYPE_ALTER, NULL);
143✔
339
}
340

341
static int32_t authQuery(SAuthCxt* pCxt, SNode* pStmt) {
1,587,864✔
342
  switch (nodeType(pStmt)) {
1,587,864✔
343
    case QUERY_NODE_SET_OPERATOR:
62,563✔
344
      return authSetOperator(pCxt, (SSetOperator*)pStmt);
62,563✔
345
    case QUERY_NODE_SELECT_STMT:
1,163,700✔
346
      return authSelect(pCxt, (SSelectStmt*)pStmt);
1,163,700✔
347
    case QUERY_NODE_DROP_USER_STMT:
49✔
348
      return authDropUser(pCxt, (SDropUserStmt*)pStmt);
49✔
349
    case QUERY_NODE_DELETE_STMT:
56,534✔
350
      return authDelete(pCxt, (SDeleteStmt*)pStmt);
56,534✔
351
    case QUERY_NODE_INSERT_STMT:
158✔
352
      return authInsert(pCxt, (SInsertStmt*)pStmt);
158✔
353
    case QUERY_NODE_CREATE_TABLE_STMT:
20,081✔
354
      return authCreateTable(pCxt, (SCreateTableStmt*)pStmt);
20,081✔
355
    case QUERY_NODE_CREATE_MULTI_TABLES_STMT:
49,119✔
356
      return authCreateMultiTable(pCxt, (SCreateMultiTablesStmt*)pStmt);
49,119✔
357
    case QUERY_NODE_DROP_TABLE_STMT:
17,605✔
358
      return authDropTable(pCxt, (SDropTableStmt*)pStmt);
17,605✔
359
    case QUERY_NODE_DROP_SUPER_TABLE_STMT:
337✔
360
      return authDropStable(pCxt, (SDropSuperTableStmt*)pStmt);
337✔
361
    case QUERY_NODE_ALTER_TABLE_STMT:
14,477✔
362
    case QUERY_NODE_ALTER_SUPER_TABLE_STMT:
363
      return authAlterTable(pCxt, (SAlterTableStmt*)pStmt);
14,477✔
364
    case QUERY_NODE_SHOW_DNODES_STMT:
1,178✔
365
    case QUERY_NODE_SHOW_MNODES_STMT:
366
    case QUERY_NODE_SHOW_MODULES_STMT:
367
    case QUERY_NODE_SHOW_QNODES_STMT:
368
    case QUERY_NODE_SHOW_ANODES_STMT:
369
    case QUERY_NODE_SHOW_ANODES_FULL_STMT:
370
    case QUERY_NODE_SHOW_SNODES_STMT:
371
    case QUERY_NODE_SHOW_BNODES_STMT:
372
    case QUERY_NODE_SHOW_CLUSTER_STMT:
373
    case QUERY_NODE_SHOW_LICENCES_STMT:
374
    case QUERY_NODE_SHOW_VGROUPS_STMT:
375
    case QUERY_NODE_SHOW_DB_ALIVE_STMT:
376
    case QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT:
377
    case QUERY_NODE_SHOW_CREATE_DATABASE_STMT:
378
    case QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT:
379
    case QUERY_NODE_SHOW_DNODE_VARIABLES_STMT:
380
    case QUERY_NODE_SHOW_VNODES_STMT:
381
    case QUERY_NODE_SHOW_SCORES_STMT:
382
    case QUERY_NODE_SHOW_USERS_STMT:
383
    case QUERY_NODE_SHOW_USERS_FULL_STMT:
384
    case QUERY_NODE_SHOW_USER_PRIVILEGES_STMT:
385
    case QUERY_NODE_SHOW_GRANTS_FULL_STMT:
386
    case QUERY_NODE_SHOW_GRANTS_LOGS_STMT:
387
    case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT:
388
    case QUERY_NODE_SHOW_ARBGROUPS_STMT:
389
    case QUERY_NODE_SHOW_ENCRYPTIONS_STMT:
390
    case QUERY_NODE_SHOW_USAGE_STMT:
391
      return !pCxt->pParseCxt->enableSysInfo ? TSDB_CODE_PAR_PERMISSION_DENIED : TSDB_CODE_SUCCESS;
1,178✔
392
    case QUERY_NODE_SHOW_TABLES_STMT:
1,911✔
393
    case QUERY_NODE_SHOW_STABLES_STMT:
394
      return authShowTables(pCxt, (SShowStmt*)pStmt);
1,911✔
395
    case QUERY_NODE_SHOW_CREATE_TABLE_STMT:
143✔
396
    case QUERY_NODE_SHOW_CREATE_STABLE_STMT:
397
      return authShowCreateTable(pCxt, (SShowCreateTableStmt*)pStmt);
143✔
398
      //    case QUERY_NODE_SHOW_CREATE_VIEW_STMT:
399
      //      return authShowCreateView(pCxt, (SShowCreateViewStmt*)pStmt);
400
    case QUERY_NODE_CREATE_VIEW_STMT:
226✔
401
      return authCreateView(pCxt, (SCreateViewStmt*)pStmt);
226✔
402
    case QUERY_NODE_DROP_VIEW_STMT:
143✔
403
      return authDropView(pCxt, (SDropViewStmt*)pStmt);
143✔
404
    default:
199,640✔
405
      break;
199,640✔
406
  }
407

408
  return TSDB_CODE_SUCCESS;
199,640✔
409
}
410

411
int32_t authenticate(SParseContext* pParseCxt, SQuery* pQuery, SParseMetaCache* pMetaCache) {
1,251,991✔
412
  SAuthCxt cxt = {.pParseCxt = pParseCxt, .pMetaCache = pMetaCache, .errCode = TSDB_CODE_SUCCESS};
1,251,991✔
413
  return authQuery(&cxt, pQuery->pRoot);
1,251,991✔
414
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc