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

Handle exceptions for adding request body audit log if rest request is invalid #4232

Merged
merged 2 commits into from
Apr 16, 2024

Conversation

Aayush8394
Copy link
Contributor

Description

This change fixes the bug #1849. This change ensures audit logging logs a failed request if request body fails to match content-type header or required parameters.

  • Category: Bug fix
  • Why these changes are required?
    This change is required to be consistent with user provided configuration of audit logging request body even for failed requests
  • What is the old behavior before changes and new behavior after changes?
    Before this change, an invalid request (with invalid content or source type parameters) did not get audit_request_body even if request body audit logging is enabled by user because of improper exception handling. After this change, audit_request_body will be generated

Issues Resolved

#1849

Is this a backport? If so, please add backport PR # and/or commits #

Testing

Unit tested

Check List

  • New functionality includes testing
  • New functionality has been documented
  • 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.

…s invalid. Resolves opensearch-project#1849

Signed-off-by: Aayush Singhal <siaayush@amazon.com>
cwperks
cwperks previously approved these changes Apr 11, 2024
Copy link
Member

@cwperks cwperks left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @Aayush8394!

@cwperks cwperks added the backport 2.x backport to 2.x branch label Apr 11, 2024
Signed-off-by: Aayush Singhal <siaayush@amazon.com>
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.20%. Comparing base (a5a5e03) to head (e0b5bcd).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4232      +/-   ##
==========================================
+ Coverage   66.15%   66.20%   +0.04%     
==========================================
  Files         301      301              
  Lines       21708    21710       +2     
  Branches     3506     3506              
==========================================
+ Hits        14362    14373      +11     
+ Misses       5584     5577       -7     
+ Partials     1762     1760       -2     
Files Coverage Δ
...pensearch/security/auditlog/impl/AuditMessage.java 76.38% <100.00%> (+1.62%) ⬆️

... and 3 files with indirect coverage changes

@stephen-crawford stephen-crawford merged commit 0bfe765 into opensearch-project:main Apr 16, 2024
82 checks passed
@opensearch-trigger-bot
Copy link
Contributor

The backport to 2.x failed:

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

To backport manually, run these commands in your terminal:

# Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/security/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/security/backport-2.x
# Create a new branch
git switch --create backport/backport-4232-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 0bfe7653b0f50ff6b6757411af4e49d9784a063b
# Push it to GitHub
git push --set-upstream origin backport/backport-4232-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/security/backport-2.x

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

@cwperks
Copy link
Member

cwperks commented Apr 16, 2024

@Aayush8394 Can you create a manual backport to 2.x for this?

@Aayush8394 Aayush8394 deleted the aayush-dev branch April 16, 2024 19:06
Aayush8394 added a commit to Aayush8394/security that referenced this pull request Apr 19, 2024
… rest request is invalid (opensearch-project#4232)

Signed-off-by: Aayush Singhal <siaayush@amazon.com>
dlin2028 pushed a commit to dlin2028/security that referenced this pull request May 1, 2024
…s invalid (opensearch-project#4232)

Signed-off-by: Aayush Singhal <siaayush@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x backport to 2.x branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants