Skip to content

Commit

Permalink
When using the --password env:FOO will now return an errors if (elast…
Browse files Browse the repository at this point in the history
…ic#10936)

* When using the --password env:FOO will now return an errors if
FOO does not exist in the environment.

(cherry picked from commit be91dbf)
  • Loading branch information
ph committed Mar 8, 2019
1 parent 6b678be commit 05f87d8
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ https://github.com/elastic/beats/compare/v6.6.0...6.x[Check the HEAD diff]
- Add ECS-like selectors and dedotting to docker autodiscover. {issue}10757[10757] {pull}10862[10862]
- Fix encoding of timestamps when using disk spool. {issue}10099[10099]
- Include ip and boolean type when generating index pattern. {pull}10995[10995]
- Fix unauthorized error when loading dashboards by adding username and password into kibana config. {issue}10513[10513] {pull}10675[10675]
- Ensure all beat commands respect configured settings. {pull}10721[10721]
- Using an environment variable for the password when enrolling a beat will now raise an error if the variable doesn't exist. {pull}10936[10936]

*Auditbeat*

Expand Down
9 changes: 7 additions & 2 deletions libbeat/common/cli/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,13 @@ func stdin(p string) (string, error) {

func env(p string) (string, error) {
if len(p) == 0 {
return "", errors.New("env variable name is needed when using env: password method")
return "", errors.New("environment variable name is needed when using env: password method")
}

return os.Getenv(p), nil
v, ok := os.LookupEnv(p)
if !ok {
return "", fmt.Errorf("environment variable %s does not exist", p)
}

return v, nil
}
5 changes: 5 additions & 0 deletions libbeat/common/cli/password_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func TestReadPassword(t *testing.T) {
input: "",
error: true,
},
{
name: "Test env variable that does not exist",
input: "env:DO_NOT_EXIST",
error: true,
},
}

for _, test := range tests {
Expand Down
1 change: 1 addition & 0 deletions x-pack/agent
Submodule agent added at ab7def

0 comments on commit 05f87d8

Please sign in to comment.