Skip to content

Commit

Permalink
Merge pull request #283 from zmstone/1222-do-not-obfuscate-undefined
Browse files Browse the repository at this point in the history
fix(hocon_tconf): do not obfuscate 'undefined' as "******"
  • Loading branch information
zmstone authored Dec 22, 2023
2 parents d39a863 + 670eb6b commit 8442790
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hocon_tconf.erl
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,10 @@ ensure_obfuscate_sensitive(Opts, Schema, Val) ->
Val
end.

%% Should not replace 'undefined' with "******" because we want to
%% be able to tell if value existed or not.
obfuscate(_Schema, undefined) ->
undefined;
obfuscate(Schema, Value) ->
case field_schema(Schema, sensitive) of
true -> <<"******">>;
Expand Down
7 changes: 7 additions & 0 deletions test/hocon_tconf_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ fields(bar) ->
[
{union_with_default, fun union_with_default/1},
{field1, fun field1/1},
{optional_secret, fun optional_secret/1},
{host, fun host/1}
];
fields(parent) ->
Expand Down Expand Up @@ -69,6 +70,12 @@ field1(desc) -> "field1 desc";
field1(sensitive) -> true;
field1(_) -> undefined.

optional_secret(type) -> string();
optional_secret(desc) -> "optional secret";
optional_secret(sensitive) -> true;
optional_secret(required) -> false;
optional_secret(_) -> undefined.

host(type) -> string();
host(required) -> false;
host(desc) -> "host desc";
Expand Down

0 comments on commit 8442790

Please sign in to comment.