def construct_security_hub_finding()

in lambdas/send_findings_to_security_hub/app.py [0:0]


def construct_security_hub_finding(scope_id, scope_analysis_id, findings_count, account_id, region_id):
    
    # Initialize date time 
    d = datetime.datetime.utcnow()

    security_hub_finding_item = {
        "SchemaVersion": "2018-10-08",
        "Title": f"Match Found for Scope Id {scope_id}",
        "Description": "You current network configuration does not align with your compliance rules defined in Network Access Analyzer",
        "ProductArn": f"arn:aws:securityhub:{region_id}:{account_id}:product/{account_id}/default",
        "AwsAccountId": account_id,
        "Id": f"scope-analysis-id/{scope_id}", 
        "GeneratorId": "CUSTOM:AutomatedScopeCheckerTool",
        "CreatedAt": d.isoformat("T") + "Z",
        "UpdatedAt": d.isoformat("T") + "Z",
        "FindingProviderFields": {
            "Severity": {
                "Label": "MEDIUM",
            },
            "Types": [
                "Software and Configuration Checks/Vulnerabilities/CVE"
            ]
        },
        "ProductFields":{
            "vpcaa-autorun/networkaccessanalyzer/NetworkScopeAnalysisId": f"{scope_analysis_id}",
            "vpcaa-autorun/networkaccessanalyzer/NetworkScopeAnalysisFindingsCount": f"{findings_count}"
        },
        "Resources": [{
            "Type": "NetworkAccessAnalyzerNetworkAccessScopeId",    
            "Id": f"arn:aws:ec2:{region_id}:{account_id}:network-insights-access-scope-analysis/{scope_id}"
        }]
    }
    return security_hub_finding_item