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;
}
/* 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))
{
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)
* - 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
* returns false. If the provided errmsg pointer is not NULL, it will be set
* to an appropriate message if the check fails.
*
* The provided whitelist must be sorted in a manner usable by bsearch, though
* this is only validated during assert-enabled builds.
* The provided allowedConninfoKeywords must be sorted in a manner usable by bsearch,
* though this is only validated during assert-enabled builds.
*/
bool
CheckConninfo(const char *conninfo, const char **whitelist,
Size whitelistLength, char **errorMsg)
CheckConninfo(const char *conninfo, const char **allowedConninfoKeywords,
Size allowedConninfoKeywordsLength, char **errorMsg)
{
PQconninfoOption *option = NULL;
char *errorMsgString = NULL;
@ -173,11 +173,11 @@ CheckConninfo(const char *conninfo, const char **whitelist,
#ifdef USE_ASSERT_CHECKING
/* verify that the whitelist is in ascending order */
for (Size whitelistIdx = 1; whitelistIdx < whitelistLength; whitelistIdx++)
/* verify that the allowedConninfoKeywords is in ascending order */
for (Size keywordIdx = 1; keywordIdx < allowedConninfoKeywordsLength; keywordIdx++)
{
const char *prev = whitelist[whitelistIdx - 1];
const char *curr = whitelist[whitelistIdx];
const char *prev = allowedConninfoKeywords[keywordIdx - 1];
const char *curr = allowedConninfoKeywords[keywordIdx];
AssertArg(strcmp(prev, curr) < 0);
}
@ -190,11 +190,12 @@ CheckConninfo(const char *conninfo, const char **whitelist,
continue;
}
void *matchingKeyword = SafeBsearch(&option->keyword, whitelist, whitelistLength,
sizeof(char *), pg_qsort_strcmp);
void *matchingKeyword = SafeBsearch(&option->keyword, allowedConninfoKeywords,
allowedConninfoKeywordsLength, sizeof(char *),
pg_qsort_strcmp);
if (matchingKeyword == NULL)
{
/* the whitelist lacks this keyword; error out! */
/* the allowedConninfoKeywords lacks this keyword; error out! */
StringInfoData 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
* 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.
*/
static bool
NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source)
{
/* this array _must_ be kept in an order usable by bsearch */
const char *whitelist[] = {
const char *allowedConninfoKeywords[] = {
"application_name",
"connect_timeout",
#if defined(ENABLE_GSS) && defined(ENABLE_SSPI)
@ -1542,8 +1542,8 @@ NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source)
"sslrootcert"
};
char *errorMsg = NULL;
bool conninfoValid = CheckConninfo(*newval, whitelist, lengthof(whitelist),
&errorMsg);
bool conninfoValid = CheckConninfo(*newval, allowedConninfoKeywords,
lengthof(allowedConninfoKeywords), &errorMsg);
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,
Index *runtimeParamStart, MemoryContext context);
extern const char * GetConnParam(const char *keyword);
extern bool CheckConninfo(const char *conninfo, const char **whitelist,
Size whitelistLength, char **errmsg);
extern bool CheckConninfo(const char *conninfo, const char **allowedConninfoKeywords,
Size allowedConninfoKeywordsLength, char **errmsg);
/* Low-level connection establishment APIs */