Skip to content

Commit

Permalink
DEP: lib/bot: replace parameter feed by name for collectors
Browse files Browse the repository at this point in the history
fixes #1144
  • Loading branch information
Sebastian Wagner committed May 24, 2018
1 parent 4d369be commit 61f14e3
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ CHANGELOG
- lib/pipeline:
* you may now define more than one destination queues path the bot should pass the message to, see [Pipelines](https://github.com/certtools/intelmq/blob/develop/docs/User-Guide.md#pipeline-configuration) (#1088, #1190).
* the special path `"_on_error"` can be used to pass messages to differnt queues in case of processing errors (#1133).
- lib/bot.py: The parameter `feed` for collectors is deprecated for 2.0 and has been replaced by the more consistent `name` (#1144).

### Bots
#### Collectors
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ which is by default set to `false` to be consistent with other bots.

The bot `bots.collectors.n6.collector_stomp` has been renamed to the new module `bots.collectors.stomp.collector`. Adapt your `runtime.conf` accordingly.

The parameter `feed` for collectors has been renamed to `name`, as it results in `feed.name`. Backwards compatibility is ensured until 2.0.

### Postgres databases
The following statements optionally update existing data.
Please check if you did use these feed names and eventually adapt them for your setup!
Expand Down
8 changes: 4 additions & 4 deletions intelmq/etc/runtime.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
"module": "intelmq.bots.collectors.http.collector_http",
"name": "Abuse.ch Feodo Domains",
"parameters": {
"feed": "Abuse.ch Feodo Domains",
"http_password": null,
"http_url": "https://feodotracker.abuse.ch/blocklist/?download=domainblocklist",
"http_username": null,
"name": "Abuse.ch Feodo Domains",
"provider": "Abuse.ch",
"rate_limit": 129600,
"ssl_client_certificate": null
Expand Down Expand Up @@ -86,10 +86,10 @@
"module": "intelmq.bots.collectors.http.collector_http",
"name": "Malc0de Windows Format",
"parameters": {
"feed": "Generic URL Fetcher is the bot responsible to get the report from an URL.",
"http_password": null,
"http_url": "https://malc0de.com/bl/BOOT",
"http_username": null,
"name": "Generic URL Fetcher is the bot responsible to get the report from an URL.",
"provider": "Malc0de",
"rate_limit": 10800,
"ssl_client_certificate": null
Expand All @@ -101,8 +101,8 @@
"module": "intelmq.bots.collectors.http.collector_http",
"name": "Malware Domain List",
"parameters": {
"feed": "Malware Domain List",
"http_url": "http://www.malwaredomainlist.com/updatescsv.php",
"name": "Malware Domain List",
"provider": "Malware Domain List",
"rate_limit": 3600
}
Expand All @@ -120,10 +120,10 @@
"module": "intelmq.bots.collectors.http.collector_http",
"name": "Spamhaus Drop",
"parameters": {
"feed": "Spamhaus Drop",
"http_password": null,
"http_url": "https://www.spamhaus.org/drop/drop.txt",
"http_username": null,
"name": "Spamhaus Drop",
"provider": "Spamhaus",
"rate_limit": 3600,
"ssl_client_certificate": null
Expand Down
9 changes: 8 additions & 1 deletion intelmq/lib/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import time
import traceback
import types
import warnings

from intelmq import (DEFAULT_LOGGING_PATH, DEFAULTS_CONF_FILE,
HARMONIZATION_CONF_FILE, PIPELINE_CONF_FILE,
Expand Down Expand Up @@ -773,7 +774,13 @@ def __filter_empty_report(self, message: dict):
return True

def __add_report_fields(self, report: dict):
report.add("feed.name", self.parameters.feed)
if hasattr(self.parameters, 'feed'):
report.add("feed.name", self.parameters.feed)
warnings.warn("The parameter 'feed' is deprecated and will be "
"removed in version 2.0. Use 'name' instead.",
DeprecationWarning)
else:
report.add("feed.name", self.parameters.name)
if hasattr(self.parameters, 'code'):
report.add("feed.code", self.parameters.code)
if hasattr(self.parameters, 'documentation'):
Expand Down
4 changes: 2 additions & 2 deletions intelmq/tests/bots/collectors/http/test_collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def set_bot(cls):
cls.bot_reference = HTTPCollectorBot
cls.sysconfig = {'http_url': 'http://localhost/two_files.tar.gz',
'extract_files': True,
'feed': 'Example feed',
'name': 'Example feed',
}

def test_events(self):
Expand All @@ -53,7 +53,7 @@ def test_formatting(self):
self.allowed_warning_count = 1 # message has empty raw
self.sysconfig = {'http_url': 'http://localhost/{time[%Y]}.txt',
'extract_files': None,
'feed': 'Example feed',
'name': 'Example feed',
'http_url_formatting': True,
}
self.run_bot(iterations=1)
Expand Down
2 changes: 1 addition & 1 deletion intelmq/tests/lib/test_collector_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class TestDummyCollectorBot(test.BotTestCase, unittest.TestCase):
def set_bot(cls):
cls.bot_reference = DummyCollectorBot
cls.default_input_message = None
cls.sysconfig = {'feed': 'Example Feed',
cls.sysconfig = {'name': 'Example Feed',
'code': 'Example Code',
'provider': 'Example Provider',
'documentation': 'Example Documentation',
Expand Down

0 comments on commit 61f14e3

Please sign in to comment.