(techniques)
parse stix techniques into appropriate data structures.

    arguments:
        techniques: list of stix-formatted technique dicts
parse stix techniques into appropriate data structures.
parse stix techniques into appropriate data structures .
def parse_techniques(techniques):
    """parse stix techniques into appropriate data structures.

    arguments:
        techniques: list of stix-formatted technique dicts
    """

    # Iterate over each technique object
    for obj in techniques:
        # Easy-access the technique's name
        tech=obj['name']
        # Go through each technique dictionary global
        # If we haven't seen this technique before, we need to initialize the array
        if tech not in tech_to_data:
            tech_to_data[tech]=[]
        if tech not in tech_to_tac:
            tech_to_tac[tech]=[]
        if tech not in tech_to_perm:
            tech_to_perm[tech]=[]
        if tech not in tech_to_plat:
            tech_to_plat[tech]=[]
        if tech not in tech_to_def:
            tech_to_def[tech]=[]
        # Store the ID number
        if 'id' in obj:
            tech_to_id[tech]=obj['id']
            id_to_tech[obj['id']]=tech
        # Store the tactics
        if 'kill_chain_phases' in obj:
            for pair in obj['kill_chain_phases']:
                if 'phase_name' in pair:
                    tac=pair['phase_name']
                    if tac not in tech_to_tac[tech]:
                        tech_to_tac[tech].append(tac)
        # Store the platforms the technique applies to
        if 'x_mitre_platforms' in obj:
            for plat in obj['x_mitre_platforms']:
                if plat not in tech_to_plat[tech]:
                    tech_to_plat[tech].append(plat)
        # Store the data sources we can monitor to detect the technique
        if 'x_mitre_data_sources' in obj:
            for src in obj['x_mitre_data_sources']:
                if src not in tech_to_data[tech]:
                    tech_to_data[tech].append(src)
        # Store the defenses the technique bypasses
        if 'x_mitre_defense_bypassed' in obj:
            for defb in obj['x_mitre_defense_bypassed']:
                if defb not in tech_to_def[tech]:
                    tech_to_def[tech].append(defb)
        # Store the permissions required to execute the technique
        if 'x_mitre_permissions_required' in obj:
            for perm in obj['x_mitre_permissions_required']:
                if perm not in tech_to_perm[tech]:
                    tech_to_perm[tech].append(perm)

    # As a note: sometimes permissions required lists user + root permissions
    # This code below makes sure only User is listed as a permission if it's a required permission
    # (rationale: if a technique requires user permission, it stands to reason you can run it as Administrator/SYSTEM/root)
    for tech in tech_to_perm:
        if 'User' in tech_to_perm[tech]:
            tech_to_perm[tech]=['User']
def parse_techniques ( techniques ) : # Iterate over each technique object for obj in techniques : # Easy-access the technique's name tech = obj [ 'name' ] # Go through each technique dictionary global # If we haven't seen this technique before, we need to initialize the array if tech not in tech_to_data : tech_to_data [ tech ] = [ ] if tech not in tech_to_tac : tech_to_tac [ tech ] = [ ] if tech not in tech_to_perm : tech_to_perm [ tech ] = [ ] if tech not in tech_to_plat : tech_to_plat [ tech ] = [ ] if tech not in tech_to_def : tech_to_def [ tech ] = [ ] # Store the ID number if 'id' in obj : tech_to_id [ tech ] = obj [ 'id' ] id_to_tech [ obj [ 'id' ] ] = tech # Store the tactics if 'kill_chain_phases' in obj : for pair in obj [ 'kill_chain_phases' ] : if 'phase_name' in pair : tac = pair [ 'phase_name' ] if tac not in tech_to_tac [ tech ] : tech_to_tac [ tech ] . append ( tac ) # Store the platforms the technique applies to if 'x_mitre_platforms' in obj : for plat in obj [ 'x_mitre_platforms' ] : if plat not in tech_to_plat [ tech ] : tech_to_plat [ tech ] . append ( plat ) # Store the data sources we can monitor to detect the technique if 'x_mitre_data_sources' in obj : for src in obj [ 'x_mitre_data_sources' ] : if src not in tech_to_data [ tech ] : tech_to_data [ tech ] . append ( src ) # Store the defenses the technique bypasses if 'x_mitre_defense_bypassed' in obj : for defb in obj [ 'x_mitre_defense_bypassed' ] : if defb not in tech_to_def [ tech ] : tech_to_def [ tech ] . append ( defb ) # Store the permissions required to execute the technique if 'x_mitre_permissions_required' in obj : for perm in obj [ 'x_mitre_permissions_required' ] : if perm not in tech_to_perm [ tech ] : tech_to_perm [ tech ] . append ( perm ) # As a note: sometimes permissions required lists user + root permissions # This code below makes sure only User is listed as a permission if it's a required permission # (rationale: if a technique requires user permission, it stands to reason you can run it as Administrator/SYSTEM/root) for tech in tech_to_perm : if 'User' in tech_to_perm [ tech ] : tech_to_perm [ tech ] = [ 'User' ]