Skip to content
Snippets Groups Projects
flow2template.py 875 B
#!/usr/bin/env python

import argparse,gzip,xml.etree.ElementTree

parser = argparse.ArgumentParser()
parser.add_argument("flowfile", help="input gziped flowfile")
parser.add_argument("templatefile", help="output template file")
args = parser.parse_args()

f=gzip.open(args.flowfile,'rb')
et = xml.etree.ElementTree.parse(f)

for v in et.findall(".//variable"):
    a=v.attrib
    if a['name']=="misp_token":
        a['value']="{{ misp_token }}"
    elif a['name']=="misp_url":
        a['value']="{{ misp_url }}"
    elif a['name']=="maxmind_key":
        a['value']="{{ maxmind_key }}"
    elif a['name']=="elastic_url":
        a['value']="https://{{ dslproxy }}:9200"
    elif a['name']=="elastic_username":
        a['value']="{{ elastic_username }}"
    elif a['name']=="elastic_password":
        a['value']="{{ odfees_adminpass }}"
    
et.write(args.templatefile)