certtools / intelmq-manager

IntelMQ Manager is a graphical interface to manage configurations for IntelMQ framework.
https://docs.intelmq.org/latest/user/manager/
102 stars 56 forks source link

Saving new bots: "Uncaught TypeError: old_bot is undefined" #279

Closed ghost closed 3 years ago

ghost commented 3 years ago

Sometimes, but interestingly not always, we get the exception

Uncaught TypeError: old_bot is undefined

in the console and can't add new bots. I'm not sure yet, why it happens on some systems, but not on others. I was just able to reproduce it with gbc1991a (maintenance) and with gbb0d6a9 (develop)

ghost commented 3 years ago

https://github.com/certtools/intelmq-manager/blob/bb0d6a9739ef0db55fbb543dd675c2994d3d933c/intelmq_manager/static/js/configs.js#L560-L561

Proposed workaround by @waldbauer-certat :

    let old_bot = app.nodes[old_id];
    if(old_bot != undefined) {
        node.parameters.destination_queues = old_bot.parameters.destination_queues;
    }
monoidic commented 3 years ago

Ah, yeah, whoops. I moved those two lines out of a block below where old_bot is already confirmed to exist.

ghost commented 3 years ago

After applying the above patch, there are more errors happening after renaming bots.

positions in file are ignored: TypeError: app.positions[node.bot_id] is undefined
    convert_nodes http://localhost/intelmq-manager/js/configs.js:303
    saveData http://localhost/intelmq-manager/js/configs.js:580
    jQuery 6
    <anonymous> http://localhost/intelmq-manager/js/configs.js:492
    jQuery 2

Object { parameters: {…}, defaults: {}, bot_id: "ecs-expert", name: "ECS", group: "Expert", module: "intelmq.bots.experts.ecs.expert", description: "Write some fields to the output field in ECS format", enabled: true, run_mode: "continuous" }
configs.js:307:25
Uncaught TypeError: can't convert undefined to object
    saveData http://localhost/intelmq-manager/js/configs.js:600
    jQuery 6
    <anonymous> http://localhost/intelmq-manager/js/configs.js:492
    jQuery 2
configs.js:600:47

Uncaught TypeError: right-hand side of 'in' should be an object, got undefined
    add_edge http://localhost/intelmq-manager/js/network-configuration.js:281
    addEdge http://localhost/intelmq-manager/js/network-configuration.js:159
    _performAddEdge http://localhost/intelmq-manager/plugins/vis.js/vis.js:51976
    _finishConnect http://localhost/intelmq-manager/plugins/vis.js/vis.js:51915
    _bindHammer http://localhost/intelmq-manager/plugins/vis.js/vis.js:48239
    inputHandler http://localhost/intelmq-manager/plugins/vis.js/vis.js:18566
    propagatedHandler http://localhost/intelmq-manager/plugins/vis.js/vis.js:14100
    emit http://localhost/intelmq-manager/plugins/vis.js/vis.js:16635
    inputHandler http://localhost/intelmq-manager/plugins/vis.js/vis.js:14631
    PEhandler http://localhost/intelmq-manager/plugins/vis.js/vis.js:15025
    domHandler http://localhost/intelmq-manager/plugins/vis.js/vis.js:14546
    addEventListeners http://localhost/intelmq-manager/plugins/vis.js/vis.js:14338
    each http://localhost/intelmq-manager/plugins/vis.js/vis.js:14176
    addEventListeners http://localhost/intelmq-manager/plugins/vis.js/vis.js:14337
    init http://localhost/intelmq-manager/plugins/vis.js/vis.js:14567
    Input http://localhost/intelmq-manager/plugins/vis.js/vis.js:14550
    PointerEventInput http://localhost/intelmq-manager/plugins/vis.js/vis.js:14984
    createInputInstance http://localhost/intelmq-manager/plugins/vis.js/vis.js:14601
    Manager http://localhost/intelmq-manager/plugins/vis.js/vis.js:16398
    Hammer http://localhost/intelmq-manager/plugins/vis.js/vis.js:16258
    PropagatingHammer http://localhost/intelmq-manager/plugins/vis.js/vis.js:13933
    _bindHammer http://localhost/intelmq-manager/plugins/vis.js/vis.js:48192
    _create http://localhost/intelmq-manager/plugins/vis.js/vis.js:48172
    Network http://localhost/intelmq-manager/plugins/vis.js/vis.js:33312
    initNetwork http://localhost/intelmq-manager/js/configs.js:769
    draw http://localhost/intelmq-manager/js/configs.js:742
    load_configuration http://localhost/intelmq-manager/js/runtime.js:84
    load_file http://localhost/intelmq-manager/js/runtime.js:60
    jQuery 6
    authenticatedAjax http://localhost/intelmq-manager/js/static.js:502
    authenticatedGetJson http://localhost/intelmq-manager/js/static.js:489
    load_file http://localhost/intelmq-manager/js/runtime.js:57
    load_configuration http://localhost/intelmq-manager/js/runtime.js:82
    load_file http://localhost/intelmq-manager/js/runtime.js:60
    jQuery 6
    authenticatedAjax http://localhost/intelmq-manager/js/static.js:502
    authenticatedGetJson http://localhost/intelmq-manager/js/static.js:489
    load_file http://localhost/intelmq-manager/js/runtime.js:57
    load_configuration http://localhost/intelmq-manager/js/runtime.js:78
    load_bots http://localhost/intelmq-manager/js/configs.js:166
    load_file http://localhost/intelmq-manager/js/runtime.js:60
    jQuery 6
    authenticatedAjax http://localhost/intelmq-manager/js/static.js:502
    authenticatedGetJson http://localhost/intelmq-manager/js/static.js:489
    load_file http://localhost/intelmq-manager/js/runtime.js:57
    <anonymous> http://localhost/intelmq-manager/js/configs.js:948
network-configuration.js:281:17

Phew.

monoidic commented 3 years ago

Strange, I don't get any errors when adding new bots after applying the patch.

monoidic commented 3 years ago

Right, node.parameters.destination_queues should be filled in as an empty object on new bots.

node.parameters.destination_queues = old_bot ? old_bot.parameters.destination_queues : {};