Skip to content

Conversation

@m-dilorenzi
Copy link
Collaborator

This pull request enhances the network scanning functionality by adding subnet size validation and improving interface information. The most important changes are:

Network scanning improvements:

  • Updated the scan function to take both device and interface parameters, and added logic to block ARP scans on subnets smaller than /20, returning a validation error if the subnet is too large.
  • Added the netmask_to_cidr_notation helper function to convert a netmask (e.g., 255.255.0.0) into CIDR notation (e.g., 16), using the ipaddress module.

Interface listing enhancements:

  • Modified the list_interfaces function to include the netmask in CIDR notation for each interface in its output.

Command-line interface updates:

  • Updated the command-line argument handling to require and pass the interface parameter for scans, ensuring the new validation logic is used.

Refs: #1434

@m-dilorenzi m-dilorenzi requested a review from Tbaile January 28, 2026 11:57
@m-dilorenzi m-dilorenzi self-assigned this Jan 28, 2026
Comment on lines 48 to 59
def scan(device, interface):
ret = []
u = EUci()

if interface:
netmask = u.get('network', interface, 'netmask')
netmask_cidr = netmask_to_cidr_notation(netmask)

# block arp-scan if the subnet is /19 or smaller
if netmask_cidr is not None and netmask_cidr < 20:
return utils.validation_error("subnet_too_large_for_scan")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tbaile Tbaile linked an issue Jan 29, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

network scan fails when using very large subnets

3 participants