Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MISP parser: added functionality to honor/filter the "to_ids" attribute of MISP #1649

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/user/bots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1341,6 +1341,10 @@ for processing. Supported MISP event categories and attribute types are
defined in the `SUPPORTED_MISP_CATEGORIES` and `MISP_TYPE_MAPPING` class
constants.

**Configuration Parameters**

* `only_ids`: If set to true, MISP events will be discardrd if their to_ids attribute is set to false

n6
^^

Expand Down
4 changes: 3 additions & 1 deletion intelmq/bots/BOTS
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@
"MISP": {
"description": "Parse MISP events.",
"module": "intelmq.bots.parsers.misp.parser",
"parameters": {}
"parameters": {
"ids_only": false
}
},
"Malc0de": {
"description": "Parse the Malc0de IP feed in either IP Blacklist, Windows Format or Bind format.",
Expand Down
14 changes: 13 additions & 1 deletion intelmq/bots/parsers/misp/parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# -*- coding: utf-8 -*-

"""
MISP parser

Parameters:
ids_only: boolean
"""

import json
from datetime import datetime
from urllib.parse import urljoin
Expand Down Expand Up @@ -95,17 +103,21 @@ def process(self):
timestamp = attribute['timestamp']
category = attribute['category']
type_ = attribute['type']
to_ids = attribute['to_ids']
ids_only = self.parameters.ids_only

# create intelmq events based on the category
if (category in self.SUPPORTED_MISP_CATEGORIES and
type_ in self.MISP_TYPE_MAPPING):
type_ in self.MISP_TYPE_MAPPING and
(not ids_only or to_ids)):

# Create and send the intelmq event
event = self.new_event(report)
event.add('raw', json.dumps(attribute, sort_keys=True))
event.add(self.MISP_TYPE_MAPPING[type_], value)
event.add('misp.event_uuid', misp_event['uuid'])
event.add('misp.attribute_uuid', uuid)
event.add('misp.to_ids', to_ids)
event.add('comment', comment)
event.add('event_description.text', category)
event.add('event_description.url', misp_event_url)
Expand Down
4 changes: 4 additions & 0 deletions intelmq/etc/harmonization.conf
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
"regex": "^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[0-9a-z]{12}$",
"type": "LowercaseString"
},
"misp.to_ids": {
"description": "MISP - Malware Information Sharing Platform & Threat Sharing IDS flag",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me, this is not descriptive enough. I can't understand the meaning of the field from this text.

"type": "Boolean"
},
"output": {
"description": "Event data converted into foreign format, intended to be exported by output plugin.",
"type": "JSON"
Expand Down
1 change: 1 addition & 0 deletions intelmq/tests/bots/parsers/misp/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"malware.name": "locky",
'misp.attribute_uuid': '575c8598-f1f0-4c16-a94a-0612c0a83866',
'misp.event_uuid': '5758ebf5-c898-48e6-9fe9-5665c0a83866',
'misp.to_ids': "false",
"raw": base64_encode(EXAMPLE_MISP_ATTR)
}

Expand Down