最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - How to get millions of security hub findings using boto3 - Stack Overflow

programmeradmin0浏览0评论

we have 7 million of security hub findings and I'm trying to fetch these by using boto3 securityhub get_findings() method but as the number of findings is huge it is taking lot of time.

import boto3

securityhub_client=boto3.client('securityhub')

def get_all_findings(securityhub_client):
    nexttoken=""
    inspector_findings=[]
    while True:
        try:
            if nexttoken:
                findings=securityhub_client.get_findings(
                    NextToken=nexttoken,
                    maxResults=100,
                    Filters={
                        'ProductName':[
                            {
                                'value':'Inspector',
                                'Comparison':'EQUALS'
                            },
                        ],
                    }
                    
                )
                inspector_findings.extend(findings['Findings'])
                nexttoken=findings.get('NextToken')
                if not nexttoken:
                    break
        except Exception as e:
            print('Some issue occurred',e)
            break
        return inspector_findings

all_findings=get_all_findings(securityhub_client)
print("all findings",all_findings)

here the code is executing successfully but it's taking a lot of time. what is the best way to get all the 7m findings?

I can't use any other filters other than ProductName as Inspector as I need all the securityhub findings of the inspector.

发布评论

评论列表(0)

  1. 暂无评论