Skip to content

Commit

Permalink
feat: add support for exceptions to annotations
Browse files Browse the repository at this point in the history
Some secrets when redacted are rejected due to invalid characters. One
example of this would `prometheus_bcrypt_salt` which is rejected due to
the use of underscores. Therefore the solution is to add support for
exceptions to the standard annotation format.

See: https://github.com/ansible/ansible/blob/devel/lib/ansible/utils/encrypt.py#L118C46-L118C46
  • Loading branch information
jackhodgkiss committed Dec 29, 2023
1 parent 52b5cfa commit 84ee860
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion utils/kayobe-automation-redact
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@ import hashlib
import base64
import sys

annotation_exceptions = {
'prometheus_bcrypt_salt': 'prometheusbcryptsalt'
}

def annotate(ctx, value):
if not isinstance(value, str):
return value
path_str = map(str, ctx['path'])
return f"{'.'.join(path_str)}.{ value }"
if path_str in annotation_exceptions:
return f"{'.'.join(annotation_exceptions['prometheus_bcrypt_salt'])}.{value}"
else:
return f"{'.'.join(path_str)}.{ value }"

def redact_int(ctx, x):
# For numbers we can't indicate change with a string, so use sentinal values
Expand Down

0 comments on commit 84ee860

Please sign in to comment.