cerebrate-project / cerebrate

Cerebrate is an open-source platform meant to act as a trusted contact information provider and interconnection orchestrator for other security tools.
https://www.cerebrate-project.org/
GNU Affero General Public License v3.0
82 stars 16 forks source link

Edit MetaFields via API #102

Closed DocArmoryTech closed 3 months ago

DocArmoryTech commented 2 years ago

Hi,

I've been trying to work out how to edit an individual's "mobile_phone" field from the "CSIRT Network individual fields" (v2).

Is it possible to create or set a metaField using the API

DocArmoryTech commented 2 years ago

I think I've worked this out now...

I inspected the headers and payload used to set a MetaTemplate field in the browser; observing something like:

email: xxxxx@exmaple.com
uuid: d157df4b-0554-419c-868f-01dda1c8ce8a
first_name: fred
last_name: flintstone
position: 
tag_list: 
MetaTemplates[1][meta_template_fields][1][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][2][metaFields][new][0]: +353871234567
MetaTemplates[1][meta_template_fields][3][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][4][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][5][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][6][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][7][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][8][metaFields][new][0]: 
MetaTemplates[1][meta_template_fields][9][metaFields][new][0]:

I ?mistakenly? took this as a cue to update via the API using a json equivalent of the above. I was unsuccessful in this approach.

I instead found updating the top-level Individual attribute named meta_fields achieved the desired result using the API. e.g. to update the first_name, last_name and mobile_phone of individual with email: xxxxx@exmaple.com and an id of 8

{
    "id":8,
    "email":"xxxxx@exmaple.com",
    "first_name":"fred",
    "last_name":"flintstone",
    "meta_fields": [
        {
            "scope": "individual",
            "parent_id": 8,
            "field": "mobile_phone",
            "value": "+333333333333",
            "uuid": "df8c35ad-ded9-48e0-a286-da318b757868",
            "meta_template_id": 1,
            "meta_template_field_id": 2
        }
    ]
}