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

Add Slack webhook exposed key handling #605

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gjcthinkst
Copy link
Contributor

@gjcthinkst gjcthinkst commented Nov 8, 2024

Proposed changes

Add Slack webhook support for exposed API key alerts. While we're in the area also do some refactoring and general improvements for the Slack webhook.

Types of changes

What types of changes does your code introduce to this repository?

  • New feature (non-breaking change which adds functionality)

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Lint and unit tests pass locally with my changes (if applicable)
  • I have run pre-commit (pre-commit in the repo)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • Linked to the relevant github issue or github discussion

Further comments

I tested the changes to the Slack webhook by creating a new AWS API key token, triggering it normally and manually creating an exposed key alert with CURL (with 25 Dec as the exposed time) and checked that all three Slack messages displayed correctly.

CleanShot 2024-11-14 at 17 31 41@2x

An example of the current (before this change) Slack message format is shown below.

CleanShot 2024-11-07 at 15 54 14@2x

@thinkst-tom
Copy link
Contributor

@gjcthinkst Seeing as we're refactoring here, do you perhaps think that this might be a good time to also change to using the newer block format for the webhook payload? Slack has marked attachments (which are used in the current webhook payload) as a legacy feature.

@gjcthinkst
Copy link
Contributor Author

@gjcthinkst Seeing as we're refactoring here, do you perhaps think that this might be a good time to also change to using the newer block format for the webhook payload? Slack has marked attachments (which are used in the current webhook payload) as a legacy feature.

@thinkst-tom Good suggestion, thanks! I've updated the code to use the new block format.

Copy link
Contributor

@thinkst-tom thinkst-tom left a comment

Choose a reason for hiding this comment

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

Thanks @gjcthinkst this looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants