Skip to content

Commit

Permalink
Resolved Comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
nmasdoufi-ol committed Dec 3, 2024
1 parent f1dcc09 commit a76273f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
16 changes: 5 additions & 11 deletions agent/nmap_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@

DEFAULT_MASK_IPV6 = 128
# scan up to 65536 host
IPV6_CIDR_LIMIT = 112
CIDR_LIMIT = 112
# More IPv6-specific constants
IPV6_MIN_PREFIX = 8 # Minimum safe prefix length for IPv6
IPV6_DEFAULT_PING_TIMEOUT = 1000 # ms
IPV6_MAX_BATCH_SIZE = 100 # Maximum number of IPv6 addresses to scan in one batch
# IPV6_DEFAULT_PING_TIMEOUT = 1000 # ms
MAX_BATCH_SIZE = 100 # Maximum number of IPv6 addresses to scan in one batch

BLACKLISTED_SERVICES = ["tcpwrapped"]

Expand Down Expand Up @@ -97,9 +97,6 @@ def _normalize_ipv6_address(self, address: str) -> str:
def _get_ipv6_scan_options(self) -> dict[str, Any]:
"""Get IPv6-specific scan options."""
return {
"ping_timeout": self.args.get(
"ipv6_ping_timeout", IPV6_DEFAULT_PING_TIMEOUT
),
"min_rate": self.args.get("ipv6_min_rate", 100),
"max_rate": self.args.get("ipv6_max_rate", 1000),
"max_retries": self.args.get("ipv6_max_retries", 2),
Expand Down Expand Up @@ -137,10 +134,8 @@ def process(self, message: msg.Message) -> None:
normalized_host = self._normalize_ipv6_address(host)

mask = int(message.data.get("mask", DEFAULT_MASK_IPV6))
if mask < IPV6_CIDR_LIMIT:
logger.error(
"IPv6 subnet mask below %s is not supported", IPV6_CIDR_LIMIT
)
if mask < CIDR_LIMIT:
logger.error("IPv6 subnet mask below %s is not supported", CIDR_LIMIT)
return

# Validate the mask
Expand Down Expand Up @@ -217,7 +212,6 @@ def _scan_host(self, host: str, mask: int) -> Tuple[Dict[str, Any], str]:
if is_ipv6 is True:
# Add IPv6-specific options
ipv6_options = self._get_ipv6_scan_options()
options.ping_timeout = ipv6_options["ping_timeout"]
options.min_rate = ipv6_options["min_rate"]
options.max_rate = ipv6_options["max_rate"]
options.max_retries = ipv6_options["max_retries"]
Expand Down
2 changes: 1 addition & 1 deletion tests/nmap_agent_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ def testNmapAgent_whenIpv6AboveLimit_agentShouldLogError(
nmap_test_agent.process(ipv6_msg_above_limit)

assert (
f"IPv6 subnet mask below {nmap_agent.IPV6_CIDR_LIMIT} is not supported"
f"IPv6 subnet mask below {nmap_agent.CIDR_LIMIT} is not supported"
in caplog.text
)

Expand Down

0 comments on commit a76273f

Please sign in to comment.