Label.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. import functools
  2. @functools.total_ordering
  3. class Label:
  4. def __init__(self, attack_name, timestamp_start, timestamp_end, parameters, attack_note=""):
  5. """
  6. Creates a new attack label
  7. :param attack_name: The name of the associated attack
  8. :param timestamp_start: The timestamp as unix time of the first attack packet
  9. :param timestamp_end: The timestamp as unix time of the last attack packet
  10. :param parameters: The list of parameters used to run the attack
  11. :param attack_note: A note associated to the attack (optional)
  12. """
  13. self.attack_name = attack_name
  14. self.timestamp_start = timestamp_start
  15. self.timestamp_end = timestamp_end
  16. self.attack_note = attack_note
  17. self.parameters = parameters
  18. def __eq__(self, other):
  19. return self.timestamp == other.timestamp
  20. def __lt__(self, other):
  21. return self.timestamp_start < other.timestamp_start
  22. def __gt__(self, other):
  23. return self.timestamp_start > other.timestamp_start
  24. def __str__(self):
  25. return ''.join(
  26. ['(', self.attack_name, ',', self.attack_note, ',', str(self.timestamp_start), ',', str(self.timestamp_end),
  27. ')'])