Sunday, June 4, 2017

Parsing firewall rules in Python

parts = rule.split(" ")
aclName, _, lineNumber, _, action, protocol = parts[:6]
endpoints = parts[6:]

def get_endpoint(eps):
    host, port = "*", "*"
    if eps[0] == "host":
        host = eps[1]
        eps = eps[2:]
    elif eps[0] == "any":
        eps = eps[1:]
    else:
        host = eps[0] + "/" + mask_to_bits(eps[1])
        eps = eps[2:]

    if eps and eps[0] == 'eq':
        port = eps[1]
        eps = eps[2:]
    return host, port, eps

sourceIP, sourcePort, endpoints = get_endpoint(endpoints)
destIP, destPort, endpoints = get_endpoint(endpoints)
https://stackoverflow.com/questions/10196998/parsing-firewall-rules-in-python

No comments:

TAP airlines Privatization ( 23 billion risk) Portugal Intel AI exposure and energy oil carburants suplly needs)

  https://www.noisecancelling.co/read/oil-finds-a-way-nvidia-keeps-the-story-alive https://ioplus.nl/en/posts/klm-suffers-cyber-breach-affec...