Skip to content

Commit

Permalink
#21 manage module path
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromeleonard committed May 3, 2017
1 parent 5ad33a8 commit c042bc6
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions contrib/misp-modules-loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def mod(path):

def run(argv):
try:
opts, args = getopt.getopt(argv, 'hp:i:r:', ["help","path=", "info=","run="])
opts, args = getopt.getopt(argv, 'hp:i:r:', ["help", "info=","run="])
except getopt.GetoptError as err:
print(__file__ + " --info <misp-module>")
print(__file__ + " --run <misp-module>")
Expand Down Expand Up @@ -47,17 +47,11 @@ def run(argv):
print("add module path")

elif opt in ('-i','--info'):
module = arg
path = arg
if path:
sys.path.append(mod(path)[0])
m = __import__(mod(path)[1])

data = json.load(sys.stdin)
print(json.dumps(m.handler(json.dumps(data))))
sys.exit(0)

m = __import__(module)
print(({'name': module, 'mispattributes': m.mispattributes,
print(({'name': module, 'mispattributes': m.mispattributes,
'moduleinfo':m.moduleinfo}))


Expand Down

0 comments on commit c042bc6

Please sign in to comment.