Skip to content

Final re-work of AWS wodle as per #510#1105

Merged
jesuslinares merged 25 commits into3.6from
dev-aws-cloudtrail-510
Aug 24, 2018
Merged

Final re-work of AWS wodle as per #510#1105
jesuslinares merged 25 commits into3.6from
dev-aws-cloudtrail-510

Conversation

@mgmacias95
Copy link
Copy Markdown
Contributor

@mgmacias95 mgmacias95 commented Aug 14, 2018

Hello team,

This PR adds the full rework of the AWS (#913) wodle made by @UranusBytes with some improvements:

  • Add compatibility with Python 3.
  • Show error messages in ossec.log.
  • Add a general exception handler in the python script.
  • Improve socket error handling. This added a new error code: 13 (Error sending message to wazuh).
  • Improve argparse error handling. Argparse uses error code 2, so the old error code 2 is now 12.
  • Control exceptions when the call AssumeRole fails.

Tested with both python3 and python2.

Best regards,
Marta

Jeremy Phillips and others added 18 commits August 10, 2018 13:41
- Scalability and functional enhancements for parsing of CloudTrail
- Support for existing config params
- Upgrade to a granular object key addressing to support multiple CloudTrails in S3 bucket
- Support granular parsing by account id, region, prefix
- Support only parsing logs after a given date
- Support IAM credential profiles, IAM roles
- Only look for new logs/objects since last iteration
- Skip digest files altogether (only look at logs)
- Move from downloading object and working with file on filesystem to byte stream
- Inherit debug from modulesd
- Add bounds checks for msg against socket buffer size; truncate fields if too big (#733)
- Support multiple debug levels
- Move connect error so not confused with general error
- If fail to parse log, and skip_on_error, attempt to send me msg to wazuh
- Support existing configurations by migrating data, inferring other required params

Associated documentation updates covered in wazuh/wazuh-documentation#274
…avoid conflicts with Elasticsearch dynamic fields and legacy events

- Reparse flag to support re-parsing of log files from s3 bucket
- Use CloudTrail timestamp for ES timestamp
- Various optimizations
- Refactor to make easier to read
The exit code 2 was used for both argparse errors and SIGINTs. Now, the SIGINT code is 12 and argparse errors are shown in ossec.log.
- Fix bug with aws_account_id being required (should not be), not parsing correctly when not included
- Reduce msg debug chatter for reformatting
- Rename script and integration (from aws to aws-cloudtrail) to support additional/other AWS integrations
All error codes higher than 2 are processed in the same way. The error message is extracted from the script output.
All socket errors were interpreted as "Wazuh must be running", invisibilizing any other socket error.
@vikman90 vikman90 added the stall label Aug 17, 2018
* Refactor code into classes

The code was very focused on processing cloudtrail logs, in order to process more aws logs an abstract class has been defined.

* Fix compilation warning

* Iterate over firehouse buckets

* Modify alert structure depending on service

Instead of aws.cloudtrail.event now it is aws.<service_name>.event.

* Remove aws.macie.event.trigger field from generated alerts

That field made the alert to be too big and, in consecuence, not being correctly processed by analysisd.

* Read s3 files in text mode instead of binary mode

* Fix bug getting creation date of files that don't match regex

If a file doesnt have its creation date of its filename, get that information from the "LastModified" attribute.

* Prevent non cloudtrail logs to be removed from db

Only 100 logs were retained in DB for each region. Since firehouse logs don't have any region, only 100 logs were retained for all firehouse buckets at the same time. To prevent that, the bucket name is used as region name.

* Remove overwriting wazuh's timestamp and add srcip for all aws services

* Replace "cloudtrail" names with "s3"

Since the integration now accepts more kinds of log services, cloudtrail name has been replaced for s3.

* Import rules from wazuh-ruleset repository

* Improvements on alert formatting

Remove service name from the alert and reformat single element lists fields into dictionaries

* Fix bug opening zipfiles

* Update elasticsearch template with IP and aws field types

* Show which bucket is being processed at info log level

* Update changelog for #1131
@jesuslinares
Copy link
Copy Markdown
Contributor

jesuslinares commented Aug 23, 2018

Pending:

  • Remove "event" subfield. It would require a re-index. (Check ruleset too)
  • Create a new subfield to store the metadata: file, account, bucket name, etc.
  • Fix Elasticsearch template: IP field only for AWS fields.
  • Fix Logstash template

@jesuslinares
Copy link
Copy Markdown
Contributor

Thanks for this great contribution @mgmacias95 @UranusBytes.

@jesuslinares jesuslinares merged commit aaf24cf into 3.6 Aug 24, 2018
@jesuslinares jesuslinares deleted the dev-aws-cloudtrail-510 branch August 24, 2018 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants