-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import json | ||
|
||
from pymisp import MISPEvent, EncodeUpdate | ||
|
||
misperrors = {'error': 'Error'} | ||
|
||
moduleinfo = {'version': '0.1', 'author': 'Raphaël Vinot', | ||
'description': 'Sign a MISP Event', | ||
'module-type': ['event']} | ||
|
||
moduleconfig = ['uid', 'passphrase'] | ||
|
||
''' | ||
NOTE: | ||
* requires pyme3 + dependencies | ||
* working gpg-agent | ||
* private key for signing | ||
''' | ||
|
||
|
||
def handler(q=False): | ||
if q is False: | ||
return False | ||
request = json.loads(q) # Assuming request has two keys: config & mispevent (mispevent being the json dump of the event) | ||
mispevent = MISPEvent() | ||
mispevent.load(request['mispevent']) | ||
mispevent.sign(request['config']['uid'], request['config']['passphrase']) | ||
return json.dumps(mispevent, cls=EncodeUpdate) | ||
|
||
|
||
def introspection(): | ||
return moduleconfig | ||
|
||
|
||
def version(): | ||
moduleinfo['config'] = moduleconfig | ||
return moduleinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
import json | ||
|
||
from pymisp import MISPEvent | ||
|
||
misperrors = {'error': 'Error'} | ||
|
||
moduleinfo = {'version': '0.1', 'author': 'Raphaël Vinot', | ||
'description': 'Verify the signature of a MISP Event', | ||
'module-type': ['event']} | ||
|
||
moduleconfig = ['uid'] | ||
|
||
''' | ||
NOTE: | ||
* requires pyme3 + dependencies | ||
* working gpg-agent | ||
* the public key which signed the event in the keyring | ||
''' | ||
|
||
|
||
def handler(q=False): | ||
if q is False: | ||
return False | ||
request = json.loads(q) # Assuming request has two keys: config & mispevent (mispevent being the json dump of the event) | ||
mispevent = MISPEvent() | ||
mispevent.load(request['mispevent']) | ||
verified = mispevent.verify(mispevent.Org['uuid']) | ||
return json.dumps(verified) | ||
|
||
|
||
def introspection(): | ||
return moduleconfig | ||
|
||
|
||
def version(): | ||
moduleinfo['config'] = moduleconfig | ||
return moduleinfo |