change wording to allowlist and the likes (#3906)

In the same line as #3904

Change wording to better reflect use and remove words that enforce/maintain bias.
pull/4036/head
Nils Dijk 2020-07-15 16:24:40 +02:00 committed by GitHub
parent 1baf6c3a45
commit d0b6e62c9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 19 deletions

View File

@ -285,7 +285,7 @@ multi_ProcessUtility(PlannedStmt *pstmt,
return; return;
} }
/* process SET LOCAL stmts of whitelisted GUCs in multi-stmt xacts */ /* process SET LOCAL stmts of allowed GUCs in multi-stmt xacts */
if (IsA(parsetree, VariableSetStmt)) if (IsA(parsetree, VariableSetStmt))
{ {
VariableSetStmt *setStmt = (VariableSetStmt *) parsetree; VariableSetStmt *setStmt = (VariableSetStmt *) parsetree;

View File

@ -122,18 +122,18 @@ AddConnParam(const char *keyword, const char *value)
* *
* - Not use a uri-prefix such as postgres:// (it must be only keys and values) * - Not use a uri-prefix such as postgres:// (it must be only keys and values)
* - Parse using PQconninfoParse * - Parse using PQconninfoParse
* - Only set keywords contained in the provided whitelist * - Only set keywords contained in the provided allowedConninfoKeywords
* *
* This function returns true if all of the above are satisfied, otherwise it * This function returns true if all of the above are satisfied, otherwise it
* returns false. If the provided errmsg pointer is not NULL, it will be set * returns false. If the provided errmsg pointer is not NULL, it will be set
* to an appropriate message if the check fails. * to an appropriate message if the check fails.
* *
* The provided whitelist must be sorted in a manner usable by bsearch, though * The provided allowedConninfoKeywords must be sorted in a manner usable by bsearch,
* this is only validated during assert-enabled builds. * though this is only validated during assert-enabled builds.
*/ */
bool bool
CheckConninfo(const char *conninfo, const char **whitelist, CheckConninfo(const char *conninfo, const char **allowedConninfoKeywords,
Size whitelistLength, char **errorMsg) Size allowedConninfoKeywordsLength, char **errorMsg)
{ {
PQconninfoOption *option = NULL; PQconninfoOption *option = NULL;
char *errorMsgString = NULL; char *errorMsgString = NULL;
@ -173,11 +173,11 @@ CheckConninfo(const char *conninfo, const char **whitelist,
#ifdef USE_ASSERT_CHECKING #ifdef USE_ASSERT_CHECKING
/* verify that the whitelist is in ascending order */ /* verify that the allowedConninfoKeywords is in ascending order */
for (Size whitelistIdx = 1; whitelistIdx < whitelistLength; whitelistIdx++) for (Size keywordIdx = 1; keywordIdx < allowedConninfoKeywordsLength; keywordIdx++)
{ {
const char *prev = whitelist[whitelistIdx - 1]; const char *prev = allowedConninfoKeywords[keywordIdx - 1];
const char *curr = whitelist[whitelistIdx]; const char *curr = allowedConninfoKeywords[keywordIdx];
AssertArg(strcmp(prev, curr) < 0); AssertArg(strcmp(prev, curr) < 0);
} }
@ -190,11 +190,12 @@ CheckConninfo(const char *conninfo, const char **whitelist,
continue; continue;
} }
void *matchingKeyword = SafeBsearch(&option->keyword, whitelist, whitelistLength, void *matchingKeyword = SafeBsearch(&option->keyword, allowedConninfoKeywords,
sizeof(char *), pg_qsort_strcmp); allowedConninfoKeywordsLength, sizeof(char *),
pg_qsort_strcmp);
if (matchingKeyword == NULL) if (matchingKeyword == NULL)
{ {
/* the whitelist lacks this keyword; error out! */ /* the allowedConninfoKeywords lacks this keyword; error out! */
StringInfoData msgString; StringInfoData msgString;
initStringInfo(&msgString); initStringInfo(&msgString);

View File

@ -1516,14 +1516,14 @@ WarnIfDeprecatedExecutorUsed(int *newval, void **extra, GucSource source)
/* /*
* NodeConninfoGucCheckHook ensures conninfo settings are in the expected form * NodeConninfoGucCheckHook ensures conninfo settings are in the expected form
* and that the keywords of all non-null settings are on a whitelist devised to * and that the keywords of all non-null settings are on a allowlist devised to
* keep users from setting options that may result in confusion. * keep users from setting options that may result in confusion.
*/ */
static bool static bool
NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source) NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source)
{ {
/* this array _must_ be kept in an order usable by bsearch */ /* this array _must_ be kept in an order usable by bsearch */
const char *whitelist[] = { const char *allowedConninfoKeywords[] = {
"application_name", "application_name",
"connect_timeout", "connect_timeout",
#if defined(ENABLE_GSS) && defined(ENABLE_SSPI) #if defined(ENABLE_GSS) && defined(ENABLE_SSPI)
@ -1542,8 +1542,8 @@ NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source)
"sslrootcert" "sslrootcert"
}; };
char *errorMsg = NULL; char *errorMsg = NULL;
bool conninfoValid = CheckConninfo(*newval, whitelist, lengthof(whitelist), bool conninfoValid = CheckConninfo(*newval, allowedConninfoKeywords,
&errorMsg); lengthof(allowedConninfoKeywords), &errorMsg);
if (!conninfoValid) if (!conninfoValid)
{ {

View File

@ -213,8 +213,8 @@ extern void AddConnParam(const char *keyword, const char *value);
extern void GetConnParams(ConnectionHashKey *key, char ***keywords, char ***values, extern void GetConnParams(ConnectionHashKey *key, char ***keywords, char ***values,
Index *runtimeParamStart, MemoryContext context); Index *runtimeParamStart, MemoryContext context);
extern const char * GetConnParam(const char *keyword); extern const char * GetConnParam(const char *keyword);
extern bool CheckConninfo(const char *conninfo, const char **whitelist, extern bool CheckConninfo(const char *conninfo, const char **allowedConninfoKeywords,
Size whitelistLength, char **errmsg); Size allowedConninfoKeywordsLength, char **errmsg);
/* Low-level connection establishment APIs */ /* Low-level connection establishment APIs */