mirror of https://github.com/MISP/misp-modules
chg: [action:mattermost] Improved support of hostname/url
parent
93bae11e33
commit
b01dc1d22b
|
@ -1,4 +1,5 @@
|
||||||
import json
|
import json
|
||||||
|
from pyfaup.faup import Faup
|
||||||
from mattermostdriver import Driver
|
from mattermostdriver import Driver
|
||||||
from ._utils import utils
|
from ._utils import utils
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@ moduleconfig = {
|
||||||
'params': {
|
'params': {
|
||||||
'mattermost_hostname': {
|
'mattermost_hostname': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'description': 'The Mattermost domain',
|
'description': 'The Mattermost domain or URL',
|
||||||
'value': 'example.mattermost.com',
|
'value': 'example.mattermost.com',
|
||||||
},
|
},
|
||||||
'bot_access_token': {
|
'bot_access_token': {
|
||||||
|
@ -44,15 +45,18 @@ moduleinfo = {'version': '0.1', 'author': 'Sami Mokaddem',
|
||||||
'description': 'Simplistic module to send message to a Mattermost channel.',
|
'description': 'Simplistic module to send message to a Mattermost channel.',
|
||||||
'module-type': ['action']}
|
'module-type': ['action']}
|
||||||
|
|
||||||
|
f = Faup()
|
||||||
|
|
||||||
def createPost(request):
|
def createPost(request):
|
||||||
params = request['params']
|
params = request['params']
|
||||||
|
f.decode(params['mattermost_hostname'])
|
||||||
|
parsedURL = f.get()
|
||||||
mm = Driver({
|
mm = Driver({
|
||||||
'url': params['mattermost_hostname'],
|
'url': parsedURL['host'],
|
||||||
'token': params['bot_access_token'],
|
'token': params['bot_access_token'],
|
||||||
'scheme': 'https',
|
'scheme': parsedURL['scheme'] if parsedURL['scheme'] is not None else 'https',
|
||||||
'basepath': '/api/v4',
|
'basepath': '/api/v4',
|
||||||
'port': 443,
|
'port': int(parsedURL['port']) if parsedURL['port'] is not None else 443,
|
||||||
})
|
})
|
||||||
mm.login()
|
mm.login()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue