mirror of https://github.com/MISP/misp-modules
add: Sigma syntax validator expansion module
--> Checks sigma rules syntax - Updated the expansion modules list as well - Updated the requirements listpull/198/head
parent
7c691af807
commit
b1c90b411e
|
@ -20,3 +20,4 @@ pygeoip
|
||||||
bs4
|
bs4
|
||||||
oauth2
|
oauth2
|
||||||
yara
|
yara
|
||||||
|
sigmatools
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
from . import _vmray
|
from . import _vmray
|
||||||
|
|
||||||
__all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl', 'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'farsight_passivedns', 'ipasn', 'passivetotal', 'sourcecache', 'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki', 'iprep', 'threatminer', 'otx', 'threatcrowd', 'vulndb', 'crowdstrike_falcon', 'yara_syntax_validator', 'hashdd', 'onyphe', 'onyphe_full', 'rbl', 'xforceexchange']
|
__all__ = ['vmray_submit', 'asn_history', 'circl_passivedns', 'circl_passivessl', 'countrycode', 'cve', 'dns', 'domaintools', 'eupi', 'farsight_passivedns', 'ipasn', 'passivetotal', 'sourcecache', 'virustotal', 'whois', 'shodan', 'reversedns', 'geoip_country', 'wiki', 'iprep', 'threatminer', 'otx', 'threatcrowd', 'vulndb', 'crowdstrike_falcon', 'yara_syntax_validator', 'hashdd', 'onyphe', 'onyphe_full', 'rbl', 'xforceexchange', 'sigma_syntax_validator']
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
import json
|
||||||
|
try:
|
||||||
|
import yaml
|
||||||
|
from sigma.parser import SigmaParser
|
||||||
|
from sigma.config import SigmaConfiguration
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
print("sigma or yaml is missing, use 'pip3 install sigmatools' to install it.")
|
||||||
|
|
||||||
|
misperrors = {'error': 'Error'}
|
||||||
|
mispattributes = {'input': ['sigma'], 'output': ['text']}
|
||||||
|
moduleinfo = {'version': '0.1', 'author': 'Christian Studer', 'module-type': ['expansion', 'hover'],
|
||||||
|
'description': 'An expansion hover module to perform a syntax check on sigma rules'}
|
||||||
|
moduleconfig = []
|
||||||
|
|
||||||
|
def handler(q=False):
|
||||||
|
if q is False:
|
||||||
|
return False
|
||||||
|
request = json.loads(q)
|
||||||
|
if not request.get('sigma'):
|
||||||
|
misperrors['error'] = 'Sigma rule missing'
|
||||||
|
return misperrors
|
||||||
|
config = SigmaConfiguration()
|
||||||
|
try:
|
||||||
|
parser = SigmaParser(yaml.load(request.get('sigma')), config)
|
||||||
|
result = ("Syntax valid: {}".format(parser.values))
|
||||||
|
except Exception as e:
|
||||||
|
result = ("Syntax error: {}".format(str(e)))
|
||||||
|
return {'results': [{'types': mispattributes['output'], 'values': result}]}
|
||||||
|
|
||||||
|
def introspection():
|
||||||
|
return mispattributes
|
||||||
|
|
||||||
|
def version():
|
||||||
|
moduleinfo['config'] = moduleconfig
|
||||||
|
return moduleinfo
|
Loading…
Reference in New Issue