# Path: lightbulb/core/base.py
# def options_as_dictionary(meta):
#     """
#     Transforms a list of tuples to a dictionary
#     Args:
#         meta (list): A list ot option tuples
#     Retuns:
#         dict: A dictionary of options key - values
#     """
#     module_config = {}
#     for seltuple in meta:
#         module_config.update({seltuple[0]: seltuple[1]})
#     return  module_config
# 
# Path: lightbulb/core/operate.py
# def manage(module_name, configuration):
#     """
#     This function manages the module initialization and execution
#     Args:
#         module_name (class): The module class to be initiated
#         configuration (dict): The module options
#     Returns:
#        list: A list with the results and stats as tuples
#     """
# 
#     module = __import__(module_name)
#     classmembers = [classmodule for classmodule in inspect.getmembers(module, inspect.isclass)
#                     if classmodule[0] == 'Module' or classmodule[0] == 'Module_A'
#                     or classmodule[0] == 'Module_B']
#     if len(classmembers) == 1:
#         return  operate_learn(classmembers[0][1], configuration)
#     else:
#         if classmembers[0][0] == "Module_A":
#             return operate_diff(classmembers[0][1], configuration, classmembers[1][1], configuration)
#         else:
#             return operate_diff(classmembers[1][1], configuration, classmembers[0][1], configuration)
# 
# Path: lightbulb/core/utils/common.py
# def findlibrary(path):
#     path = re.sub('.*my_saved_models/', expanduser("~") + "/.LightBulb/models/", path)
#     path = re.sub('.*my_saved_regex/', expanduser("~") + "/.LightBulb/regex/", path)
#     path = re.sub('.*my_saved_trees/', expanduser("~") + "/.LightBulb/trees/", path)
#     path = re.sub('.*my_saved_grammars/', expanduser("~") + "/.LightBulb/grammars/", path)
#     path = path.replace('{library}', imp.find_module('lightbulb')[1]+"/data/")
#     return path


from lightbulb.core.base import options_as_dictionary
from collections import OrderedDict
from lightbulb.core.operate import manage
from lightbulb.core.utils.common import findlibrary
import json
class Module():


    def __init__(self, configuration):
        self.configuration = configuration
        self.stats_records = []
        with open(findlibrary(configuration['WAFCONF']), 'r') as fp:
            self.wafs = json.load(fp,object_pairs_hook=OrderedDict)
        self.name = "CORRECT"


    def learn(self):
        for waf in self.wafs:
            configuration = {
                'FILE' : self.configuration['FILE'],
                'URL' : self.wafs[waf]['data']['URL'],
                'REQUEST_TYPE' : self.wafs[waf]['data']['REQUEST_TYPE'],
                'PARAM' : self.wafs[waf]['data']['PARAM'],
                'BLOCK' : self.wafs[waf]['data']['BLOCK'],
                'BYPASS' : self.wafs[waf]['data']['BYPASS'],
                'PROXY_SCHEME' : self.configuration['PROXY_SCHEME'],
                'PROXY_HOST' : self.configuration['PROXY_HOST'],
                'PROXY_PORT' : self.configuration['PROXY_PORT'],
                'PROXY_USERNAME' : self.configuration['PROXY_USERNAME'],
                'PROXY_PASSWORD' : self.configuration['PROXY_PASSWORD'],
                'USER_AGENT' : self.configuration['USER_AGENT'],
                'ALPHABET': None,
                'REFERER' : self.configuration['REFERER'],
            }
            res = options_as_dictionary(manage("distinguish_waf", configuration))

# Path: lightbulb/core/base.py
# def options_as_dictionary(meta):
#     """
#     Transforms a list of tuples to a dictionary
#     Args:
#         meta (list): A list ot option tuples
#     Retuns:
#         dict: A dictionary of options key - values
#     """
#     module_config = {}
#     for seltuple in meta:
#         module_config.update({seltuple[0]: seltuple[1]})
#     return  module_config
# 
# Path: lightbulb/core/operate.py
# def manage(module_name, configuration):
#     """
#     This function manages the module initialization and execution
#     Args:
#         module_name (class): The module class to be initiated
#         configuration (dict): The module options
#     Returns:
#        list: A list with the results and stats as tuples
#     """
# 
#     module = __import__(module_name)
#     classmembers = [classmodule for classmodule in inspect.getmembers(module, inspect.isclass)
#                     if classmodule[0] == 'Module' or classmodule[0] == 'Module_A'
#                     or classmodule[0] == 'Module_B']
#     if len(classmembers) == 1:
#         return  operate_learn(classmembers[0][1], configuration)
#     else:
#         if classmembers[0][0] == "Module_A":
#             return operate_diff(classmembers[0][1], configuration, classmembers[1][1], configuration)
#         else:
#             return operate_diff(classmembers[1][1], configuration, classmembers[0][1], configuration)
# 
# Path: lightbulb/core/utils/common.py
# def findlibrary(path):
#     path = re.sub('.*my_saved_models/', expanduser("~") + "/.LightBulb/models/", path)
#     path = re.sub('.*my_saved_regex/', expanduser("~") + "/.LightBulb/regex/", path)
#     path = re.sub('.*my_saved_trees/', expanduser("~") + "/.LightBulb/trees/", path)
#     path = re.sub('.*my_saved_grammars/', expanduser("~") + "/.LightBulb/grammars/", path)
#     path = path.replace('{library}', imp.find_module('lightbulb')[1]+"/data/")
#     return path


# Path: lightbulb/modules/verify_waf_tree.py
from lightbulb.core.base import options_as_dictionary
from collections import OrderedDict
from lightbulb.core.operate import manage
from lightbulb.core.utils.common import findlibrary
import json

class Module():


    def __init__(self, configuration):
        self.configuration = configuration
        self.stats_records = []
        with open(findlibrary(configuration['WAFCONF']), 'r') as fp:
            self.wafs = json.load(fp,object_pairs_hook=OrderedDict)
        self.name = "CORRECT"


    def learn(self):
        for waf in self.wafs:
            configuration = {
                'FILE' : self.configuration['FILE'],
                'URL' : self.wafs[waf]['data']['URL'],
                'REQUEST_TYPE' : self.wafs[waf]['data']['REQUEST_TYPE'],
                'PARAM' : self.wafs[waf]['data']['PARAM'],
                'BLOCK' : self.wafs[waf]['data']['BLOCK'],
                'BYPASS' : self.wafs[waf]['data']['BYPASS'],
                'PROXY_SCHEME' : self.configuration['PROXY_SCHEME'],
                'PROXY_HOST' : self.configuration['PROXY_HOST'],
                'PROXY_PORT' : self.configuration['PROXY_PORT'],
                'PROXY_USERNAME' : self.configuration['PROXY_USERNAME'],
                'PROXY_PASSWORD' : self.configuration['PROXY_PASSWORD'],
                'USER_AGENT' : self.configuration['USER_AGENT'],
                'ALPHABET': None,
                'REFERER' : self.configuration['REFERER'],
            }
            res = options_as_dictionary(manage("distinguish_waf", configuration))

            if res['Waf'] == self.wafs[waf]['name']: