-
Notifications
You must be signed in to change notification settings - Fork 65
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
Resolve hosts when checking against host deny list #496
Resolve hosts when checking against host deny list #496
Conversation
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
LGTM, just need to figure out how to fix the tests |
Dashboards is going to fail because of the reason mentioned here. I'll work on fixing the unit tests though. |
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
It looks like the unit tests are still failing even after adding the stubbing, possible becasue I'm using We should be changing to use |
…of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
Codecov Report
@@ Coverage Diff @@
## main #496 +/- ##
=========================================
Coverage 61.77% 61.77%
Complexity 112 112
=========================================
Files 73 73
Lines 2451 2451
Branches 264 264
=========================================
Hits 1514 1514
Misses 761 761
Partials 176 176
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
…BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
"io.mockk:mockk:1.11.0", | ||
"io.mockk:mockk-common:1.11.0", | ||
"io.mockk:mockk-dsl:1.11.0", | ||
"io.mockk:mockk-dsl-jvm:1.11.0", | ||
"io.mockk:mockk-agent-api:1.11.0", |
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.
Why do we need the new mock libraries. Lets have a followup to see if we can fix this.
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.
This subproject wasn't using mockk
before. I had to add them similar to what the other subproject did. We can however try to refactor the common stuff into the main build.gradle
so it doesn't get redeclared. That has some implications though, we can discuss this more as a follow-up.
The backport to
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.0 2.0
# Navigate to the new working tree
cd .worktrees/backport-2.0
# Create a new branch
git switch --create backport/backport-496-to-2.0
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 82a926e1a77fa4deb388aac6f31338bbf9580acb
# Push it to GitHub
git push --set-upstream origin backport/backport-496-to-2.0
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.0 Then, create a pull request where the |
* Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> (cherry picked from commit 82a926e)
The backport to
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.1 2.1
# Navigate to the new working tree
cd .worktrees/backport-2.1
# Create a new branch
git switch --create backport/backport-496-to-2.1
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 82a926e1a77fa4deb388aac6f31338bbf9580acb
# Push it to GitHub
git push --set-upstream origin backport/backport-496-to-2.1
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.1 Then, create a pull request where the |
* Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> (cherry picked from commit 82a926e) Co-authored-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
…t#496) * Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
…t#496) * Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
* Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
* Resolve hosts when checking against host deny list Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub isHostInDenyList() for notification core unit tests Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Stub the correct isHostInDenylist function Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Use Before annotation instead for mocking setup Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Test switching one of the ChimeDestinationTests to use mockk instead of EasyMock Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Switch to BeforeEach for setup and remove unneeded unit test Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com> * Change CustomWebhookDestinationTest and SlackDestinationTests to use BeforeEach as well for consistency Signed-off-by: Mohammad Qureshi <47198598+qreshi@users.noreply.github.com>
Signed-off-by: Mohammad Qureshi 47198598+qreshi@users.noreply.github.com
Description
The Notifications deny list setting (
opensearch.notifications.core.http.host_deny_list
) can take in a list of IPs or IP ranges to be blocked so that messages can't be sent against them. Example:This PR adds hostname resolution before checking against the deny list so that a hostname which is not necessarily an IP (ex.
example.com
) does not bypass the denied IPs.Issues Resolved
[List any issues this PR will resolve]
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.