From 3d62feeff46cf27438546e09829cdc117c3db27d Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 23 Jun 2020 11:03:17 +0800 Subject: [PATCH] Use more inclusive language (#3903) Remove use of "whitelist" and "blacklist". I have not changed the testdata (sourcemaps), nor the docs copied from beats. The latter should be changed upstream. --- agentcfg/fetch.go | 2 +- agentcfg/model.go | 11 ++++++----- docs/common-problems.asciidoc | 4 ++-- tests/fields.go | 18 +++++++++--------- tests/fields_test.go | 20 ++++++++++---------- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/agentcfg/fetch.go b/agentcfg/fetch.go index 62451faf114..7b975f6d82a 100644 --- a/agentcfg/fetch.go +++ b/agentcfg/fetch.go @@ -107,7 +107,7 @@ func sanitize(insecureAgents []string, result Result) Result { } settings := Settings{} for k, v := range result.Source.Settings { - if utility.Contains(k, WhitelistedSettings) { + if utility.Contains(k, UnrestrictedSettings) { settings[k] = v } } diff --git a/agentcfg/model.go b/agentcfg/model.go index 2bc211a25f2..d9916a67104 100644 --- a/agentcfg/model.go +++ b/agentcfg/model.go @@ -34,8 +34,9 @@ const ( ) var ( - // WhitelistedSettings are settings considered safe to be returned to all requesters, including unauthenticated ones such as RUM. - WhitelistedSettings = []string{"transaction_sample_rate"} + // UnrestrictedSettings are settings considered safe to be returned to all requesters, + // including unauthenticated ones such as RUM. + UnrestrictedSettings = []string{"transaction_sample_rate"} ) // Result models a Kibana response @@ -71,9 +72,9 @@ type Query struct { // agent name matches any of the specified prefixes. // // If InsecureAgents is non-empty, and any of the prefixes matches the result, - // then the resulting settings will be restricted to those identified by - // WhitelistedSettings. Otherwise, if InsecureAgents is empty, the agent name - // is ignored and no restrictions are applied. + // then the resulting settings will be filtered down to the subset of settings + // identified by UnrestrictedSettings. Otherwise, if InsecureAgents is empty, + // the agent name is ignored and no restrictions are applied. InsecureAgents []string `json:"-"` } diff --git a/docs/common-problems.asciidoc b/docs/common-problems.asciidoc index 062c43f1ede..d11ad9b25fd 100644 --- a/docs/common-problems.asciidoc +++ b/docs/common-problems.asciidoc @@ -74,7 +74,7 @@ The <> in the request header doesn't match the confi === HTTP 403: Forbidden request Either you are sending requests to a <> endpoint without RUM enabled, or a request -is coming from an origin not whitelisted in `apm-server.rum.allow_origins`. See the <>. +is coming from an origin not specified in `apm-server.rum.allow_origins`. See the <>. [[queue-full]] [float] @@ -271,4 +271,4 @@ with configurable size and time between flushes. * **Ruby Agent** - Internal queue with configurable size: {apm-ruby-ref}/configuration.html#config-api-buffer-size[`api_buffer_size`]. * **RUM Agent** - No internal queue. Data is lost. -* **.NET Agent** - No internal queue. Data is lost. \ No newline at end of file +* **.NET Agent** - No internal queue. Data is lost. diff --git a/tests/fields.go b/tests/fields.go index afb45cec275..a33c49d4d4e 100644 --- a/tests/fields.go +++ b/tests/fields.go @@ -115,7 +115,7 @@ func (ps *ProcessorSetup) TemplateFieldsInEventFields(t *testing.T, eventFields, assertEmptySet(t, missing, fmt.Sprintf("Fields missing in event: %v", missing)) } -func fetchFields(t *testing.T, p TestProcessor, path string, blacklisted *Set) *Set { +func fetchFields(t *testing.T, p TestProcessor, path string, excludedKeys *Set) *Set { buf, err := loader.LoadDataAsBytes(path) require.NoError(t, err) events, err := p.Process(buf) @@ -127,7 +127,7 @@ func fetchFields(t *testing.T, p TestProcessor, path string, blacklisted *Set) * if k == "@timestamp" { continue } - FlattenMapStr(event.Fields[k], k, blacklisted, keys) + FlattenMapStr(event.Fields[k], k, excludedKeys, keys) } } sortedKeys := make([]string, keys.Len()) @@ -139,24 +139,24 @@ func fetchFields(t *testing.T, p TestProcessor, path string, blacklisted *Set) * return keys } -func FlattenMapStr(m interface{}, prefix string, keysBlacklist *Set, flattened *Set) { +func FlattenMapStr(m interface{}, prefix string, excludedKeys *Set, flattened *Set) { if commonMapStr, ok := m.(common.MapStr); ok { for k, v := range commonMapStr { - flattenMapStrStr(k, v, prefix, keysBlacklist, flattened) + flattenMapStrStr(k, v, prefix, excludedKeys, flattened) } } else if mapStr, ok := m.(map[string]interface{}); ok { for k, v := range mapStr { - flattenMapStrStr(k, v, prefix, keysBlacklist, flattened) + flattenMapStrStr(k, v, prefix, excludedKeys, flattened) } } - if prefix != "" && !isBlacklistedKey(keysBlacklist, prefix) { + if prefix != "" && !isExcludedKey(excludedKeys, prefix) { flattened.Add(prefix) } } func flattenMapStrStr(k string, v interface{}, prefix string, keysBlacklist *Set, flattened *Set) { key := strConcat(prefix, k, ".") - if !isBlacklistedKey(keysBlacklist, key) { + if !isExcludedKey(keysBlacklist, key) { flattened.Add(key) } switch v := v.(type) { @@ -171,7 +171,7 @@ func flattenMapStrStr(k string, v interface{}, prefix string, keysBlacklist *Set } } -func isBlacklistedKey(keysBlacklist *Set, key string) bool { +func isExcludedKey(keysBlacklist *Set, key string) bool { for _, disabledKey := range keysBlacklist.Array() { switch k := disabledKey.(type) { case string: @@ -183,7 +183,7 @@ func isBlacklistedKey(keysBlacklist *Set, key string) bool { return true } default: - panic("blacklist key must be string or Group") + panic("excluded key must be string or Group") } } return false diff --git a/tests/fields_test.go b/tests/fields_test.go index dbd9ab516cf..fdf50a2949e 100644 --- a/tests/fields_test.go +++ b/tests/fields_test.go @@ -29,26 +29,26 @@ import ( func TestFlattenCommonMapStr(t *testing.T) { emptyBlacklist := NewSet() - blacklist := NewSet("a.bMap", "f") + excluded := NewSet("a.bMap", "f") expectedAll := NewSet("a", "a.bStr", "a.bMap", "a.bMap.cMap", "a.bMap.cMap.d", "a.bMap.cStr", "a.bAnotherMap", "a.bAnotherMap.e", "f") expectedWoBlacklisted := NewSet("a", "a.bStr", "a.bMap.cStr", "a.bMap.cMap", "a.bMap.cMap.d", "a.bAnotherMap", "a.bAnotherMap.e") expectedAllPrefixed := NewSet("pre", "pre.a", "pre.a.bStr", "pre.a.bMap", "pre.a.bMap.cMap", "pre.a.bMap.cMap.d", "pre.a.bMap.cStr", "pre.a.bAnotherMap", "pre.a.bAnotherMap.e", "pre.f") expectedWithFilledInput := NewSet("prefilled", "a", "a.bStr", "a.bAnotherMap", "a.bAnotherMap.e", "a.bMap.cMap.d", "a.bMap.cStr", "a.bMap.cMap") for idx, dataRow := range []struct { - mapData common.MapStr - prefix string - blacklist *Set - input *Set - retVal *Set + mapData common.MapStr + prefix string + excluded *Set + input *Set + retVal *Set }{ {common.MapStr{}, "whatever", emptyBlacklist, NewSet(), NewSet("whatever")}, - {common.MapStr{}, "", blacklist, NewSet(), NewSet()}, + {common.MapStr{}, "", excluded, NewSet(), NewSet()}, {commonMapStr(), "", emptyBlacklist, NewSet(), expectedAll}, - {commonMapStr(), "", blacklist, NewSet(), expectedWoBlacklisted}, + {commonMapStr(), "", excluded, NewSet(), expectedWoBlacklisted}, {commonMapStr(), "pre", emptyBlacklist, NewSet(), expectedAllPrefixed}, - {commonMapStr(), "", blacklist, NewSet("prefilled"), expectedWithFilledInput}, + {commonMapStr(), "", excluded, NewSet("prefilled"), expectedWithFilledInput}, } { - FlattenMapStr(dataRow.mapData, dataRow.prefix, dataRow.blacklist, dataRow.input) + FlattenMapStr(dataRow.mapData, dataRow.prefix, dataRow.excluded, dataRow.input) expected := dataRow.retVal diff := SymmDifference(dataRow.input, expected)