Update RequestContentValidator to only validate fields from request payload and not pre-existing values stored in security index#6061
Conversation
…ayload and not pre-existing values stored in security index Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6061 +/- ##
==========================================
+ Coverage 73.98% 74.04% +0.05%
==========================================
Files 441 441
Lines 27413 27481 +68
Branches 4110 4123 +13
==========================================
+ Hits 20281 20347 +66
Misses 5193 5193
- Partials 1939 1941 +2
🚀 New features to boost your workflow:
|
Signed-off-by: Craig Perkins <cwperx@amazon.com>
Signed-off-by: Craig Perkins <cwperx@amazon.com>
PR Code Analyzer ❗AI-powered 'Code-Diff-Analyzer' found issues on commit 3b4a597.
The table above displays the top 10 most important findings. Pull Requests Author(s): Please update your Pull Request according to the report above. Repository Maintainer(s): You can Thanks. |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
Description
This PR contains a fix for using PATCH API with the security plugin to update security configs like internal users.
This PR relates to the following 3 PRs:
Prior to opensearch-project/security-dashboards-plugin#2330, when internal users would be created through OSD then they would automatically get empty string ("") pre-populated in the list of backend roles.
With the new API validations added in #5714, a user making a PATCH request can get a BAD_REQUEST error if the internaluser being edited has an empty string already stored in the security index regardless if the request payload is modifying this field.
For example in my internalusers.yml file I put:
and then try to update the hash via API using PATCH. It fails:
With the change in this PR, the request would succeed bc the validation would only apply on the request payload itself.
Bugfix
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.