|
| 1 | +# SPDX-FileCopyrightText: 2022 Sebastian Wagner |
| 2 | +# SPDX-License-Identifier: AGPL-3.0-or-later |
| 3 | +# |
| 4 | +# -*- coding: utf-8 -*- |
| 5 | + |
| 6 | + |
| 7 | +def shadowserver_feednames(configuration, harmonization, dry_run, **kwargs): |
| 8 | + """ |
| 9 | + Replace deprecated Shadowserver feednames |
| 10 | + """ |
| 11 | + mapping = { |
| 12 | + "Botnet-Drone-Hadoop": "Drone", |
| 13 | + "DNS-open-resolvers": "DNS-Open-Resolvers", |
| 14 | + "Open-NetBIOS": "Open-NetBIOS-Nameservice", |
| 15 | + "Ssl-Freak-Scan": "SSL-FREAK-Vulnerable-Servers", |
| 16 | + "Ssl-Scan": "SSL-POODLE-Vulnerable-Servers", |
| 17 | + } |
| 18 | + changed = None |
| 19 | + for bot_id, bot in configuration.items(): |
| 20 | + if bot_id == 'global': |
| 21 | + continue |
| 22 | + if bot["module"] == "intelmq.bots.parsers.shadowserver.parser": |
| 23 | + if bot["parameters"]["feedname"] in mapping: |
| 24 | + changed = True |
| 25 | + bot["parameters"]["feedname"] = mapping[bot["parameters"]["feedname"]] |
| 26 | + |
| 27 | + return changed, configuration, harmonization |
| 28 | + |
| 29 | + |
| 30 | +def deprecations(configuration, harmonization, dry_run, **kwargs): |
| 31 | + """ |
| 32 | + Checking for deprecated runtime configurations (stomp collector, cymru parser, ripe expert, collector feed parameter) |
| 33 | + """ |
| 34 | + mapping = { |
| 35 | + "intelmq.bots.collectors.n6.collector_stomp": "intelmq.bots.collectors.stomp.collector", |
| 36 | + "intelmq.bots.parsers.cymru_full_bogons.parser": "intelmq.bots.parsers.cymru.parser_full_bogons", |
| 37 | + } |
| 38 | + changed = None |
| 39 | + for bot_id, bot in configuration.items(): |
| 40 | + if bot_id == 'global': |
| 41 | + continue |
| 42 | + if bot["module"] in mapping: |
| 43 | + bot["module"] = mapping[bot["module"]] |
| 44 | + changed = True |
| 45 | + if bot["module"] == "intelmq.bots.experts.ripencc_abuse_contact.expert": |
| 46 | + bot["module"] = "intelmq.bots.experts.ripe.expert" |
| 47 | + changed = True |
| 48 | + if bot["module"] == "intelmq.bots.experts.ripe.expert": |
| 49 | + if bot["parameters"].get("query_ripe_stat"): |
| 50 | + if "query_ripe_stat_asn" not in bot["parameters"]: |
| 51 | + bot["parameters"]["query_ripe_stat_asn"] = bot["parameters"]["query_ripe_stat"] |
| 52 | + if "query_ripe_stat_ip" not in bot["parameters"]: |
| 53 | + bot["parameters"]["query_ripe_stat_ip"] = bot["parameters"]["query_ripe_stat"] |
| 54 | + del bot["parameters"]["query_ripe_stat"] |
| 55 | + changed = True |
| 56 | + if bot["group"] == 'Collector' and bot["parameters"].get("feed") and not bot["parameters"].get("name"): |
| 57 | + try: |
| 58 | + bot["parameters"]["name"] = bot["parameters"]["feed"] |
| 59 | + del bot["parameters"]["feed"] |
| 60 | + except KeyError: |
| 61 | + pass |
| 62 | + else: |
| 63 | + changed = True |
| 64 | + |
| 65 | + return changed, configuration, harmonization |
0 commit comments