Handle InvalidSignature and add to suspicious activities and log the offense

pull/1746/head
tuxxy 2020-02-25 03:18:43 +01:00
parent 8b2ac8106d
commit 87534a944d
2 changed files with 3 additions and 2 deletions

View File

@ -852,8 +852,8 @@ class Learner:
try:
self.verify_from(current_teacher, node_payload, signature=signature)
except current_teacher.InvalidSignature:
# TODO: What to do if the teacher improperly signed the node payload? 1713
raise
self.suspicious_activities_witnessed['vladimirs'].append(('Node payload improperly signed', node_payload, signature))
self.log.warn(f"Invalid signature ({signature}) received from teacher {current_teacher} for payload {node_payload}")
# End edge case handling.
fleet_state_checksum_bytes, fleet_state_updated_bytes, node_payload = FleetStateTracker.snapshot_splitter(

View File

@ -59,6 +59,7 @@ def test_blockchain_ursula_stamp_verification_tolerance(blockchain_ursulas, mock
# Learn about a node with a badly signed payload
mocker.patch.object(lonely_blockchain_learner, 'verify_from', side_effect=Learner.InvalidSignature)
lonely_blockchain_learner.learn_from_teacher_node(eager=True)
assert len(lonely_blockchain_learner.suspicious_activities_witnessed['vladimirs']) == 1
@pytest.mark.skip("See Issue #1075") # TODO: Issue #1075
def test_invalid_workers_tolerance(testerchain,