@@ -125,11 +125,10 @@ def live_test(self):
125
125
)
126
126
127
127
table_name = '{}_binaryalert_matches' .format (self ._config ['name_prefix' ])
128
- print ('EICAR test file uploaded! Connecting to table DynamoDB:{}' .format (table_name ))
128
+ print ('EICAR test file uploaded! Connecting to table DynamoDB:{}... ' .format (table_name ))
129
129
table = boto3 .resource ('dynamodb' ).Table (table_name )
130
130
eicar_sha256 = hashlib .sha256 (EICAR_STRING .encode ('UTF-8' )).hexdigest ()
131
131
dynamo_record_found = False
132
- lambda_version = 0
133
132
134
133
for attempt in range (1 , 11 ):
135
134
time .sleep (5 )
@@ -143,21 +142,22 @@ def live_test(self):
143
142
KeyConditionExpression = Key ('SHA256' ).eq (eicar_sha256 ),
144
143
FilterExpression = Attr ('S3Objects' ).contains (s3_identifier )
145
144
).get ('Items' )
145
+
146
146
if items :
147
147
print ('\n SUCCESS: Expected DynamoDB entry for the EICAR file was found!\n ' )
148
148
dynamo_record_found = True
149
- lambda_version = items [0 ]['LambdaVersion' ]
150
149
pprint .pprint (items [0 ])
150
+
151
+ print ('\n Removing DynamoDB EICAR entry...' )
152
+ lambda_version = items [0 ]['LambdaVersion' ]
153
+ table .delete_item (Key = {'SHA256' : eicar_sha256 , 'LambdaVersion' : lambda_version })
151
154
break
152
155
elif attempt == 10 :
153
156
print ('\n FAIL: Expected DynamoDB entry for the EICAR file was *not* found!\n ' )
154
157
155
- print ('\n Removing EICAR test file from S3...' )
158
+ print ('Removing EICAR test file from S3...' )
156
159
bucket .delete_objects (Delete = {'Objects' : [{'Key' : test_filename }]})
157
160
158
- print ('Removing DynamoDB EICAR entry...' )
159
- table .delete_item (Key = {'SHA256' : eicar_sha256 , 'LambdaVersion' : lambda_version })
160
-
161
161
if dynamo_record_found :
162
162
print ('\n Live test succeeded! Verify the alert was sent to your SNS subscription(s).' )
163
163
else :
0 commit comments