-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] fix validation of output secret fields #172795
Conversation
Pinging @elastic/fleet (Team:Fleet) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
is_default_monitoring: false, | ||
hosts: ['https://bla.co'], | ||
secrets: { service_token: 'token' }, | ||
preset: 'balanced', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strangely leaving the preset out had the effect of the secret not being created
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting. Any further indication why that might have happened? Might be worth experimenting with or exploring further 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't reproduce it, tried with curl to leave out preset field, but I get a different 400 error:
curl 'http://localhost:5601/julia/api/fleet/outputs' \
-sk -XPOST -u elastic:changeme \
-H 'elastic-api-version: 2023-10-31' \
-H "kbn-xsrf: reporting" \
--data-raw '{"name":"remote","type":"remote_elasticsearch","hosts":["http://localhost"],"is_default":false,"is_default_monitoring":false,"config_yaml":"","secrets":{"service_token":"token"},"proxy_id":null}'
{"statusCode":400,"error":"Bad Request","message":"[request body]: types that failed validation:\n- [request body.0.name]: expected value of type [string] but got [undefined]\n- [request body.1.name]: expected value of type [string] but got [undefined]\n- [request body.2.name]: expected value of type [string] but got [undefined]\n- [request body.3.name]: expected value of type [string] but got [undefined]"}%
I also tried to comment out the preset field from the UI code, but then the output was created successfully with the secret. I'm not sure what was different in cypress.
is_default_monitoring: false, | ||
hosts: ['https://bla.co'], | ||
secrets: { service_token: 'token' }, | ||
preset: 'balanced', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm interesting. Any further indication why that might have happened? Might be worth experimenting with or exploring further 🤷
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
To update your PR or re-run it, just comment with: |
## Summary Closes elastic#172481 Fixed validation of secret output fields. Updated cypress tests that validates output secrets. Create a new remote elasticsearch output and verify that service token field is required when clicking Save without filling it in. <img width="673" alt="image" src="https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c"> Same for Logstash ssl key: <img width="678" alt="image" src="https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c"> Kafka password and ssl key: <img width="669" alt="image" src="https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498"> In edit mode, when the secret field is empty, the validation is shown again and goes away when clicking on Cancel changes. <img width="680" alt="image" src="https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15"> <img width="667" alt="image" src="https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca"> ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit a8f8f08)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
) # Backport This will backport the following commits from `main` to `8.12`: - [[Fleet] fix validation of output secret fields (#172795)](#172795) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Julia Bardi","email":"[email protected]"},"sourceCommit":{"committedDate":"2023-12-07T13:14:56Z","message":"[Fleet] fix validation of output secret fields (#172795)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation of secret output fields. Updated cypress tests that\r\nvalidates output secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that service token\r\nfield is required when clicking Save without filling it in.\r\n<img width=\"673\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame for Logstash ssl key:\r\n<img width=\"678\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka password and ssl key:\r\n<img width=\"669\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn edit mode, when the secret field is empty, the validation is shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img width=\"680\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img width=\"667\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3","branchLabelMapping":{"^v8.13.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v8.12.0","v8.13.0"],"number":172795,"url":"https://github.com/elastic/kibana/pull/172795","mergeCommit":{"message":"[Fleet] fix validation of output secret fields (#172795)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation of secret output fields. Updated cypress tests that\r\nvalidates output secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that service token\r\nfield is required when clicking Save without filling it in.\r\n<img width=\"673\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame for Logstash ssl key:\r\n<img width=\"678\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka password and ssl key:\r\n<img width=\"669\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn edit mode, when the secret field is empty, the validation is shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img width=\"680\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img width=\"667\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3"}},"sourceBranch":"main","suggestedTargetBranches":["8.12"],"targetPullRequestStates":[{"branch":"8.12","label":"v8.12.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.13.0","labelRegex":"^v8.13.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/172795","number":172795,"mergeCommit":{"message":"[Fleet] fix validation of output secret fields (#172795)\n\n## Summary\r\n\r\nCloses https://github.com/elastic/kibana/issues/172481\r\n\r\nFixed validation of secret output fields. Updated cypress tests that\r\nvalidates output secrets.\r\n\r\nCreate a new remote elasticsearch output and verify that service token\r\nfield is required when clicking Save without filling it in.\r\n<img width=\"673\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/29774463-23de-495a-a1c7-49fd3281877c\">\r\n\r\nSame for Logstash ssl key:\r\n<img width=\"678\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/7b41d95f-8066-47d1-a662-2e696399f90c\">\r\n\r\nKafka password and ssl key:\r\n<img width=\"669\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/2ea4dade-beb2-41e8-b068-6d6c42dca498\">\r\n\r\nIn edit mode, when the secret field is empty, the validation is shown\r\nagain and goes away when clicking on Cancel changes.\r\n<img width=\"680\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/93500091-05a5-458c-a42e-97d5f8937d15\">\r\n<img width=\"667\" alt=\"image\"\r\nsrc=\"https://github.com/elastic/kibana/assets/90178898/b7434126-bf20-40ce-9605-f63d694ea9ca\">\r\n\r\n\r\n### Checklist\r\n\r\n- [x] [Unit or functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere updated or added to match the most common scenarios","sha":"a8f8f087d3ba622970ff9075beab2a1693e3a7d3"}}]}] BACKPORT--> Co-authored-by: Julia Bardi <[email protected]>
Summary
Closes #172481
Fixed validation of secret output fields. Updated cypress tests that validates output secrets.
Create a new remote elasticsearch output and verify that service token field is required when clicking Save without filling it in.
Same for Logstash ssl key:
Kafka password and ssl key:
In edit mode, when the secret field is empty, the validation is shown again and goes away when clicking on Cancel changes.
Checklist