Skip to content

Commit

Permalink
Merge pull request #454 from overmindtech/rename-redaction
Browse files Browse the repository at this point in the history
Rename REDATED to (sensitive value)
  • Loading branch information
dylanratcliffe authored Jul 9, 2024
2 parents c5156b8 + 58d2be0 commit ee79ab0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions cmd/changes_submit_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func maskAllData(attributes map[string]any) map[string]any {
if mv, ok := v.(map[string]any); ok {
attributes[k] = maskAllData(mv)
} else {
attributes[k] = "REDACTED"
attributes[k] = "(sensitive value)"
}
}
return attributes
Expand All @@ -62,7 +62,7 @@ func maskAllData(attributes map[string]any) map[string]any {
// maskSensitiveData masks every entry in attributes that is set to true in sensitive. returns the redacted attributes
func maskSensitiveData(attributes, sensitive any) any {
if sensitive == true {
return "REDACTED"
return "(sensitive value)"
} else if sensitiveMap, ok := sensitive.(map[string]any); ok {
if attributesMap, ok := attributes.(map[string]any); ok {
result := map[string]any{}
Expand All @@ -71,20 +71,20 @@ func maskSensitiveData(attributes, sensitive any) any {
}
return result
} else {
return "REDACTED (type mismatch)"
return "(sensitive value) (type mismatch)"
}
} else if sensitiveArr, ok := sensitive.([]any); ok {
if attributesArr, ok := attributes.([]any); ok {
if len(sensitiveArr) != len(attributesArr) {
return "REDACTED (len mismatch)"
return "(sensitive value) (len mismatch)"
}
result := make([]any, len(attributesArr))
for i, v := range attributesArr {
result[i] = maskSensitiveData(v, sensitiveArr[i])
}
return result
} else {
return "REDACTED (type mismatch)"
return "(sensitive value) (type mismatch)"
}
}
return attributes
Expand Down
10 changes: 5 additions & 5 deletions cmd/changes_submit_plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestMaskSensitiveData(t *testing.T) {

require.Equal(t,
map[string]any{
"foo": "REDACTED",
"foo": "(sensitive value)",
},
maskSensitiveData(
map[string]any{
Expand All @@ -68,7 +68,7 @@ func TestMaskSensitiveData(t *testing.T) {

require.Equal(t,
map[string]any{
"foo": "REDACTED",
"foo": "(sensitive value)",
},
maskSensitiveData(
map[string]any{
Expand All @@ -78,7 +78,7 @@ func TestMaskSensitiveData(t *testing.T) {

require.Equal(t,
map[string]any{
"foo": map[string]any{"key": "REDACTED"},
"foo": map[string]any{"key": "(sensitive value)"},
},
maskSensitiveData(
map[string]any{
Expand All @@ -102,7 +102,7 @@ func TestMaskSensitiveData(t *testing.T) {

require.Equal(t,
map[string]any{
"foo": "REDACTED",
"foo": "(sensitive value)",
},
maskSensitiveData(
map[string]any{
Expand All @@ -112,7 +112,7 @@ func TestMaskSensitiveData(t *testing.T) {

require.Equal(t,
map[string]any{
"foo": []any{"one", "REDACTED"},
"foo": []any{"one", "(sensitive value)"},
},
maskSensitiveData(
map[string]any{
Expand Down

0 comments on commit ee79ab0

Please sign in to comment.