Skip to content

Commit

Permalink
changing the usage of 'stream_log_envelope' to 'streamalert:envelope_…
Browse files Browse the repository at this point in the history
…keys' and updating docs to reflect the change
  • Loading branch information
ryandeivert committed May 5, 2017
1 parent cb29573 commit a9a1c6b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docs/source/conf-schemas.rst
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ The resultant parsed records::
"example": 1,
"host": "jumphost-1.domain.com",
"time": "11:00 PM",
"envelope": {
"streamalert:envelope_keys": {
"id": 1431948983198,
"application": "my-app"
}
Expand All @@ -329,7 +329,7 @@ The resultant parsed records::
"example": 2,
"host": "jumphost-2.domain.com",
"time": "12:00 AM",
"envelope": {
"streamalert:envelope_keys": {
"id": 1431948983198,
"application": "my-app"
}
Expand Down
6 changes: 3 additions & 3 deletions stream_alert/rule_processor/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def _parse(self, payload, data):
for data in valid_parse.parsed_data:
# Convert data types per the schema
# Use the root schema for the parser due to updates caused by
# configuration settings such as envelope and optional_keys
# configuration settings such as envelope_keys and optional_keys
if not self._convert_type(data, valid_parse.parser.type(), valid_parse.root_schema, valid_parse.parser.options):
return False

Expand Down Expand Up @@ -372,8 +372,8 @@ def _convert_type(self, payload, parser_type, schema, options):
continue # allow empty maps (dict)

# handle nested values
# skip the 'stream_log_envelope' key that we've added during parsing
if key == 'stream_log_envelope' and isinstance(payload[key], dict):
# skip the 'streamalert:envelope_keys' key that we've added during parsing
if key == 'streamalert:envelope_keys' and isinstance(payload[key], dict):
continue

if 'log_patterns' in options:
Expand Down
8 changes: 4 additions & 4 deletions stream_alert/rule_processor/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def _key_check(self, schema, json_records):
if json_keys == schema_keys:
schema_match = True
for key, key_type in schema.iteritems():
if key == 'stream_log_envelope' and isinstance(json_records[index][key], dict):
if key == 'streamalert:envelope_keys' and isinstance(json_records[index][key], dict):
continue
# Nested key check
if key_type and isinstance(key_type, dict):
Expand All @@ -154,7 +154,7 @@ def _parse_records(self, schema, json_payload):
JSONpath selector that yields the desired nested records).
If desired, fields present on the root record can be merged into child
events using the `envelope` option.
events using the `envelope_keys` option.
Args:
json_payload [dict]: The parsed json data
Expand Down Expand Up @@ -201,7 +201,7 @@ def default_optional_values(key):
envelope = {}
envelope_schema = self.options.get('envelope_keys', {})
if len(envelope_schema):
schema.update({'stream_log_envelope': envelope_schema})
schema.update({'streamalert:envelope_keys': envelope_schema})
envelope_keys = envelope_schema.keys()
envelope_jsonpath = jsonpath_rw.parse("$." + ",".join(envelope_keys))
envelope_matches = [match.value for match in envelope_jsonpath.find(json_payload)]
Expand All @@ -211,7 +211,7 @@ def default_optional_values(key):
for match in records_jsonpath.find(json_payload):
record = match.value
if len(envelope):
record.update({'stream_log_envelope': envelope})
record.update({'streamalert:envelope_keys': envelope})

json_records.append(record)

Expand Down
4 changes: 2 additions & 2 deletions test/unit/test_gzip_json_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def test_cloudwatch(self):
expected_keys = (u'protocol', u'source', u'destination', u'srcport',
u'destport', u'eni', u'action', u'packets', u'bytes',
u'windowstart', u'windowend', u'version', u'account',
u'flowlogstatus',u'stream_log_envelope')
u'flowlogstatus',u'streamalert:envelope_keys')
expected_envelope_keys = (u'logGroup', u'logStream', u'owner')

for result in parsed_result:
assert_equal(sorted(expected_keys), sorted(result.keys()))
assert_equal(sorted(expected_envelope_keys),sorted(result['stream_log_envelope'].keys()))
assert_equal(sorted(expected_envelope_keys),sorted(result['streamalert:envelope_keys'].keys()))

0 comments on commit a9a1c6b

Please sign in to comment.