amira
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: amira | ||
| Version: 1.2.2 | ||
| Version: 2.0.0 | ||
| Summary: Automated Malware Incident Response and Analysis | ||
@@ -54,5 +54,5 @@ Home-page: https://github.com/Yelp/amira | ||
| AMIRA uses boto to interface with AWS. | ||
| You can supply the credentials using either of the possible | ||
| [boto config files](http://boto.cloudhackers.com/en/latest/boto_config_tut.html#details). | ||
| AMIRA uses boto3 to interface with AWS. | ||
| You can supply credentials using either of the possible | ||
| [configuration options](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). | ||
@@ -59,0 +59,0 @@ The credentials should allow reading and deleting SQS messages |
@@ -1,3 +0,3 @@ | ||
| boto | ||
| boto3 | ||
| osxcollector_output_filters>=1.1.1 | ||
| simplejson |
@@ -5,2 +5,2 @@ # -*- coding: utf-8 -*- | ||
| __version__ = '1.2.2' | ||
| __version__ = '2.0.0' |
+14
-37
@@ -7,4 +7,3 @@ # -*- coding: utf-8 -*- | ||
| import boto | ||
| from boto.s3.key import Key | ||
| import boto3 | ||
@@ -18,3 +17,3 @@ from amira.results_uploader import ResultsUploader | ||
| (object) with the contents of a given file. | ||
| AWS and boto use the ambiguous term "key" to describe the objects | ||
| AWS uses the ambiguous term "key" to describe the objects | ||
| inside the S3 bucket. They are unrelated to AWS keys used to access | ||
@@ -25,3 +24,3 @@ the resources. | ||
| def __init__(self): | ||
| self._s3_connection = boto.connect_s3() | ||
| self._s3_connection = boto3.client('s3') | ||
@@ -33,13 +32,9 @@ def get_contents_as_string(self, bucket_name, key_name): | ||
| :type bucket_name: string | ||
| :param key_name: The S3 key (object) name. | ||
| :type key_name: string | ||
| :returns: The key (object) contents as a string. | ||
| :rtype: string | ||
| :returns: The key (object) contents as a bytes (str in py2). | ||
| :rtype: bytes | ||
| """ | ||
| bucket = self._s3_connection.get_bucket(bucket_name, validate=False) | ||
| key = bucket.get_key(key_name) | ||
| contents = key.get_contents_as_string() | ||
| return contents | ||
| response = self._s3_connection.get_object(Bucket=bucket_name, Key=key_name) | ||
| return response['Body'].read() | ||
@@ -57,16 +52,4 @@ | ||
| self._bucket_name = bucket_name | ||
| self._s3_connection = boto3.client('s3') | ||
| logging.info( | ||
| 'Connecting to S3 to obtain access to {0} bucket.'.format( | ||
| bucket_name, | ||
| ), | ||
| ) | ||
| s3_connection = boto.connect_s3() | ||
| self._bucket = s3_connection.get_bucket(bucket_name, validate=False) | ||
| logging.info( | ||
| 'S3 bucket {0} retrieved successfully.'.format( | ||
| bucket_name, | ||
| ), | ||
| ) | ||
| def upload_results(self, results): | ||
@@ -85,13 +68,7 @@ """Uploads the analysis results to an S3 bucket. | ||
| ) | ||
| self._create_object_from_file(file_meta_info) | ||
| def _create_object_from_file(self, file_meta_info): | ||
| """Creates a new key (object) in the S3 bucket with the | ||
| contents of a given file. | ||
| """ | ||
| key = Key(self._bucket) | ||
| key.key = file_meta_info.name | ||
| key.set_contents_from_file( | ||
| file_meta_info.content, | ||
| headers={'Content-Type': file_meta_info.content_type}, | ||
| ) | ||
| self._s3_connection.put_object( | ||
| Bucket=self._bucket_name, | ||
| Key=file_meta_info.name, | ||
| ContentType=file_meta_info.content_type, | ||
| Body=file_meta_info.content, | ||
| ) |
+11
-45
@@ -8,5 +8,4 @@ # -*- coding: utf-8 -*- | ||
| import boto.sqs | ||
| import boto3 | ||
| import simplejson | ||
| from boto.sqs.message import RawMessage | ||
@@ -36,7 +35,4 @@ | ||
| def __init__(self, region_name, queue_name): | ||
| self._setup_sqs_queue(region_name, queue_name) | ||
| """ Connects to the SQS queue in a given AWS region. | ||
| def _setup_sqs_queue(self, region_name, queue_name): | ||
| """Connects to the SQS queue in a given AWS region. | ||
| :param region_name: The AWS region name. | ||
@@ -47,16 +43,8 @@ :type region_name: string | ||
| """ | ||
| sqs_connection = boto.sqs.connect_to_region(region_name) | ||
| self.sqs_queue = sqs_connection.get_queue(queue_name) | ||
| if not self.sqs_queue: | ||
| raise SqsQueueNotFoundException(queue_name) | ||
| sqs_connection = boto3.resource('sqs', region_name=region_name) | ||
| self.sqs_queue = sqs_connection.get_queue_by_name(QueueName=queue_name) | ||
| logging.info( | ||
| 'Successfully connected to {0} SQS queue'.format( | ||
| queue_name, | ||
| ), | ||
| 'Successfully connected to {} SQS queue'.format(queue_name), | ||
| ) | ||
| self.sqs_queue.set_message_class(RawMessage) | ||
| def get_created_objects(self): | ||
@@ -67,20 +55,13 @@ """Retrieves the S3 event notifications about the objects | ||
| """ | ||
| messages = self.sqs_queue.get_messages(MAX_NUMBER_MESSAGES) | ||
| messages = self.sqs_queue.receive_messages(MaxNumberOfMessages=MAX_NUMBER_MESSAGES) | ||
| logging.info( | ||
| 'Received {0} message(s) from the SQS queue'.format( | ||
| len(messages), | ||
| ), | ||
| 'Received {0} message(s) from the SQS queue'.format(len(messages)), | ||
| ) | ||
| if messages: | ||
| for message in messages: | ||
| objects_created = self._retrieve_created_objects_from_message( | ||
| message, | ||
| ) | ||
| objects_created = self._retrieve_created_objects_from_message(message) | ||
| for object_created in objects_created: | ||
| yield object_created | ||
| message.delete() | ||
| self.sqs_queue.delete_message_batch(messages) | ||
| def _retrieve_created_objects_from_message(self, message): | ||
@@ -97,5 +78,3 @@ """Retrieves the bucket name and the key name, describing the | ||
| """ | ||
| json_body = message.get_body() | ||
| body = simplejson.loads(json_body) | ||
| body = simplejson.loads(message.body) | ||
| if 'Records' not in body: | ||
@@ -107,6 +86,4 @@ logging.warning( | ||
| return [] | ||
| return self._extract_created_objects_from_records(body['Records']) | ||
| records = body['Records'] | ||
| return self._extract_created_objects_from_records(records) | ||
| def _extract_created_objects_from_records(self, records): | ||
@@ -116,3 +93,2 @@ logging.info( | ||
| ) | ||
| for record in records: | ||
@@ -122,11 +98,1 @@ bucket_name = record['s3']['bucket']['name'] | ||
| yield CreatedObject(bucket_name=bucket_name, key_name=key_name) | ||
| class SqsQueueNotFoundException(Exception): | ||
| """An exception thrown when the SQS queue cannot be found.""" | ||
| def __init__(self, queue_name): | ||
| self.queue_name = queue_name | ||
| def __str__(self): | ||
| return 'SQS queue {0} not found.'.format(self.queue_name) |
+4
-4
| Metadata-Version: 2.1 | ||
| Name: amira | ||
| Version: 1.2.2 | ||
| Version: 2.0.0 | ||
| Summary: Automated Malware Incident Response and Analysis | ||
@@ -54,5 +54,5 @@ Home-page: https://github.com/Yelp/amira | ||
| AMIRA uses boto to interface with AWS. | ||
| You can supply the credentials using either of the possible | ||
| [boto config files](http://boto.cloudhackers.com/en/latest/boto_config_tut.html#details). | ||
| AMIRA uses boto3 to interface with AWS. | ||
| You can supply credentials using either of the possible | ||
| [configuration options](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). | ||
@@ -59,0 +59,0 @@ The credentials should allow reading and deleting SQS messages |
+3
-3
@@ -46,5 +46,5 @@  | ||
| AMIRA uses boto to interface with AWS. | ||
| You can supply the credentials using either of the possible | ||
| [boto config files](http://boto.cloudhackers.com/en/latest/boto_config_tut.html#details). | ||
| AMIRA uses boto3 to interface with AWS. | ||
| You can supply credentials using either of the possible | ||
| [configuration options](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html). | ||
@@ -51,0 +51,0 @@ The credentials should allow reading and deleting SQS messages |
+1
-1
@@ -53,3 +53,3 @@ #!/usr/bin/python | ||
| install_requires=[ | ||
| 'boto', | ||
| 'boto3', | ||
| 'osxcollector_output_filters>=1.1.1', | ||
@@ -56,0 +56,0 @@ 'simplejson', |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
37217
-3.44%419
-8.52%