Esempio n. 1
0
def test_add_tag(input_data, expected_count):
    test_object = Firmware()
    for item in input_data:
        test_object.set_tag(item)
    for item in input_data:
        assert item in test_object.tags
    assert len(test_object.tags.keys()) == expected_count
Esempio n. 2
0
def convert_analysis_task_to_fw_obj(analysis_task):
    fw = Firmware(
        scheduled_analysis=analysis_task['requested_analysis_systems'])
    if 'binary' in analysis_task.keys():
        fw.set_binary(analysis_task['binary'])
        fw.file_name = analysis_task['file_name']
    else:
        if 'file_name' in analysis_task.keys():
            fw.file_name = analysis_task['file_name']
        fw.overwrite_uid(analysis_task['uid'])
    fw.set_device_name(analysis_task['device_name'])
    fw.set_firmware_version(analysis_task['firmware_version'])
    fw.set_device_class(analysis_task['device_class'])
    fw.set_vendor(analysis_task['vendor'])
    fw.set_release_date(analysis_task['release_date'])
    for tag in _get_tag_list(analysis_task['tags']):
        fw.set_tag(tag)
    return fw
Esempio n. 3
0
def convert_analysis_task_to_fw_obj(analysis_task: dict) -> Firmware:
    '''
    Convert an analysis task to a firmware object.

    :param analysis_task: The analysis task data.
    :return: A new `Firmware` object based on the analysis task data.
    '''
    fw = Firmware(scheduled_analysis=analysis_task['requested_analysis_systems'])
    if 'binary' in analysis_task.keys():
        fw.set_binary(analysis_task['binary'])
        fw.file_name = analysis_task['file_name']
    else:
        if 'file_name' in analysis_task.keys():
            fw.file_name = analysis_task['file_name']
        fw.uid = analysis_task['uid']
    fw.set_device_name(analysis_task['device_name'])
    fw.set_part_name(analysis_task['device_part'])
    fw.set_firmware_version(analysis_task['version'])
    fw.set_device_class(analysis_task['device_class'])
    fw.set_vendor(analysis_task['vendor'])
    fw.set_release_date(analysis_task['release_date'])
    for tag in _get_tag_list(analysis_task['tags']):
        fw.set_tag(tag)
    return fw