Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Slack Webhook Pipeline for Notifier #563

Merged
merged 13 commits into from Sep 14, 2017

Conversation

acotenoff
Copy link
Contributor

@acotenoff acotenoff commented Aug 17, 2017

Thanks for opening a Pull Request!

Here's a handy checklist to ensure your PR goes smoothly.

These guidelines and more can be found in our contributing guidelines.

This PR adds support for posting violations to a Slack webhook.

@acotenoff acotenoff changed the title Slack Webhook Pipeline for Notifier Slack Webhook Pipeline for Notifier WIP Aug 17, 2017
@codecov
Copy link

codecov bot commented Aug 18, 2017

Codecov Report

Merging #563 into dev will decrease coverage by <.01%.
The diff coverage is 81.25%.

@@            Coverage Diff            @@
##             dev     #563      +/-   ##
=========================================
- Coverage   83.5%   83.49%   -0.01%     
=========================================
  Files        164      165       +1     
  Lines       8185     8217      +32     
=========================================
+ Hits        6835     6861      +26     
- Misses      1350     1356       +6
Impacted Files Coverage Δ
...urity/notifier/pipelines/slack_webhook_pipeline.py 81.25% <81.25%> (ø)
...le/cloud/security/common/data_access/csv_writer.py 91.83% <0%> (ø) ⬆️

@gbrindisi
Copy link
Contributor

@blueandgold here comes the test case!

@blueandgold blueandgold self-requested a review September 12, 2017 03:35
Copy link
Contributor

@blueandgold blueandgold left a comment

Choose a reason for hiding this comment

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

The slack integration is super cool....!! Everything looks great, just some style nits.

@@ -140,3 +140,10 @@ notifier:
sendgrid_api_key: ''
sender: ''
recipient: ''
# Slack webhook pipeline
# Create an incoming webhook in your organization's Slack located at:
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Sorry to point this out, but would adding the word setting such as below, read better?
# Create an incoming webhook in your organization's Slack setting, located at:

@@ -0,0 +1,95 @@

# Copyright 2017 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nenad made us change to the shared copyright as below: 😄
# Copyright 2017 The Forseti Security Authors. All rights reserved.

@@ -0,0 +1,95 @@

Copy link
Contributor

Choose a reason for hiding this comment

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

Please remove the blank line.

Copy link
Contributor

Choose a reason for hiding this comment

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

done!

@@ -0,0 +1,54 @@
# Copyright 2017 Google Inc.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto on shared copyright

webhook_payload: a string formatted violation
"""

def slack_output_dump(data, indent=0):
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the consideration to define this slack_output_dump() as a nested method of _compose()? I would seem to be more clear if it is moved out as a private method within the class.

Note the underscore in the method name, to denote the private.

class SlackWebhookPipeline(bnp.BaseNotificationPipeline):
    def _slack_output_dump(data, indent=0):
        blah blah blah

    def _compose(self, **kwargs):
        blah blah blah

webhook_payload: a string formatted violation
"""

def slack_output_dump(data, indent=0):
Copy link
Contributor

Choose a reason for hiding this comment

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

Another nit: method names usually start with a verb. So, in this case, the method name would be more awesome as:
_dump_slack_output()

@gbrindisi
Copy link
Contributor

@blueandgold fixed, thanks for the nits!

Copy link
Contributor

@blueandgold blueandgold left a comment

Choose a reason for hiding this comment

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

Looks super awesome now!

Copy link
Contributor

@mirons-google mirons-google left a comment

Choose a reason for hiding this comment

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

Do we also want to include an entry in configs/forseti_conf.yaml.in?

# See the License for the specific language governing permissions and
# limitations under the License.

"""Slack webhook pipeline to perform notifications"""
Copy link
Contributor

Choose a reason for hiding this comment

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

super-nit: Don't forget the period to end the sentence.

@mirons-google mirons-google changed the title Slack Webhook Pipeline for Notifier WIP Slack Webhook Pipeline for Notifie Sep 14, 2017
@mirons-google mirons-google changed the title Slack Webhook Pipeline for Notifie Slack Webhook Pipeline for Notifier Sep 14, 2017
@carise carise merged commit e07bb9e into forseti-security:dev Sep 14, 2017
@gbrindisi
Copy link
Contributor

thank you!

@acotenoff acotenoff deleted the slack_pipeline branch September 18, 2017 09:14
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants