ACL_test.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:pyASA 作者: xpac1985 项目源码 文件源码
def test_append_rules(self, asa):
        rules = []
        for i in range(1, 351):
            protocol = choice(["tcp", "udp"])
            if bool(getrandbits(1)):
                src = IPAddress(randint(0, 4294967295))
            else:
                src = IPNetwork(f"{IPAddress(randint(0, 4294967295))}/{randint(0, 31)}").cidr
            if bool(getrandbits(1)):
                dst = IPAddress(randint(0, 4294967295))
            else:
                dst = IPNetwork(f"{IPAddress(randint(0, 4294967295))}/{randint(0, 31)}").cidr
            dst_port = randint(1, 65535)
            src_comp = choice([comp for comp in ServiceComparator])
            dst_comp = choice([comp for comp in ServiceComparator])
            rule = RuleTCPUDP(protocol=protocol, src=src, dst=dst, src_port=i, dst_port=dst_port,
                              src_comp=src_comp, dst_comp=dst_comp)
            rules.append(rule)
        asa.acl.append_rules(settings.test_acl, rules)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号