forked from huawei/openGauss-server
mask password before storing into hash
Offering: openGaussDev More detail: mask password before storing into hash Match-id-8eb6b3914e2a402344b1b1b8ac69c00adec93236
This commit is contained in:
parent
3bb32d1d4a
commit
af8dd4ecb9
|
|
@ -494,30 +494,6 @@ void UpdateUniqueSQLVecSortStats(Batchsortstate* state, uint64 spill_count, Time
|
|||
}
|
||||
}
|
||||
|
||||
static void mask_unique_sql_str(UniqueSQL* unique_sql)
|
||||
{
|
||||
errno_t rc;
|
||||
|
||||
/* hide password */
|
||||
if (unique_sql->unique_sql != NULL) {
|
||||
char* mask_str = NULL;
|
||||
mask_str = maskPassword(unique_sql->unique_sql);
|
||||
if (mask_str != NULL) {
|
||||
rc = memset_s(unique_sql->unique_sql, UNIQUE_SQL_MAX_LEN - 1, 0, UNIQUE_SQL_MAX_LEN - 1);
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
/* after calling maskPassword, mask_str can be longer than original string,
|
||||
* now the length of masked password('*..*') is fixed to 'password_min_length'(GUC) */
|
||||
size_t valid_mask_len = strlen(mask_str) > (size_t)(UNIQUE_SQL_MAX_LEN - 1)
|
||||
? (size_t)(UNIQUE_SQL_MAX_LEN - 1)
|
||||
: strlen(mask_str);
|
||||
rc = memcpy_s(unique_sql->unique_sql, UNIQUE_SQL_MAX_LEN - 1, mask_str, valid_mask_len);
|
||||
securec_check(rc, "\0", "\0");
|
||||
pfree(mask_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void set_unique_sql_string_in_entry(UniqueSQL* entry, Query* query, const char* sql, int32 multi_sql_offset)
|
||||
{
|
||||
errno_t rc = EOK;
|
||||
|
|
@ -536,7 +512,6 @@ static void set_unique_sql_string_in_entry(UniqueSQL* entry, Query* query, const
|
|||
// generate and store normalized query string
|
||||
if (normalized_unique_querystring(query, sql, entry->unique_sql, UNIQUE_SQL_MAX_LEN - 1,
|
||||
multi_sql_offset)) {
|
||||
mask_unique_sql_str(entry);
|
||||
entry->unique_sql = trim(entry->unique_sql);
|
||||
} else {
|
||||
ereport(LOG,
|
||||
|
|
|
|||
|
|
@ -203,12 +203,11 @@ bool normalized_unique_querystring(Query* query, const char* query_string, char*
|
|||
}
|
||||
|
||||
bool result = true;
|
||||
char* norm_query = NULL;
|
||||
char *norm_query = NULL, *mask_str = NULL;
|
||||
int encoding = GetDatabaseEncoding();
|
||||
int query_len;
|
||||
pgssJumbleState jstate;
|
||||
errno_t rc;
|
||||
rc = memset_s(&jstate, sizeof(jstate), 0, sizeof(jstate));
|
||||
errno_t rc = memset_s(&jstate, sizeof(jstate), 0, sizeof(jstate));
|
||||
securec_check(rc, "\0", "\0");
|
||||
|
||||
query_len = strlen(query_string);
|
||||
|
|
@ -221,6 +220,12 @@ bool normalized_unique_querystring(Query* query, const char* query_string, char*
|
|||
result = false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mask_str = maskPassword(query_string);
|
||||
if (mask_str != NULL) {
|
||||
query_string = mask_str;
|
||||
query_len = strlen(mask_str);
|
||||
}
|
||||
}
|
||||
|
||||
if (result) {
|
||||
|
|
@ -235,6 +240,7 @@ bool normalized_unique_querystring(Query* query, const char* query_string, char*
|
|||
query_string = builtin_unique_sql->unique_sql;
|
||||
query_len = builtin_unique_sql->unique_sql_len;
|
||||
}
|
||||
|
||||
if (query_len > buf_len) {
|
||||
query_len = pg_encoding_mbcliplen(encoding, query_string, query_len,
|
||||
g_instance.attr.attr_common.pgstat_track_activity_query_size - 1);
|
||||
|
|
@ -245,6 +251,7 @@ bool normalized_unique_querystring(Query* query, const char* query_string, char*
|
|||
}
|
||||
}
|
||||
|
||||
pfree_ext(mask_str);
|
||||
return result;
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue