gcp_audit.py 文件源码

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

项目:gcp-audit 作者: spotify 项目源码 文件源码
def apply_rules(ruletype, gcpobjects, descfield, outfile, project):
    rules = loadrules(ruletype)
    for obj in gcpobjects:
        for rule in rules:
            if 'filtercondition' in rule:
                res = apply_rule_filters(obj, rule['filters'],
                                         rule['filtercondition'])
            else:
                res = apply_rule_filters(obj, rule['filters'])

            if res:
                print colored('MATCH:', 'red'), \
                    "object '%s' matches rule '%s'" \
                    % (obj[descfield], rule['name'])

                with open(outfile, 'a') as f:
                    f.write(datetime.datetime.now().ctime()
                            + ": Project: " + project
                            + " | Object: " + obj[descfield]
                            + " | Matches rule: " + rule['name']
                            + "\n" + json.dumps(obj) + "\n\n")
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号