Skip to content

Commit

Permalink
feat(#3341): Add remove_from_bucket test for aws Trusted Advisor inte…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
nico-stefani committed Jan 9, 2023
1 parent d3cd160 commit f5eef7a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions deps/wazuh_testing/wazuh_testing/modules/aws/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@
CLOUD_TRAIL_TYPE = 'cloudtrail'
VPC_FLOW_TYPE = 'vpcflow'
KMS_TYPE = 'kms'
TRUSTED_ADVISOR_TYPE = 'trusted'
CUSTOM_TYPE = 'custom'
56 changes: 55 additions & 1 deletion deps/wazuh_testing/wazuh_testing/modules/aws/data_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,65 @@ def get_data_sample(self) -> str:
)


class TrustedAdvisorDataGenerator(DataGenerator):
BASE_PATH = ''
BASE_FILE_NAME = f'firehose_trustedadvisor-1-'

def get_filename(self, *args, **kwargs) -> str:
"""Return the filename in the Trusted Advisor format.
Example:
<prefix>/<year>/<month>/<day>
Returns:
str: Syntetic filename.
"""
now = datetime.now()
path = f"{self.BASE_PATH}{now.strftime(cons.PATH_DATE_FORMAT)}/"
name = f"{self.BASE_FILE_NAME}{now.strftime(cons.FILENAME_DATE_FORMAT)}{cons.JSON_EXT}"

return f'{path}{name}'

def get_data_sample(self) -> str:
"""Returns a sample of data according to the KMS format.
Returns:
str: Syntetic data.
"""
return json.dumps(
{
'version': '0',
'id': get_random_string(26),
'detail-type': 'Trusted Advisor Check Item Refresh Notification',
'source': 'aws.trustedadvisor',
'account': cons.RANDOM_ACCOUNT_ID,
'time': datetime.now().strftime(cons.FILENAME_DATE_FORMAT),
'region': 'us-east-1',
'resources': [],
'detail': {
'check-name': 'IAM Group',
'check-item-detail': {
'Status': 'Green',
'Current Usage': '1',
'Limit Name': 'Groups',
'Region': '-',
'Service': 'IAM',
'Limit Amount': '300'
},
'status': 'OK',
'resource_id': '',
'uuid': str(uuid4())
}
}
)


# Maps bucket type with corresponding data generator
buckets_data_mapping = {
cons.CLOUD_TRAIL_TYPE: CloudTrailDataGenerator,
cons.VPC_FLOW_TYPE: VPCDataGenerator,
cons.KMS_TYPE: KMSDataGenerator
cons.KMS_TYPE: KMSDataGenerator,
cons.TRUSTED_ADVISOR_TYPE: TrustedAdvisorDataGenerator,
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,12 @@
metadata:
bucket_type: cloudtrail
bucket_name: wazuh-cloudtrail-integration-tests

- name: trusted_advisor_remove_from_bucket
description: Trusted Advisor remove from bucket configurations
configuration_parameters:
BUCKET_TYPE: custom
BUCKET_NAME: wazuh-trusted-advisor-integration-tests
metadata:
bucket_type: custom
bucket_name: wazuh-trusted-advisor-integration-tests

0 comments on commit f5eef7a

Please sign in to comment.