MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / run_nmap_ping_scan

Function run_nmap_ping_scan

webapp_modern.py:8613–8637  ·  view source on GitHub ↗

Run nmap ping scan to discover active hosts

(network=None)

Source from the content-addressed store, hash-verified

8611 if raw_ip.lower() in ('unknown', ''):
8612 raw_ip = ''
8613
8614 # Validate whatever was supplied; require at least one usable field.
8615 if raw_mac and not _MAC_RE.match(raw_mac):
8616 return jsonify({'error': f'Invalid MAC: {raw_mac}'}), 400
8617 if raw_ip:
8618 try:
8619 raw_ip = str(_ip.ip_address(raw_ip))
8620 except ValueError:
8621 return jsonify({'error': f'Invalid IP: {raw_ip}'}), 400
8622 if not raw_mac and not raw_ip:
8623 return jsonify({'error': 'Provide a mac and/or ip to ignore'}), 400
8624
8625 changed = False
8626 if request.method == 'POST':
8627 if raw_mac and raw_mac not in macs:
8628 macs.append(raw_mac)
8629 changed = True
8630 if raw_ip and raw_ip not in ips:
8631 ips.append(raw_ip)
8632 changed = True
8633 else: # DELETE
8634 if raw_mac and raw_mac in macs:
8635 macs = [m for m in macs if m != raw_mac]
8636 changed = True
8637 if raw_ip and raw_ip in ips:
8638 ips = [i for i in ips if i != raw_ip]
8639 changed = True
8640

Callers 2

get_nmap_ping_scanFunction · 0.85

Calls 6

_detect_local_cidrFunction · 0.85
_parse_nmap_ping_outputFunction · 0.85
errorMethod · 0.80
infoMethod · 0.80
warningMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected