* 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 f8f7421c47
commit 1912a27422
3 changed files with 27 additions and 18 deletions

View File

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

View File

@ -191,6 +191,8 @@ class Telemetry(flask_restful.Resource):
if 'wmi' in telemetry_json['data']:
wmi_handler = WMIHandler(monkey_id, telemetry_json['data']['wmi'], users_secrets)
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
def add_ip_to_ssh_keys(ip, ssh_info):

View File

@ -548,6 +548,10 @@ class ReportService:
logger.info('Domain issues generated for reporting')
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
def get_issues():
ISSUE_GENERATORS = [
@ -564,8 +568,11 @@ class ReportService:
for issue in issues:
if issue.get('is_local', True):
machine = issue.get('machine').upper()
aws_instance_id = ReportService.get_machine_aws_instance_id(issue.get('machine'))
if machine not in issues_dict:
issues_dict[machine] = []
if aws_instance_id:
issue['aws_instance_id'] = aws_instance_id
issues_dict[machine].append(issue)
logger.info('Issues generated for reporting')
return issues_dict