Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lambda][rule] fixing a bug related to log_pattern enforcement #131

Merged
merged 5 commits into from
May 5, 2017

Conversation

ryandeivert
Copy link
Contributor

to: @airbnb/streamalert-maintainers
size: medium

changes

  • Found that we were not applying log_patterns to logs that matched only one schema and fixed this so log_patterns will always be applied if they exist for a defined schema.
  • Fixing a bug where typed data was not being returned in records
  • Recursively nested parsing of csv and json are now supported
  • Updating tests for multiple schema matching with log_patterns
  • Updating tests for single schema matching with log_patterns

@ryandeivert ryandeivert force-pushed the ryandeivert-fix-for-log-patterns branch from da68f9b to cc3a6ce Compare May 4, 2017 00:19
# configuration settings such as envelope and optional_keys
converted_data = self._convert_type(data, parser.type(), parser.schema, parser.options)
converted_data = self._convert_type(data, valid_parse.parser.type(), valid_parse.root_schema, valid_parse.parser.options)
Copy link
Contributor

Choose a reason for hiding this comment

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

rename this to conversion_result

Copy link
Contributor Author

Choose a reason for hiding this comment

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

simplified this - ptal

schema_match = False

for json_record in json_records:
json_keys = set(json_record.keys())
for i in reversed(range(len(json_records))):
Copy link
Contributor

Choose a reason for hiding this comment

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

can we use a different variable name an i

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure thing

@ryandeivert ryandeivert force-pushed the ryandeivert-fix-for-log-patterns branch from 42d1d8e to 4a1dcf4 Compare May 4, 2017 18:35

from stream_alert.rule_processor.parsers import get_parser

logging.basicConfig()
LOGGER = logging.getLogger('StreamAlert')

# Set the below to True when we want to support multiple matching on multiple schema
Copy link

Choose a reason for hiding this comment

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

multiple matching on multiple schema matching

image

Make this clear

Copy link
Contributor

Choose a reason for hiding this comment

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

1ofj3b

def _parse(self, payload, data):
"""Parse a record into a declared type.
def _process_log_schemas(self, payload, data):
"""Get any log schemas that properly classified this log
Copy link

Choose a reason for hiding this comment

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

The wording is weird. A schema doesn't classify a log, nor does a schema parse a log (said a bit below). We identify what schemas a log matches to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good eye. changed this

@ryandeivert ryandeivert force-pushed the ryandeivert-fix-for-log-patterns branch 4 times, most recently from 17ebd04 to a9a1c6b Compare May 5, 2017 05:18
* Fixing a bug where typed data was not being returned in records
* Recursively nested parsing of csv and json are now supported
* Updating tests for multiple schema matching with log_patterns
* Updating tests for single schema matching with log_patterns
…keys' and updating docs to reflect the change
@ryandeivert ryandeivert force-pushed the ryandeivert-fix-for-log-patterns branch from a9a1c6b to 300a722 Compare May 5, 2017 18:23
@ryandeivert ryandeivert merged commit 7cedf2a into master May 5, 2017
@ryandeivert ryandeivert deleted the ryandeivert-fix-for-log-patterns branch May 5, 2017 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants