Example #1
0
def features(act, target=[], args={}, *extra_args, **extra_kwargs):
    if not isinstance(args, dict) and len(set(args) - {"response"}) > 0:
        print("Invalid Query Args")
        return exceptions.bad_argument()

    if not isinstance(target,
                      list) and len(set(target) - set(Features.keys())) > 0:
        return exceptions.bad_request()

    else:
        rtn = dict(status=200, results={k: Features[k](act) for k in target})

        return {k: v for k, v in rtn.items() if v}
Example #2
0
def ipv6_addr(act, target="", args={}, *extra_args, **extra_kwargs):
    if not isinstance(args, dict) and len(set(args) - ValidArgs) > 0:
        print("Invalid Deny Args")
        return exceptions.bad_argument()

    ip = valid_ip(target)
    if ip:
        direction = args.get("direction", None)  # Apply to both INPUT and OUTPUT if None
        print(f"Deny ipv6_addr: {ip} - {direction}")
        return exceptions.action_exception('deny', except_msg='target implementation TBD')

    print("Invalid Deny/IPv6_Addr target")
    return exceptions.bad_request(except_msg="Validation Error: Target: ipv6_addr")