firewalls.py 文件源码

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

项目:G-Scout 作者: nccgroup 项目源码 文件源码
def add_affected_instances(projectId, db):
    for firewall in db.table('Firewall').all():
        try:
            for instance in db.table('Network').get(Query().selfLink==firewall['network'])['members']:
                try:
                    if not firewall.get('targetTags'):
                        db.table('Firewall').update(
                        add_instance({
                        "kind":instance['kind'],
                        "selfLink":instance['selfLink'],
                        "tags":instance.get('tags'),
                        "name":instance['name']
                        }),eids=[firewall.eid])
                    try:
                        for tag in instance.get('tags'):
                            if tag in firewall.get('targetTags'):
                                db.table('Firewall').update(
                            add_instance({
                            "kind":instance['kind'],
                            "selfLink":instance['selfLink'],
                            "tags":instance.get('tags'),
                            "name":instance['name']
                            }),eids=[firewall.eid])
                    except TypeError:
                        continue
                except KeyError:
                    continue
        except KeyError:
            continue

# Function to pass Tinydb for the update query
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号