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

fix: add validation on data.method when using transport.request #801

Merged
merged 4 commits into from
Jul 5, 2023

Conversation

SuZhou-Joe
Copy link
Member

@SuZhou-Joe SuZhou-Joe commented Jun 30, 2023

Description

[Describe what this change achieves]

Issues Resolved

[List any issues this PR will resolve]

Check List

  • Commits are signed per the DCO using --signoff

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.

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
@SuZhou-Joe
Copy link
Member Author

#800

@SuZhou-Joe SuZhou-Joe added v2.9.0 Label description backport 2.8 backport 2.x bug Something isn't working and removed backport 2.8 labels Jun 30, 2023
@SuZhou-Joe SuZhou-Joe changed the title fix: add validation on data.method when using tranport.request fix: add validation on data.method when using transport.request Jun 30, 2023
@codecov
Copy link

codecov bot commented Jun 30, 2023

Codecov Report

Merging #801 (a8e2df0) into main (c821a2a) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #801   +/-   ##
=======================================
  Coverage   63.40%   63.40%           
=======================================
  Files         340      340           
  Lines       11540    11540           
  Branches     2238     2238           
=======================================
  Hits         7317     7317           
  Misses       3649     3649           
  Partials      574      574           

Hailong-am
Hailong-am previously approved these changes Jun 30, 2023
@xluo-aws
Copy link
Member

@SuZhou-Joe , could you add a UT for it?

* Check valid method here
*/
if (endpoint === "transport.request" && data?.method) {
if (VALID_METHODS.indexOf(data.method?.toUpperCase()) === -1) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

? after data.method can be removed because it's checked for null in 65

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, good point and modify that to catch toUpperCase in case data.method is not a string.

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
@SuZhou-Joe
Copy link
Member Author

@SuZhou-Joe , could you add a UT for it?

Sure, thanks for reminding.

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
@Hailong-am Hailong-am merged commit 13fb97f into opensearch-project:main Jul 5, 2023
10 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 5, 2023
* fix: add validation on data.method when using tranport.request

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add validation on endpoint

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add more protect

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
(cherry picked from commit 13fb97f)
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-801-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 13fb97fac3db5d6af6ef03b2bee8e04c80de4094
# Push it to GitHub
git push --set-upstream origin backport/backport-801-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x

Then, create a pull request where the base branch is 2.x and the compare/head branch is backport/backport-801-to-2.x.

opensearch-trigger-bot bot pushed a commit that referenced this pull request Jul 5, 2023
* fix: add validation on data.method when using tranport.request

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add validation on endpoint

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add more protect

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
(cherry picked from commit 13fb97f)
SuZhou-Joe added a commit that referenced this pull request Jul 5, 2023
* fix: add validation on data.method when using tranport.request

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add validation on endpoint

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add more protect

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
(cherry picked from commit 13fb97f)
SuZhou-Joe added a commit to SuZhou-Joe/index-management-dashboards-plugin that referenced this pull request Jul 5, 2023
…search-project#801)

* fix: add validation on data.method when using tranport.request

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add validation on endpoint

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add unit test

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

* feat: add more protect

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>

---------

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
(cherry picked from commit 13fb97f)
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Hailong-am pushed a commit that referenced this pull request Jul 10, 2023
#803)

* fix: add validation on data.method when using tranport.request



* feat: add validation on endpoint



* feat: add unit test



* feat: add more protect



---------


(cherry picked from commit 13fb97f)

Signed-off-by: SuZhoue-Joe <suzhou@amazon.com>
Signed-off-by: SuZhou-Joe <suzhou@amazon.com>
Co-authored-by: suzhou <suzhou@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x bug Something isn't working v2.9.0 Label description
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants