Пример #1
0
def create_tables():
    with app.app_context():
        # Ugly hack to create tables and also setting alembic revision
        conn_string = faraday.server.config.database.connection_string
        InitDB()._create_tables(conn_string)
        click.echo(
            click.style('Tables created successfully!', fg='green', bold=True))
Пример #2
0
def initdb(choose_password):
    with app.app_context():
        InitDB().run(choose_password=choose_password)
        couchdb_config_present = faraday.server.config.couchdb
        if couchdb_config_present and couchdb_config_present.user and couchdb_config_present.password:
            print('Importing data from CouchDB, please wait...')
            ImportCouchDB().run()
            print('All users from CouchDB were imported. You can login with your old username/password to faraday now.')
Пример #3
0
def create_tables():
    with app.app_context():
        # Ugly hack to create tables and also setting alembic revision
        conn_string = faraday.server.config.database.connection_string
        if not conn_string:
            logger = logging.getLogger(__name__)
            logger.error((
                'No database configuration found. Please check: '
                'if the database is running or if the configuration settings are correct. '
                'For first time installations execute: faraday-manage initdb'))
            sys.exit(1)
        InitDB()._create_tables(conn_string)
        click.echo(
            click.style('Tables created successfully!', fg='green', bold=True))
Пример #4
0
def reset_db_all():
    # It might be  required to do a cascade delete to correctly the
    # vulnerability table
    for table in ('vulnerability', 'vulnerability_template', 'comment',
                  'faraday_user'):
        try:
            db.engine.execute(f'DROP TABLE {table} CASCADE')
        except Exception as ex:
            print(ex)
    db.drop_all()

    # db.create_all()
    # Ugly hack to create tables and also setting alembic revision
    conn_string = faraday.server.config.database.connection_string
    InitDB()._create_tables(conn_string)
Пример #5
0
def reset_db_all():
    # It might be  required to do a cascade delete to correctly the
    # vulnerability table
    for table in ('vulnerability', 'vulnerability_template', 'comment',
                  'faraday_user'):
        try:
            db.engine.execute('DROP TABLE {} CASCADE'.format(table))
        except:
            pass
    db.drop_all()

    # db.create_all()
    # Ugly hack to create tables and also setting alembic revision
    import faraday.server.config
    conn_string = faraday.server.config.database.connection_string
    from faraday.server.commands.initdb import InitDB
    InitDB()._create_tables(conn_string)
Пример #6
0
def initdb(choose_password, password):
    with app.app_context():
        InitDB().run(choose_password=choose_password, faraday_user_password=password)
Пример #7
0
def initdb(choose_password):
    with app.app_context():
        InitDB().run(choose_password=choose_password)