Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FiveTuple printing #1034

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
9 changes: 6 additions & 3 deletions nat-lab/tests/utils/connection_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def __hash__(self):
(self.protocol, self.src_ip, self.dst_ip, self.src_port, self.dst_port)
)

def __str__(self) -> str:
return f"{self.protocol} {self.src_ip}:{self.src_port} -> {self.dst_ip}:{self.dst_port}"


class EventType(Enum):
"""Event type reported by conntrack"""
Expand Down Expand Up @@ -147,7 +150,7 @@ def __init__(
):
if max_limit is not None and min_limit is not None and max_limit < min_limit:
raise ValueError(
f"Max limit {max_limit} is smaller then min limit {min_limit}"
f"Max limit {max_limit} is smaller than min limit {min_limit}"
)

self.key = key
Expand All @@ -172,12 +175,12 @@ def find_conntracker_violations(
if self.max_limit is not None and count > self.max_limit:
return ConnTrackerViolation(
recoverable=False,
reason=f"In {self.key} there has been {count} connections to {FiveTuple} which is more then max limit of {self.max_limit}",
reason=f"In {self.key} there has been {count} connections to {FiveTuple} which is more than max limit of {self.max_limit}",
)
if self.min_limit is not None and count < self.min_limit:
return ConnTrackerViolation(
recoverable=True,
reason=f"In {self.key} there has been {count} connections to {FiveTuple} which is less then min limit of {self.min_limit}",
reason=f"In {self.key} there has been {count} connections to {FiveTuple} which is less than min limit of {self.min_limit}",
)

return None
Expand Down
Loading