Code Monkey home page Code Monkey logo

amazon-guardduty-to-slack's Introduction

amazon-guardduty-to-slack

Demonstrates sending Amazon GuardDuty findings to your Slack Channel

Prerequisites:

You must have your own slack account

Step 1:

Create an incoming webhook in slack

  • Go to your slack application and select your team on the top left corner as shown:
  • You will find a popup Menu and you’ll want to click on Manage Apps.
  • You will then want to select custom integrations on the left and Incoming Webhooks.
  • Select the slack channel that you’d like to post messages to with this new incoming web hook. An example would be #general.
  • Press the button to add the incoming web hook at the bottom of the page.
  • Copy the new Webhook URL so we can use it as input in our CloudFormation template.

Step 2:

Use the CloudFormation service to execute the gd2slack.template in this repository

  • You will add your incoming web hook as the first parameter in the template
  • Add the slack channel as a parameter - example #general
  • Add the minimum severity - example HIGH would only send high severity findings, LOW sends all findings
  • Acknowledge that the template will create IAM resources and execute it

Thats it! The template will run for about 5 minutes and you are ready to go.

To test the template be sure that you have GuardDuty enabled in the same region. You can then generate some sample findings. In a few minutes, you should see the findings showing up in your slack channel.

Extending the sample and making it your own

This project is intended to be a sample and I embedded the lambda code directly into the CloudFormation template to make it simple to do an initial deployment to any region. The downside of doing this is that the lambda function is limited to 4096 characters and its node.js embedded in JSON which is difficult to work with. If you want to extend the sample, I'd recommend that you package up the lambda code in your own S3 bucket. You would then just replace the ZipFile parameter in the CloudFormation to the S3Bucket and S3Key of your lambda function.

License

This sample code is made available under the MIT-0 license. See the LICENSE file.

amazon-guardduty-to-slack's People

Contributors

akhil850 avatar hyandell avatar kleo avatar kody-abe avatar phundisk avatar ryanholland avatar thamizarasu avatar tomstickle avatar translucens avatar venu9999 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-guardduty-to-slack's Issues

Node 8.10 EOL

I am using this to forward findings to Slack and just got an email from AWS notifying us that AWS is EOL'ing Node 8.10

I have updated my stack to use 10.x and it seems to work fine, so it would be nice to update the Cloudformation template to make this still function.

The email from AWS:

We are contacting you as we have identified that your AWS Account currently has one or more Lambda functions using Node.js 8.10, which will reach its EOL at the end of 2019.

What’s happening?

The Node community has decided to end support for Node.js 8.x on December 31, 2019 [1]. From this date forward, Node.js 8.x will stop receiving bug fixes, security updates, and/or performance improvements. To ensure that your new and existing functions run on a supported and secure runtime, language runtimes that have reached their EOL are deprecated in AWS [2].

For Node.js 8.x, there will be 2 stages to the runtime deprecation process:

  1. Disable Function Create – Beginning January 6, 2020, customers will no longer be able to create functions using Node.js 8.10

  2. Disable Function Update – Beginning February 3, 2020, customers will no longer be able to update functions using Node.js 8.10

After this period, both function creation and updates will be disabled permanently. However, existing Node 8.x functions will still be available to process invocation events.

What do I need to do?

We encourage you to update all of your Node.js 8.10 functions to the newer available runtime version, Node.js 10.x[3]. You should test your functions for compatibility with the Node.js 10.x language version before applying changes to your production functions.

What if I have issues/What if I need help?

Please contact us through AWS Support [4] or the AWS Developer Forums [5] should you have any questions or concerns.

[1] https://github.com/nodejs/Release
[2] https://docs.aws.amazon.com/lambda/latest/dg/runtime-support-policy.html
[3] https://aws.amazon.com/about-aws/whats-new/2019/05/aws_lambda_adds_support_for_node_js_v10/?nc1=h_ls
[4] https://aws.amazon.com/support
[5] https://forums.aws.amazon.com/forum.jspa?forumID=186

Nodejs18.x runtime issues

AWS doesnot support nodejs16.x anymore and for nodejs18.x and above, this code doesnot work as earlier. Can you update runtime version as well as sample code?

Cannot read properties of undefined (reading 'type') - line 47

Getting an error in Lambda so nothing is posting to slack.

Response
{
"errorType": "TypeError",
"errorMessage": "Cannot read properties of undefined (reading 'type')",
"trace": [
"TypeError: Cannot read properties of undefined (reading 'type')",
" at processEvent (/var/task/index.js:47:36)",
" at Runtime.exports.handler (/var/task/index.js:119:9)",
" at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1085:29)"
]
}

Question on AWSLambdaVPCAccessExecutionRole

Is this really necessary or is there a more restrictive permission set that could accomplish the same?

"arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole" It seems to me that GuardDuty doesn't need to do anything with the VPC. It should just receive the guard duty message as JSON and then post it on to slack. Thoughts?

Connection refused errors on lambda invocation

Deployed this as a cloudformation template with the necessary variables. However, when firing test GuardDuty alerts I get the following:

2021-12-08T22:57:06.856Z	3eb11653-unique-identifier-string-123	ERROR	Uncaught Exception 	{
    "errorType": "Error",
    "errorMessage": "connect ECONNREFUSED 127.0.0.1:443",
    "code": "ECONNREFUSED",
    "errno": "ECONNREFUSED",
    "syscall": "connect",
    "address": "127.0.0.1",
    "port": 443,
    "stack": [
        "Error: connect ECONNREFUSED 127.0.0.1:443",
        "    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16)"
    ]
}

Is there any way to test this setup

I have successfully deployed this stack in our test account but before I do the same in prod i would like to perform a test.

How can I do that?

How to generate fake GuardDuty alerts or trigger this lambda manually?

GuardDuty events with no severity generate bad notifications

When a GuardDuty Event occurs that does not have a severity, such as when you archive a finding, this guardduty-to-slack Lambda generates a junk notification to Slack, which looks like the below.

GuardDutyAPP  11:13
Finding in us-west-2 for Acct: XXXXXXXXXXXX
undefined
undefined
Severity
High
Region
us-west-2
Last Seen
<!date^NaN^{date} at {time} | undefined>

I've implemented a fix for this in my local copy & will submit a PR.

minSeverityLevel variable

Regardless of using Medium or High in the minSeverityLevel variable. I continue to get Severity low notifications in Slack.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.