Esempio n. 1
0
def delete_tag():

    object_type = request.args.get('object_type')
    object_id = request.args.get('object_id')
    tag = request.args.get('tag')

    res = Tag.api_delete_obj_tags(tags=[tag],
                                  object_id=object_id,
                                  object_type=object_type)
    if res[1] != 200:
        return str(res[0])
    return redirect(Correlate_object.get_item_url(object_type, object_id))
Esempio n. 2
0
def add_tags():

    tags = request.args.get('tags')
    tagsgalaxies = request.args.get('tagsgalaxies')
    object_id = request.args.get('object_id')
    object_type = request.args.get('object_type')

    list_tag = tags.split(',')
    list_tag_galaxies = tagsgalaxies.split(',')

    res = Tag.api_add_obj_tags(tags=list_tag,
                               galaxy_tags=list_tag_galaxies,
                               object_id=object_id,
                               object_type=object_type)
    # error
    if res[1] != 200:
        return str(res[0])

    return redirect(Correlate_object.get_item_url(object_type, object_id))
Esempio n. 3
0
def import_object_file():
    error = None

    is_file = False
    if 'file' in request.files:
        file = request.files['file']
        if file:
            if file.filename:
                is_file = True

    all_imported_obj = []
    if is_file:
        filename = MispImport.sanitize_import_file_path(file.filename)
        file.save(filename)
        map_uuid_global_id = MispImport.import_objs_from_file(filename)
        os.remove(filename)
        for obj_uuid in map_uuid_global_id:
            dict_obj = Correlate_object.get_global_id_from_id(
                map_uuid_global_id[obj_uuid])
            dict_obj['uuid'] = obj_uuid
            dict_obj['url'] = Correlate_object.get_item_url(
                dict_obj['type'],
                dict_obj['id'],
                correlation_type=dict_obj['subtype'])
            dict_obj['node'] = Correlate_object.get_correlation_node_icon(
                dict_obj['type'],
                correlation_type=dict_obj['subtype'],
                value=dict_obj['id'])
            all_imported_obj.append(dict_obj)

        if not all_imported_obj:
            error = "error: Empty or invalid JSON file"

    return render_template("import_object.html",
                           all_imported_obj=all_imported_obj,
                           error=error)