Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for hiding and redacting sensitive details #151

Merged
merged 8 commits into from
Jun 17, 2018

Conversation

vlovgr
Copy link
Owner

@vlovgr vlovgr commented Jun 15, 2018

Hiding sensitive details

  • Change ConfigValue#toString and ConfigEntry#toString to not include values.
  • Change Show instances for ConfigValue and ConfigEntry to not include values.
  • Add ConfigValue#toStringWithValue and ConfigEntry#toStringWithValues for keeping the previous toString behaviours.

You'll no longer have to worry about accidentally logging values, unless you're explicitly logging the result from a function with value in the name (sourceValue, value, toStringWithValue, ...).

Redacting sensitive details

  • Add ConfigError#sensitive for creating errors with sensitive details.
  • Add ConfigError#redactSensitive for redacting sensitive details.
  • Add ConfigError#redactedValue placeholder for redacted details.
  • Add ConfigDecoder#redactSensitive for redacting sensitive details in decoding errors.
  • Change ConfigDecoder[Secret[A]] to automatically redact sensitive details.
  • Change ConfigError#combined, missingKey, readException, wrongType to redact sensitive details.

In effect, this means that if you're using Secret to wrap the types of your secret configuration values, sensitive details will now automatically be redacted in error messages. And you will not have to worry about ever accidentally including secret values in log output.

scala> env[Secret[Int]]("FILE_ENCODING")
     |  .orElse(prop("file.encoding"))
     |  .value.left.map(_.message)
res0: Either[String,ciris.Secret[Int]] = Left(Missing environment variable [FILE_ENCODING] and system property [file.encoding] with value [<redacted>] cannot be converted to type [Int])

@vlovgr vlovgr force-pushed the redact-sensitive branch from 2ab4f56 to 5d4f210 Compare June 15, 2018 10:31
@codecov
Copy link

codecov bot commented Jun 15, 2018

Codecov Report

Merging #151 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #151      +/-   ##
==========================================
+ Coverage   99.71%   99.72%   +<.01%     
==========================================
  Files          43       43              
  Lines         704      717      +13     
  Branches        4        5       +1     
==========================================
+ Hits          702      715      +13     
  Misses          2        2
Impacted Files Coverage Δ
...ore/shared/src/main/scala/ciris/ConfigSource.scala 100% <ø> (ø) ⬆️
...m/src/main/scala/ciris/CirisPlatformSpecific.scala 100% <ø> (ø) ⬆️
...ined/jvm/src/main/scala/ciris/refined/syntax.scala 100% <ø> (ø) ⬆️
...les/core/shared/src/main/scala/ciris/package.scala 100% <ø> (ø) ⬆️
...re/shared/src/main/scala/ciris/ConfigDecoder.scala 100% <100%> (ø) ⬆️
...core/shared/src/main/scala/ciris/ConfigValue.scala 100% <100%> (ø) ⬆️
...ain/scala/ciris/decoders/CirisConfigDecoders.scala 100% <100%> (ø) ⬆️
...n/scala/ciris/cats/api/CirisInstancesForCats.scala 100% <100%> (ø) ⬆️
...core/shared/src/main/scala/ciris/ConfigError.scala 100% <100%> (ø) ⬆️
...core/shared/src/main/scala/ciris/ConfigEntry.scala 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5deb9e...a580d7a. Read the comment docs.

@vlovgr vlovgr force-pushed the redact-sensitive branch from 74af180 to 1172ba3 Compare June 16, 2018 11:11
@vlovgr vlovgr force-pushed the redact-sensitive branch from 7cc3963 to 6238c4f Compare June 16, 2018 13:14
@vlovgr vlovgr changed the title Add support for redacting sensitive details in errors Add support for hiding and redacting sensitive details Jun 17, 2018
@vlovgr vlovgr force-pushed the redact-sensitive branch from 053e699 to a580d7a Compare June 17, 2018 15:01
@vlovgr vlovgr merged commit 50a0374 into master Jun 17, 2018
@vlovgr vlovgr deleted the redact-sensitive branch June 17, 2018 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant