Refactor imports in firewall.py and scan.py to use ip_utils; remove utils module
This commit is contained in:
1 parent
40212d84f7
commit
540154d426
3 files changed
+7
-622
No files matched your search
@@ -15,6 +15,8 @@ import utils
|
||||
from firewall import MikrotikFirewall
|
||||
from copyparty import CopypartyAnalyzer, DEFAULT_LOG_PATH as CP_DEFAULT_LOG, DEFAULT_REPORT_DIR as CP_DEFAULT_REPORT
|
||||
from npm import NpmAnalyzer, DEFAULT_LOG_PATH as NPM_DEFAULT_LOG, DEFAULT_REPORT_DIR as NPM_DEFAULT_REPORT
|
||||
from ip_utils import is_whitelisted, split_versions
|
||||
from whois import consolidate_by_subnet
|
||||
|
||||
DEFAULT_CONSOLIDATED_REPORT_DIR = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "reports")
|
||||
@@ -111,13 +113,13 @@ def main() -> None:
|
||||
|
||||
# Exclude whitelisted IPs
|
||||
final_blocked_ips = {
|
||||
ip for ip in consolidated_candidates if not utils.is_whitelisted(ip)}
|
||||
ip for ip in consolidated_candidates if not is_whitelisted(ip)}
|
||||
|
||||
# Group into subnets via WHOIS if multiple malicious IPs in same subnet (threshold = 3)
|
||||
print("\nGrouping blocked IPs into subnets using WHOIS...")
|
||||
final_blocked_targets = utils.consolidate_by_subnet(
|
||||
final_blocked_targets = consolidate_by_subnet(
|
||||
final_blocked_ips, threshold=3)
|
||||
blocked_ipv4, blocked_ipv6 = utils.split_versions(final_blocked_targets)
|
||||
blocked_ipv4, blocked_ipv6 = split_versions(final_blocked_targets)
|
||||
|
||||
print("\n=== Consolidated Summary ===")
|
||||
print(
|
||||
@@ -142,5 +144,6 @@ def main() -> None:
|
||||
f"remove {len(changes['removed_ipv4'])} IPv4 and "
|
||||
f"{len(changes['removed_ipv6'])} IPv6 addresses.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user