From fbb204072bb851d8a1b8668d6e312825329026f3 Mon Sep 17 00:00:00 2001 From: Austin Byers Date: Mon, 14 Aug 2017 10:53:51 -0700 Subject: [PATCH] Feedback from last live_test PR (#39) --- manage.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/manage.py b/manage.py index 9919b10..4e06da4 100644 --- a/manage.py +++ b/manage.py @@ -125,11 +125,10 @@ def live_test(self): ) table_name = '{}_binaryalert_matches'.format(self._config['name_prefix']) - print('EICAR test file uploaded! Connecting to table DynamoDB:{}'.format(table_name)) + print('EICAR test file uploaded! Connecting to table DynamoDB:{}...'.format(table_name)) table = boto3.resource('dynamodb').Table(table_name) eicar_sha256 = hashlib.sha256(EICAR_STRING.encode('UTF-8')).hexdigest() dynamo_record_found = False - lambda_version = 0 for attempt in range(1, 11): time.sleep(5) @@ -143,21 +142,22 @@ def live_test(self): KeyConditionExpression=Key('SHA256').eq(eicar_sha256), FilterExpression=Attr('S3Objects').contains(s3_identifier) ).get('Items') + if items: print('\nSUCCESS: Expected DynamoDB entry for the EICAR file was found!\n') dynamo_record_found = True - lambda_version = items[0]['LambdaVersion'] pprint.pprint(items[0]) + + print('\nRemoving DynamoDB EICAR entry...') + lambda_version = items[0]['LambdaVersion'] + table.delete_item(Key={'SHA256': eicar_sha256, 'LambdaVersion': lambda_version}) break elif attempt == 10: print('\nFAIL: Expected DynamoDB entry for the EICAR file was *not* found!\n') - print('\nRemoving EICAR test file from S3...') + print('Removing EICAR test file from S3...') bucket.delete_objects(Delete={'Objects': [{'Key': test_filename}]}) - print('Removing DynamoDB EICAR entry...') - table.delete_item(Key={'SHA256': eicar_sha256, 'LambdaVersion': lambda_version}) - if dynamo_record_found: print('\nLive test succeeded! Verify the alert was sent to your SNS subscription(s).') else: