Skip to content

Commit

Permalink
more strict validation of the IPs passed to ProfileID dataclass
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Feb 2, 2024
1 parent 0883928 commit 4455b4f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions slips_files/core/evidence_structure/evidence.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def validate_timestamp(ts) -> str:
raise ValueError(f"Invalid timestamp format: {ts}. "
f"Expected format: '%Y/%m/%d %H:%M:%S.%f%z'.")



class EvidenceType(Enum):
"""
These are the types of evidence slips can detect
Expand Down Expand Up @@ -195,10 +193,12 @@ class IDEACategory(Enum):

@dataclass
class ProfileID:
ip: str = field(metadata={
'validate': lambda x: ipaddress.ip_address(x)
}
)
ip: str

def __setattr__(self, name, value):
if name == 'ip':
assert ipaddress.ip_address(value)
self.__dict__[name] = value

def __repr__(self):
return f"profile_{self.ip}"
Expand Down

0 comments on commit 4455b4f

Please sign in to comment.