def before_all(context): context.SERVER_ADDRESS = os.environ['SERVER_ADDRESS'] context.BROKER_URI = os.environ['BROKER_URI'] db.init_engine(os.environ['DATABASE_URI']) context.engine = db.engine context.redis_db = _setup_redis(context.BROKER_URI)
def test_module_registers_all_modules_in_metadata(self, mock_create_engine): """After initialization all models needs to exist in the metadata""" db.init_engine() assert 'project' in Base.metadata.tables.keys() assert 'scan' in Base.metadata.tables.keys() assert 'scan_vulnerability' in Base.metadata.tables.keys() assert 'vulnerability' in Base.metadata.tables.keys() assert 'vulnerabilities_in_scans' in Base.metadata.tables.keys()
def step_impl(context): db.init_engine(db_uri=os.environ['DATABASE_URI']) clean_directory(context.SHARED_VOLUME_PATH) sql = text('DELETE FROM vulnerability') context.engine.execute(sql) sql = text('DELETE FROM scan_vulnerability') context.engine.execute(sql) sql = text('DELETE FROM scan_deps') context.engine.execute(sql) sql = text('DELETE FROM scan') context.engine.execute(sql) sql = text('DELETE FROM project') context.engine.execute(sql) context.redis_db.delete('celery')
def test_after_init_engine_metadata_should_create_all_models( self, mock_database_exists, mock_create_engine, mock_base): """After initialization metadata should create all models""" db.init_engine() assert mock_base.metadata.create_all.called
Celery worker module. ~~~~~~~~~~~~~~~~~~~~~ This module can be launched with celery to create workers to handle tasks. Run deeptracy celery workers with `INFO` log levels:: $ celery -A deeptracy.celery:celery worker -l INFO """ from celery import Celery from deeptracy_core.dal.database import db from .config import BROKER_URI from .plugin_store import plugin_store db.init_engine() # Init database engine plugin_store.load_plugins() # Load analyzer plugins # SETUP AND CREATE CELERY APP celery = Celery('deeptracy', broker=BROKER_URI, backend=BROKER_URI, include=[ 'deeptracy.tasks.prepare_scan', 'deeptracy.tasks.scan_deps', 'deeptracy.tasks.start_scan', 'deeptracy.tasks.run_analyzer', 'deeptracy.tasks.merge_results', 'deeptracy.tasks.notify_results' ])
# Copyright 2017 BBVA # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """ Module for deeptracy """ from deeptracy_core.dal.database import db from .celery import setup_celery from .api.flask import setup_api db.init_engine() # Init database engine celery = setup_celery() # setup the celery client flask_app = setup_api() # setup flask api