* added instance ID to each issue in an aws machine

* changed findings resource to ec2 instance id instead of IP
This commit is contained in:
maor.rayzin 2018-11-26 12:59:06 +02:00
parent 30a6d7542f
commit a79c60e9bc
3 changed files with 27 additions and 18 deletions

View File

@ -93,8 +93,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['dest'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -118,8 +118,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": str(issue['ip_address']) "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -143,8 +143,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['ip_address'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -167,8 +167,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['ip_address'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -191,8 +191,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['ip_address'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -215,8 +215,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['networks'][0][:-2] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -243,8 +243,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": '10.0.0.1' "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -267,8 +267,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['ip_address'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }
@ -291,8 +291,8 @@ class AWSExporter(Exporter):
"Normalized": 100 "Normalized": 100
}, },
"Resources": [{ "Resources": [{
"Type": "IpAddress", "Type": "AwsEc2Instance",
"Id": issue['ip_address'] "Id": issue['aws_instance_id']
}], }],
"RecordState": "ACTIVE", "RecordState": "ACTIVE",
} }

View File

@ -191,6 +191,8 @@ class Telemetry(flask_restful.Resource):
if 'wmi' in telemetry_json['data']: if 'wmi' in telemetry_json['data']:
wmi_handler = WMIHandler(monkey_id, telemetry_json['data']['wmi'], users_secrets) wmi_handler = WMIHandler(monkey_id, telemetry_json['data']['wmi'], users_secrets)
wmi_handler.process_and_handle_wmi_info() wmi_handler.process_and_handle_wmi_info()
if 'aws' in telemetry_json['data']:
mongo.db.monkey.insert({'aws_instance_id': telemetry_json['data']['instance-id']})
@staticmethod @staticmethod
def add_ip_to_ssh_keys(ip, ssh_info): def add_ip_to_ssh_keys(ip, ssh_info):

View File

@ -548,6 +548,10 @@ class ReportService:
logger.info('Domain issues generated for reporting') logger.info('Domain issues generated for reporting')
return domain_issues_dict return domain_issues_dict
@staticmethod
def get_machine_aws_instance_id(hostname):
return str(mongo.db.monkey.find({'hostname': hostname}, {'aws_instance_id': 1}))
@staticmethod @staticmethod
def get_issues(): def get_issues():
ISSUE_GENERATORS = [ ISSUE_GENERATORS = [
@ -564,8 +568,11 @@ class ReportService:
for issue in issues: for issue in issues:
if issue.get('is_local', True): if issue.get('is_local', True):
machine = issue.get('machine').upper() machine = issue.get('machine').upper()
aws_instance_id = ReportService.get_machine_aws_instance_id(issue.get('machine'))
if machine not in issues_dict: if machine not in issues_dict:
issues_dict[machine] = [] issues_dict[machine] = []
if aws_instance_id:
issue['aws_instance_id'] = aws_instance_id
issues_dict[machine].append(issue) issues_dict[machine].append(issue)
logger.info('Issues generated for reporting') logger.info('Issues generated for reporting')
return issues_dict return issues_dict