Skip to content

Commit

Permalink
Better clarify obfuscated values
Browse files Browse the repository at this point in the history
Closes #23
  • Loading branch information
japgolly committed Oct 22, 2021
1 parent d783a25 commit 9eaa0fc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Set `versionScheme` to `"early-semver"`
* Upgrade `microlibs` to 4.0.0
* Update Scala.js to 1.7
* Better clarify in reports where values are obfuscated. Instead of `<# hash #>`, obfuscated values are now displayed as `Obfuscated (hash)`

### 2.0.0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Used keys (5):
+-------------------+------+-------------------------+---------+
| Key | Env | cp:/database.properties | Default |
+-------------------+------+-------------------------+---------+
| POSTGRES_PASSWORD | | <# 1C02B9F6 #> | |
| POSTGRES_PASSWORD | | Obfuscated (1C02B9F6) | |
| POSTGRES_PORT | 4000 | | 8080 |
| POSTGRES_SCHEMA | | | |
| POSTGRES_URL | | http://localhost/blah | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ object Report {
ValueDisplay((_, _, _, v) => if (v.length <= maxLen) v else v.take(maxLen - 1) + "")

def obfuscate: ValueDisplay =
ValueDisplay((c, _, _, v) => "%s<# %08X #>%s".format(c.secret, MurmurHash3 stringHash v, c.reset))
ValueDisplay((c, _, _, v) => "%sObfuscated (%08X)%s".format(c.secret, MurmurHash3 stringHash v, c.reset))

def obfuscateSources(f: SourceName => Boolean): ValueDisplay =
obfuscate.when((s, _, _) => f(s))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ object ConfigReportTest extends TestSuite {
! - S
!
!Used keys (3):
!+-----+----------------+
!| Key | S |
!+-----+----------------+
!| a | 1 |
!| b | <# 16CC649D #> |
!| c | 3 |
!+-----+----------------+
!+-----+-----------------------+
!| Key | S |
!+-----+-----------------------+
!| a | 1 |
!| b | Obfuscated (16CC649D) |
!| c | 3 |
!+-----+-----------------------+
!
!Unused keys (0):
!No data to report.
Expand Down Expand Up @@ -372,19 +372,19 @@ object ConfigReportTest extends TestSuite {
val r = c.withReport.run(s).get_!._2
"on" - assertMultiline(r.withColour.used(false),
s"""
|+-----+----------------+
|| Key | S |
|+-----+----------------+
|| i | ${Console.YELLOW}<# 9C554F15 #>${Console.RESET} |
|+-----+----------------+
|+-----+-----------------------+
|| Key | S |
|+-----+-----------------------+
|| i | ${Console.YELLOW}Obfuscated (9C554F15)${Console.RESET} |
|+-----+-----------------------+
""".stripMargin.trim)
"off" - assertMultiline(r.withoutColour.used(false),
"""
|+-----+----------------+
|| Key | S |
|+-----+----------------+
|| i | <# 9C554F15 #> |
|+-----+----------------+
|+-----+-----------------------+
|| Key | S |
|+-----+-----------------------+
|| i | Obfuscated (9C554F15) |
|+-----+-----------------------+
""".stripMargin.trim)
}

Expand Down

0 comments on commit 9eaa0fc

Please sign in to comment.