Skip to content

Commit

Permalink
Include sensitive values in dotenv export content.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Apr 19, 2023
1 parent 899bc17 commit b9baf1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The format is based on [Keep a Changelog], and this project adheres to
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [1.0.3] - 2023-04-20

### Changed

- `export/dotenv` mode now includes sensitive values in the output

## [1.0.2] - 2023-03-29

### Fixed
Expand Down Expand Up @@ -201,6 +207,7 @@ The two most important changes in usage are:
[1.0.0]: https://github.com/dogmatiq/ferrite/releases/tag/v1.0.0
[1.0.1]: https://github.com/dogmatiq/ferrite/releases/tag/v1.0.1
[1.0.2]: https://github.com/dogmatiq/ferrite/releases/tag/v1.0.2
[1.0.3]: https://github.com/dogmatiq/ferrite/releases/tag/v1.0.3

<!-- version template
## [0.0.1] - YYYY-MM-DD
Expand Down
4 changes: 2 additions & 2 deletions internal/mode/export/dotenv/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Run(opts mode.Config) {
if def, ok := s.Default(); ok {
x := def.Quote()
if s.IsSensitive() {
x = strings.Repeat("*", len(def.String))
x = strings.Repeat("*", len(x))
}
must.Fprintf(opts.Out, "default: %s", x)
} else if s.IsDeprecated() {
Expand All @@ -41,7 +41,7 @@ func Run(opts mode.Config) {
must.Fprintf(opts.Out, ")\n")
must.Fprintf(opts.Out, "export %s=", s.Name())

if v.Source() == variable.SourceEnvironment && !s.IsSensitive() {
if v.Source() == variable.SourceEnvironment {
err := v.Error()
if err, ok := err.(variable.ValueError); ok {
must.Fprintf(
Expand Down
2 changes: 1 addition & 1 deletion mode_dotenv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func ExampleInit_exportDotEnvFile() {
// export FERRITE_STRING='hello, world!'
//
// # example sensitive string (default: ********, sensitive)
// export FERRITE_STRING_SENSITIVE=
// export FERRITE_STRING_SENSITIVE=hunter2
//
// # kubernetes "ferrite-svc" service host (deprecated)
// export FERRITE_SVC_SERVICE_HOST=host.example.org
Expand Down

0 comments on commit b9baf1c

Please sign in to comment.