airbnb / streamalert

StreamAlert is a serverless, realtime data analysis framework which empowers you to ingest, analyze, and alert on data from any environment, using datasources and alerting logic you define.
https://streamalert.io
Apache License 2.0
2.86k stars 334 forks source link

[BUG] App Creation stores path to file vs file contents. #1261

Closed gavinelder closed 2 years ago

gavinelder commented 4 years ago

Background

Currently in streamalert_cli/helpers.py there is a function called user_input historically user_input used python2 raw_input and as part of calling response_is_valid called a validation function which returned a string.

This string would then replace the contents of raw_input() overriding the user inputed string.

In the later releases of StreamAlert and migration to python3 it appears that input() is no longer having the value manipulated in the same way.

Description

Steps to Reproduce

On a StreamAlert 3.0+ release create a new application such as gsuite or box which utilise this value returned by the validation function, once the application is created go to parameter store and look at the contents you should see the String to the path on disk vs the file contents.

Desired Change

Contents of the file on disk to be stored in parameter store.

chunyong-lin commented 4 years ago

As @gavinelder pointed out in py3 it uses input() while py2 uses raw_input(), but they should behave the same to read the user input as a string which is the keyfile path in our case. Later, we should read the content of the keyfile using _required_auth_info classmethod https://github.com/airbnb/streamalert/blob/a0a284c6bfdb9de40e76fc7581627b5863445cc0/streamalert/apps/_apps/gsuite.py#L200-L227

Definitely there is something wrong when calls _required_auth_info or it may not be called. Will investigate more.

To add more context about @gavinelder 's issue, the value of gsuite_token_gtoken_app_auth should be a json blob containing the context of private key. However, instead of storing the context of private key, it stores the path to the private key file which is wrong. gsuite_gtoken_app_auth

gavinelder commented 3 years ago

Opened a PR to address this, was forced to spend more time than a quick glance as part of building a new app.