def mappings_to_df(mappings_bundle, stixid_to_object):
    """Return a pandas dataframe listing the mappings in mappings_bundle"""
    rows = []
    for mapping in mappings_bundle:
        control = stixid_to_object.get(mapping["source_ref"])
        if not control:
            print(Fore.RED + f"ERROR: cannot find object with ID {mapping.source_ref} in controls bundle" + Fore.RESET)
            exit()

        technique = stixid_to_object.get(mapping["target_ref"])
        if not technique:
            print(Fore.RED + f"ERROR: cannot find object with ID {mapping.target_ref} in ATT&CK bundle" + Fore.RESET)
            exit()

        rows.append({
            "Control ID": control["external_references"][0]["external_id"],
            "Control Name": control["name"],
            "Mapping Type": mapping["relationship_type"],
            "Technique ID": technique["external_references"][0]["external_id"],
            "Technique Name": technique["name"],
        })

    data_frame = pandas.DataFrame(rows)
    data_frame.sort_values(['Control ID', 'Technique ID'], ascending=[True, True], inplace=True)

    return data_frame
Return a pandas dataframe listing the mappings in mappings_bundle
src/list_mappings.py