Beispiel #1
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.conn = DatabaseHandler.get_connection()
     self.module_store = ModulesStore()
     self.package_store = PackageStore()
     self.update_store = UpdateStore()
     self.content_set_to_db_id = self._prepare_content_set_map()
Beispiel #2
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.downloader = FileDownloader()
     self.cvemap_store = CvemapStore()
     self.updated = False
     self.lastmodified = None
     self.tmp_directory = tempfile.mkdtemp(prefix="cvemap-")
Beispiel #3
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.downloader = FileDownloader()
     self.unpacker = FileUnpacker()
     self.cverepo_store = CveRepoStore()
     self.repos = set()
     self.db_lastmodified = {}
     self.year_since = int(os.getenv('YEAR_SINCE', DEFAULT_YEAR_SINCE))
 def __init__(self):
     self.logger = get_logger(__name__)
     self.downloader = FileDownloader()
     self.unpacker = FileUnpacker()
     self.repo_store = RepositoryStore()
     self.repositories = set()
     self.certs_tmp_directory = None
     self.certs_files = {}
Beispiel #5
0
    def __init__(self):
        self.logger = get_logger(__name__)
        self.conn = DatabaseHandler.get_connection()
        self.cpe_label_to_id = {}
        self.cpe_label_to_name = {}

        cur = self.conn.cursor()
        cur.execute("select id, label, name from cpe")
        for cpe_id, label, name in cur.fetchall():
            self.cpe_label_to_id[label] = cpe_id
            self.cpe_label_to_name[label] = name
        cur.close()
Beispiel #6
0
    def __init__(self, oval_id, updated, url, local_path):
        self.logger = get_logger(__name__)
        self.oval_id = oval_id
        self.updated = updated
        self.url = url
        self.local_path = local_path
        self.root = None

        self.definitions = []
        self.tests = []
        self.objects = []
        self.states = []
Beispiel #7
0
def test_progress_logger(caplog):
    """Test ProgressLogger."""
    logger = logging_utils.get_logger(__name__)
    progress_logger = logging_utils.ProgressLogger(logger, 3, log_interval=0)

    progress_logger.update()
    progress_logger.update()
    progress_logger.update()
    progress_logger.reset(4)
    progress_logger.update()

    assert caplog.records[0].message == ' 33.33 % completed [1/3]'
    assert caplog.records[1].message == ' 66.67 % completed [2/3]'
    assert caplog.records[2].message == '100.00 % completed [3/3]'
    assert caplog.records[3].message == ' 25.00 % completed [1/4]'
Beispiel #8
0
import glob
import os
import json
import gzip
from common.logging_utils import get_logger, init_logging
from common.dateutil import format_datetime, now
from common.fileutil import remove_file_if_exists
from common.rpm import join_rpm_name
from database.database_handler import DatabaseHandler, NamedCursor, init_db

DEFAULT_KEEP_COPIES = "2"
PKGTREE_FILE = '/data/pkg_tree.json.gz'
DEFAULT_PKGTREE_INDENT = "0"

LOGGER = get_logger(__name__)


class JsonPkgTree:  # pylint: disable=too-many-instance-attributes
    """Class for creating package tree json file from database."""
    def __init__(self, db_instance, filename):
        self.db_instance = db_instance
        self.filename = filename
        self.outputdata = {}
        self.datadict = {}
        self.pkgnameid2pkgname = {}
        self.evrid2evr = {}
        self.archid2arch = {}
        self.packagedata = {}
        self.repodata = {}
        self.cvename = {}
Beispiel #9
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.repo = []
     self.conn = DatabaseHandler.get_connection()
     self.cve_store = CveStore()
Beispiel #10
0
 def __init__(self):
     self.queue = []
     self.logger = get_logger(__name__)
     self.chunk_size = int(os.getenv('CHUNK_SIZE', DEFAULT_CHUNK_SIZE))
     self.progress_logger = ProgressLogger(self.logger, 0)
Beispiel #11
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.conn = DatabaseHandler.get_connection()
Beispiel #12
0
 def __init__(self):
     self.queue = Queue()
     self.logger = get_logger(__name__)
     self.num_threads = int(os.getenv('THREADS', DEFAULT_THREADS))
Beispiel #13
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.downloader = FileDownloader()
     self.cpe_store = CpeStore()
     self.tmp_directory = tempfile.mkdtemp(prefix="cpe-")
Beispiel #14
0
Wait for VMaaS services.
"""
import os
import signal
import sys
import time

from requests import request

from common.config import Config
from common.logging_utils import get_logger
from common.logging_utils import init_logging
from reposcan.database.database_handler import DatabaseHandler
from reposcan.database.database_handler import init_db

LOGGER = get_logger(__file__)


def bye():
    """Handle signal"""
    sys.exit("Stopped.")


def wait(func, *args, delay=1, service=""):
    """Waits for success of `func`."""
    LOGGER.info("Checking if %s is up", service)
    while True:
        try:
            result = func(*args)
            if result:
                return
Beispiel #15
0
#!/usr/bin/env python3
"""
Main entrypoint of websocket server.
"""
import signal

from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.web import Application, RequestHandler
from tornado.websocket import WebSocketHandler

from common.logging_utils import get_logger, init_logging

WEBSOCKET_PING_INTERVAL = 5
WEBSOCKET_TIMEOUT = 60

LOGGER = get_logger("websocket")


class NotificationHandler(WebSocketHandler):
    """Websocket handler to send messages to subscribed clients."""
    connections = {}
    # What is the freshest data each webapp has
    webapp_export_timestamps = {}
    # What time did we advertise last
    last_refresh_sent = None

    def __init__(self, application, request, **kwargs):
        super(NotificationHandler, self).__init__(application, request,
                                                  **kwargs)
        self.last_pong = None
        self.timeout_callback = None
Beispiel #16
0
 def __init__(self):
     self.logger = get_logger(__name__)
     self.conn = DatabaseHandler.get_connection()
     self.cpe_label_to_id = {}
     self.cpe_label_to_name = {}