MISP/PyMISP

Name: PyMISP

Owner: MISP Project

Description: Python library using the MISP Rest API

Created: 2014-04-16 07:50:11.0

Updated: 2018-01-08 16:06:27.0

Pushed: 2018-01-12 22:32:23.0

Homepage: null

Size: 1121

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

README

Documentation Status Build Status Coverage Status

PyMISP - Python Library to access MISP

PyMISP is a Python library to access MISP platforms via their REST API.

PyMISP allows you to fetch events, add or update events/attributes, add or update samples or search for attributes.

Requirements
Install from pip
 install pymisp
Install the latest version from repo
clone https://github.com/MISP/PyMISP.git && cd PyMISP
submodule update --init
 install -I .
Samples and how to use PyMISP

Various examples and samples scripts are in the examples/ directory.

In the examples directory, you will need to change the keys.py.sample to enter your MISP url and API key.

xamples
eys.py.sample keys.py
keys.py

The API key of MISP is available in the Automation section of the MISP web interface.

To test if your URL and API keys are correct, you can test with examples/last.py to fetch the last 10 events published.

xamples
on3 last.py -l 10
Debugging

You have two options there:

  1. Pass debug=True to PyMISP and it will enable logging.DEBUG to stderr on the whole module

  2. Use the python logging module directly:

rt logging
er = logging.getLogger('pymisp')

nfigure it as you whish, for example, enable DEBUG mode:
er.setLevel(logging.DEBUG)

Or if you want to write the debug output to a file instead of stderr:

rt pymisp
rt logging

er = logging.getLogger('pymisp')
ing.basicConfig(level=logging.DEBUG, filename="debug.log", filemode='w', format=pymisp.FORMAT)
Documentation

PyMISP API documentation is available.

Documentation can be generated with epydoc:

oc --url https://github.com/MISP/PyMISP --graph all --name PyMISP --pdf pymisp -o doc
Everything is a Mutable Mapping

… or at least everything that can be imported/exported from/to a json blob

AbstractMISP is the master class, and inherit collections.MutableMapping which means the class can be represented as a python dictionary.

The abstraction assumes every property that should not be seen in the dictionary is prepended with a _, or its name is added to the private list __not_jsonable (accessible through update_not_jsonable and set_not_jsonable.

This master class has helpers that will make it easy to load, and export, to, and from, a json string.

MISPEvent, MISPAttribute, MISPObjectReference, MISPObjectAttribute, and MISPObject are subclasses of AbstractMISP, which mean that they can be handled as python dictionaries.

MISP Objects

Creating a new MISP object generator should be done using a pre-defined template and inherit AbstractMISPObjectGenerator.

Your new MISPObject generator need to generate attributes, and add them as class properties using add_attribute.

When the object is sent to MISP, all the class properties will be exported to the JSON export.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.