Skip to content

Commit

Permalink
allow for null/NoneType values during type conversion (airbnb#777)
Browse files Browse the repository at this point in the history
* allow for null/nonetype values during type conversion

* adding rule table mocking for rule tests
  • Loading branch information
ryandeivert authored Jun 30, 2018
1 parent b79e824 commit 5ef8ae0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions stream_alert/rule_processor/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ def _convert_type(cls, payload, schema):
"""
for key, value in schema.iteritems():
key = str(key)

# Allow for null/NoneType values
if payload[key] is None:
continue

# if the schema value is declared as string
if value == 'string':
try:
Expand Down
14 changes: 14 additions & 0 deletions stream_alert_cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,20 @@ def setup_mock_firehose_delivery_streams(config):
create_delivery_stream(region, stream_name, prefix)


def setup_mock_dynamodb_rules_table(config):
"""Mock DynamoDB Rules table for rule testing
Args:
config (CLIConfig): The StreamAlert config
"""
if not config['global']['infrastructure'].get('rule_staging', {}).get('enabled'):
return False

prefix = config['global']['account']['prefix']
table_name = '{}_streamalert_rules'.format(prefix)

setup_mock_rules_table(table_name)


def setup_mock_dynamodb_ioc_table(config):
"""Mock DynamoDB IOC table for rule testing
Expand Down
1 change: 1 addition & 0 deletions stream_alert_cli/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ def run_tests(options, context):

# Run the rule processor for all rules or designated rule set
if context.mocked:
helpers.setup_mock_dynamodb_rules_table(config)
helpers.setup_mock_alerts_table(alerts_table)
# Mock S3 bucket for lookup tables testing
helpers.mock_s3_bucket(config)
Expand Down

0 comments on commit 5ef8ae0

Please sign in to comment.