()
return {
        "name": "heatmap example",
        "versions": {
            "layer": "4.1",
            "navigator": "4.1"
        },
        "sorting": 3, # descending order of score
        "description": "An example layer where all techniques have a randomized score",
        "domain": "enterprise-attack",
        "techniques": techniques_list,
    }
parse the STIX on MITRE/CTI and return a layer dict with techniques with randomized scores
parse the STIX on MITRE/CTI and return a layer dict with techniques with randomized scores
parse the STIX on MITRE / CTI and return a layer dict with techniques with randomized scores
def generate():
    """parse the STIX on MITRE/CTI and return a layer dict with techniques with randomized scores"""
    # import the STIX data from MITRE/CTI
    stix = requests.get("https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json").json()
    ms = MemoryStore(stix_data=stix["objects"])
    # get all techniques in STIX
    techniques = ms.query([
        Filter("type", "=", "attack-pattern")
    ])
    # parse techniques into layer format
    techniques_list = []
    for technique in techniques:
        # skip deprecated and revoked
        if ("x_mitre_deprecated" in technique and technique["x_mitre_deprecated"]) or ("revoked" in technique and technique["revoked"]): continue
        techniqueID = technique["external_references"][0]["external_id"] # get the attackID
        techniques_list.append({
            "techniqueID": techniqueID,
            "score": random.randint(1,100) # random score
        })
    # return the techniques in a layer dict
    return {
        "name": "heatmap example",
        "versions": {
            "layer": "4.1",
            "navigator": "4.1"
        },
        "sorting": 3, # descending order of score
        "description": "An example layer where all techniques have a randomized score",
        "domain": "enterprise-attack",
        "techniques": techniques_list,
    }
def generate ( ) : # import the STIX data from MITRE/CTI stix = requests . get ( "https://raw.githubusercontent.com/mitre/cti/master/enterprise-attack/enterprise-attack.json" ) . json ( ) ms = MemoryStore ( stix_data = stix [ "objects" ] ) # get all techniques in STIX techniques = ms . query ( [ Filter ( "type" , "=" , "attack-pattern" ) ] ) # parse techniques into layer format techniques_list = [ ] for technique in techniques : # skip deprecated and revoked if ( "x_mitre_deprecated" in technique and technique [ "x_mitre_deprecated" ] ) or ( "revoked" in technique and technique [ "revoked" ] ) : continue techniqueID = technique [ "external_references" ] [ 0 ] [ "external_id" ] # get the attackID techniques_list . append ( { "techniqueID" : techniqueID , "score" : random . randint ( 1 , 100 ) # random score } ) # return the techniques in a layer dict return { "name" : "heatmap example" , "versions" : { "layer" : "4.1" , "navigator" : "4.1" } , "sorting" : 3 , # descending order of score "description" : "An example layer where all techniques have a randomized score" , "domain" : "enterprise-attack" , "techniques" : techniques_list , }