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

When using the --password env:FOO will now return an errors if #10936

Merged
merged 6 commits into from
Feb 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix a issue when remote and local configuration didn't match when fetching configuration from Central Management. {issue}10587[10587]
- 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