Граф коммитов

18 Коммитов

Автор SHA1 Сообщение Дата
Gene Wood cd919a5304
Correction from the last commit, we need both GetParameter and GetParameters 2020-04-17 15:54:01 -07:00
Gene Wood 4dbd5d5a95
Fix typo in IAM permission for SSM 2020-04-17 15:40:34 -07:00
Gene Wood 4ad8674487
Fix store_oauth_token ValidationException error
This fixes the exception of

botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the PutParameter operation: Invalid request: tags and overwrite can't be used together. To create a parameter with tags, please remove overwrite flag. To update tags for an existing parameter, please use AddTagsToResource or RemoveTagsFromResource.
2020-04-17 15:32:19 -07:00
Emma Rose 70000abf8f
Fix use of cp and rm commands to work on macOS 2020-04-14 20:17:21 -04:00
Emma Rose f4e169eae8
Modify use of ln so it works on macOS 2020-04-14 19:48:28 -04:00
Emma Rose 4761a62572
Modify mktemp calls so they ought to work on both macOS and Linux 2020-04-14 19:42:34 -04:00
Gene Wood 347ca0db4c
Add checks for missing client_secrets 2020-04-14 16:18:54 -07:00
Gene Wood b652f73b46
Add production client_id 2020-04-14 16:18:30 -07:00
Emma Rose 6ce09ae55b
Explicitly mark the output of discover-sqs-queue-url JSON 2020-03-10 15:01:22 -04:00
Emma Rose 3387705fcd
Fixed some residual typos 2020-03-10 15:00:50 -04:00
Gene Wood 55ac67caaf
Move IAM user creation into it's own CloudFormation stack
This will make the IAM user and API keys durable across API
stack rebuilds.
This also grants the IAM user rights to invoke all deployments
of the API and all SQS queues used by the API
2019-12-30 17:00:57 -08:00
Gene Wood 8bb843cb29
Change the result structure one more time to be a JSON dictionary
This was changed in 5d0ba05 and then in 74f8d5f9e5
This is another attempt at getting it right
2019-12-30 16:59:38 -08:00
Gene Wood 051384430d
Add support for emitting slackName to MozDef
This emits an additional piece of information to MozDef about
the user, the user's Slack username in the slackName field of
the SQS message
2019-12-30 16:57:39 -08:00
Gene Wood 74f8d5f9e5
Fix exception handling change to pass results on success
Fix the change introduced in 5d0ba05215 which
fails to pass the result back to the caller upon success.
2019-12-30 10:25:31 -08:00
Gene Wood 5d0ba05215
Improve exception handling
Deal with exceptions differently depending on if the function was called
by API Gateway or through direct invocation.

Pass SlackExceptions through to the invoker of the function.
2019-12-30 10:02:36 -08:00
Gene Wood 03aa28745b
Add working end to end bot
* Add functions to utils
  * store_oauth_token : Store an OAuth 2 access token in SSM parameter store
  * get_access_token : Fetch the OAuth 2 access token for a given client_id from cache or SSM
    parameter store
  * emit_to_mozdef : Send a message with the user's response to SQS for pickup by MozDef
  * call_slack : POST to a slack URL and return the result
  * provision_token : Given an OAuth 2 code, obtain a Slack access token and store it
  * redirect_to_slack_authorize : Build a Slack OAuth 2 authorization URL and redirect the user to it
* Fill out lambda_handler in app to cover all URL paths and direct invocations
* Add functions to app
  * API calls
    * process_api_call : Process an API Gateway call depending on the URL path called
      * `/authorize` : utils.redirect_to_slack_authorize
      * `/redirect_uri` : utils.provision_token
      * `/slack/interactive-endpoint` : handle_message_interaction : Process a user's interaction with a Slack message
        * send_slack_message_response : Respond to a user's selection by updating the Slack message with a reply
  * Direct invocations
    * send_message_to_slack : Send a message to a user via IM or Slack App conversation
      * get_user_from_email : Fetch a slack user dictionary for an email address
      * compose_message : Create a Slack message object
      * create_slack_channel : Create an IM channel with a user
      * post_message : Post a message to a slack channel
* Update README with configuration details
* Add details on discovering the SQS URL to the README
* Add additional test invocations to the Makefile
* Add SQS URL discovery to the Makefile
* Add requests to the requirements.txt
* Update CloudFormation template to
  * accept Slack client ID and secret
  * Grant Lambda function rights to
    * read and write to SSM parameter store
    * decrypt parameter store secrets
    * send messages to the SQS queue
  * Create the SQS queue
  * Grant the MozDef user rights to read from the SQS queue
* Add new settings to config.py
2019-12-27 22:52:14 -08:00
Gene Wood bc43250cec
Add a function invoker IAM user with access keys for MozDef to use 2019-11-27 10:07:55 -08:00
Gene Wood 47845df716
Add AWS Lambda and API Gateway traige bot API 2019-11-26 15:04:55 -08:00