#2676: Code review changes

This commit is contained in:
Nick Todd
2024-07-17 17:50:55 +01:00
parent 061509dffd
commit 4361734014
3 changed files with 8 additions and 12 deletions

View File

@@ -19,7 +19,7 @@ from primaite.simulator.core import RequestFormat, RequestManager, RequestPermis
from primaite.simulator.domain.account import Account
from primaite.simulator.file_system.file_system import FileSystem
from primaite.simulator.network.hardware.node_operating_state import NodeOperatingState
from primaite.simulator.network.nmne import NmneData
from primaite.simulator.network.nmne import NMNEConfig
from primaite.simulator.network.transmission.data_link_layer import Frame
from primaite.simulator.network.transmission.network_layer import IPProtocol
from primaite.simulator.system.applications.application import Application
@@ -99,7 +99,7 @@ class NetworkInterface(SimComponent, ABC):
pcap: Optional[PacketCapture] = None
"A PacketCapture instance for capturing and analysing packets passing through this interface."
nmne_config: ClassVar[NmneData] = None
nmne_config: ClassVar[NMNEConfig] = None
"A dataclass defining malicious network events to be captured."
nmne: Dict = Field(default_factory=lambda: {})

View File

@@ -1,15 +1,14 @@
# © Crown-owned copyright 2024, Defence Science and Technology Laboratory UK
from dataclasses import dataclass, field
from pydantic import BaseModel
from typing import Dict, List
@dataclass
class NmneData:
class NMNEConfig(BaseModel):
"""Store all the information to perform NMNE operations."""
capture_nmne: bool = True
"""Indicates whether Malicious Network Events (MNEs) should be captured."""
nmne_capture_keywords: List[str] = field(default_factory=list)
nmne_capture_keywords: List[str] = []
"""List of keywords to identify malicious network events."""
capture_by_direction: bool = True
"""Captures should be organized by traffic direction (inbound/outbound)."""
@@ -23,7 +22,7 @@ class NmneData:
"""Captures should be filtered and categorised based on specific keywords."""
def store_nmne_config(nmne_config: Dict) -> NmneData:
def store_nmne_config(nmne_config: Dict) -> NMNEConfig:
"""
Store configuration for capturing Malicious Network Events (MNEs).
@@ -51,4 +50,4 @@ def store_nmne_config(nmne_config: Dict) -> NmneData:
if not isinstance(nmne_capture_keywords, list):
nmne_capture_keywords = [] # Reset to empty list if the provided value is not a list
return NmneData(capture_nmne=capture_nmne, nmne_capture_keywords=nmne_capture_keywords)
return NMNEConfig(capture_nmne=capture_nmne, nmne_capture_keywords=nmne_capture_keywords)