Skip to content

Commit

Permalink
Use more inclusive language (#3903)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
axw authored Jun 23, 2020
1 parent 635a4c9 commit 3d62fee
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion agentcfg/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
11 changes: 6 additions & 5 deletions agentcfg/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:"-"`
}

Expand Down
4 changes: 2 additions & 2 deletions docs/common-problems.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ The <<secret-token, secret token>> in the request header doesn't match the confi
=== HTTP 403: Forbidden request

Either you are sending requests to a <<configuration-rum, RUM>> endpoint without RUM enabled, or a request
is coming from an origin not whitelisted in `apm-server.rum.allow_origins`. See the <<configuration-rum, RUM configuration>>.
is coming from an origin not specified in `apm-server.rum.allow_origins`. See the <<configuration-rum, RUM configuration>>.

[[queue-full]]
[float]
Expand Down Expand Up @@ -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.
* **.NET Agent** - No internal queue. Data is lost.
18 changes: 9 additions & 9 deletions tests/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand All @@ -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) {
Expand All @@ -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:
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/fields_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 3d62fee

Please sign in to comment.