new security tasks

This commit is contained in:
2025-10-12 16:52:25 -07:00
parent d2c9c31105
commit 7049c2288c
11 changed files with 227 additions and 47 deletions

View File

@ -0,0 +1,31 @@
import yaml
import argparse
from ipaddress import IPv4Network, IPv4Address
def load_subnet_list(file_path):
with open(file_path, 'r') as file:
data = yaml.safe_load(file)
return [str(net) for net in data['subnet_list']]
def check_ip_in_subnets(ip, subnet_list):
ip_address = IPv4Address(ip)
for subnet in subnet_list:
if ip_address in IPv4Network(subnet):
return True
return False
def main():
parser = argparse.ArgumentParser(description="Check if an IP address is within a list of subnets.")
parser.add_argument("ip", type=str, help="The IP address to check")
args = parser.parse_args()
subnet_list = load_subnet_list('subnets.yaml')
result = check_ip_in_subnets(args.ip, subnet_list)
if result:
print("True")
else:
print("False")
if __name__ == "__main__":
main()

View File

@ -0,0 +1,2 @@
pyyaml
ipaddress

View File

@ -0,0 +1,7 @@
---
subnet_list:
- "172.20.0.0/16"
- "172.25.1.0/24"
...