Ejemplo n.º 1
0
import json
from copy import copy, deepcopy
from logging import getLogger
import os
import time
import utils

log = getLogger(utils.get_module_name(os.path.basename(__file__)))


class Configurations():
    def __init__(self, parsed_params):
        self._jmanager_config = parsed_params['jmanager_config']
        self._template_config = parsed_params['config_template']

        self._load()

    def _fillTemplate(self, template, obj):
        if type(obj) is list:
            for idx in range(len(obj)):
                if len(template) < len(obj):
                    template.append(obj[idx])
                self._fillTemplate(template[idx], obj[idx])
        elif type(obj) is dict:
            for key in obj.keys():
                if ((not type(obj[key]) is dict)
                        and (not type(obj[key]) is list)):
                    template[key] = obj[key]
                else:
                    self._fillTemplate(template[key], obj[key])
Ejemplo n.º 2
0
import abc
import json
import redis
from datetime import datetime
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))

from logger import LOGINFO_IF_ENABLED
from logger import LOGERR_IF_ENABLED
from utils import get_module_name

from caches import stats as stats_cache

from state import State
from state import decode as decode_state

MODULE_NAME = get_module_name(__file__)
SOURCE_MODULE = '[{0}] :: '.format(MODULE_NAME)


class Observer(metaclass=abc.ABCMeta):
    def __init__(self):
        self._subject = None
        self._observer_state = None

    @abc.abstractmethod
    def update(self, state):
        pass


class LogObserver(Observer):
    def __init__(self, source_module):
Ejemplo n.º 3
0
import zlib
from threading import Thread
from xml.sax import make_parser
from xml.sax.handler import ContentHandler
from datetime import datetime

baseDir = os.path.dirname(os.path.abspath(os.path.dirname(__file__)))
sys.path.append(baseDir)

from logger import LOGERR_IF_ENABLED, LOGINFO_IF_ENABLED
from utils import get_file, get_module_name, check_internet_connection
from settings import SETTINGS

from dskcache import DequeDiskCache as dc

SOURCE_MODULE = '[{0}] :: '.format(get_module_name(__file__))
PLUGIN_NAME = get_module_name(__file__)


class CWEHandler(ContentHandler):
    def __init__(self):
        self.cwe = []
        self.description_summary_tag = False
        self.weakness_tag = False

    def startElement(self, name, attrs):
        if name == 'Weakness':
            self.weakness_tag = True
            self.statement = ""
            self.weaknesses = attrs.get('Weakness_Abstraction')
            self.name = attrs.get('Name')
Ejemplo n.º 4
0
import os
import json
import redis

from utils import get_module_name
from settings import SETTINGS
from logger import LOGINFO_IF_ENABLED, LOGERR_IF_ENABLED

SOURCE_MODULE = '[{0}] :: '.format(get_module_name(__file__))

cache_local_settings = SETTINGS.get("cache", {})
cache_default_host = cache_local_settings.get("host", "localhost")
cache_default_port = cache_local_settings.get("port", 6379)
cache_default_db = cache_local_settings.get("db", 3)

store_local_settings = SETTINGS.get("store", {})
store_default_host = store_local_settings.get("host", "localhost")
store_default_port = store_local_settings.get("port", 6379)
store_default_db = store_local_settings.get("db", 2)

stats_local_settings = SETTINGS.get("stats", {})
stats_default_host = stats_local_settings.get("host", "localhost")
stats_default_port = stats_local_settings.get("port", 6379)
stats_defailt_db = stats_local_settings.get("db", 1)

queue_local_settings = SETTINGS.get("queue", {})
queue_default_host = queue_local_settings.get("host", "localhost")
queue_default_port = queue_local_settings.get("port", 6379)
queue_defailt_db = queue_local_settings.get("db", 0)

cache_host = os.environ.get("REDIS_HOST", cache_default_host)