Exemplo n.º 1
0
class CifStore(Auth):

    name = 'cif_store'

    def __init__(self, **kwargs):
        self.store = Store(store_type=STORE_DEFAULT, nodes=STORE_NODES)
        self.store._load_plugin(store_type=STORE_DEFAULT, nodes=STORE_NODES)

    def handle_token_search(self, token, **kwargs):
        return self.store.store.tokens.auth_search({'token': token})
Exemplo n.º 2
0
 def _init_store(self, context, store_address, store_type, nodes=False):
     self.logger.info('launching store...')
     p = mp.Process(target=Store(store_address=store_address,
                                 store_type=store_type,
                                 nodes=nodes).start)
     p.start()
     self.store_p = p
Exemplo n.º 3
0
def store():
    dbfile = tempfile.mktemp()
    with Store(store_type='sqlite', db_path='sqlite:///' + dbfile) as s:
        yield s

    if os.path.isfile(dbfile):
        os.unlink(dbfile)
Exemplo n.º 4
0
 def _init_store(self, context, store_address, store_type, nodes=False):
     self.logger.info('launching store...')
     t = threading.Thread(target=Store(context=context,
                                       store_address=store_address,
                                       store_type=store_type,
                                       nodes=nodes).start)
     t.daemon = True
     t.start()
Exemplo n.º 5
0
def store():
    dbfile = tempfile.mktemp()
    with Store(store_type='sqlite', dbfile=dbfile) as s:
        s._load_plugin(dbfile=dbfile)
        yield s

    if os.path.isfile(dbfile):
        os.unlink(dbfile)
Exemplo n.º 6
0
def store():
    dbfile = tempfile.mktemp()
    with Store(store_type='sqlite', dbfile=dbfile) as s:
        s.token_handler.token_create_admin()
        yield s

    if os.path.isfile(dbfile):
        os.unlink(dbfile)
Exemplo n.º 7
0
def test_store_dummy(obs):
    with Store(store='dummy') as s:
        t = s.store.tokens_admin_exists()

        x = s.handle_indicators_search(t, obs.__dict__)
        assert x[0]['indicator'] == 'example.com'

        x = s.handle_indicators_create(t, obs.__dict__)
        assert x[0]['indicator'] == 'example.com'
Exemplo n.º 8
0
def test_store_dummy(indicator):
    with Store(store_type='dummy') as s:
        t = s.store.tokens_admin_exists()

        x = s.handle_indicators_search(indicator)
        assert x[0]['indicator'] == 'example.com'

        x = s.handle_indicators_create(dict(indicator))
        assert x[0]['indicator'] == 'example.com'
def store():
    dbfile = tempfile.mktemp()
    with Store(store_type='sqlite', dbfile=dbfile) as s:
        s._load_plugin(dbfile=dbfile)
        s.token_create_admin()
        yield s

    s = None
    if os.path.isfile(dbfile):
        os.unlink(dbfile)
Exemplo n.º 10
0
def store():

    with Store(store_type='elasticsearch', nodes='192.168.99.100:9200') as s:
        s._load_plugin(nodes='192.168.99.100:9200')
        try:
            connections.get_connection().indices.delete(index='indicators-*')
            connections.get_connection().indices.delete(index='tokens')
        except Exception as e:
            pass
        yield s
Exemplo n.º 11
0
def store():
    try:
        [_del_index(i) for i in ['indicators-*', 'tokens']]

    except Exception as e:
        pass

    with Store(store_type='elasticsearch') as s:

        yield s

    [_del_index(i) for i in ['indicators-*', 'tokens']]
Exemplo n.º 12
0
def store():
    try:
        connections.get_connection().indices.delete(index='indicators-*')
        connections.get_connection().indices.delete(index='tokens')
    except Exception as e:
        pass

    with Store(store_type='elasticsearch', nodes='127.0.0.1:9200') as s:
        s._load_plugin(nodes='127.0.0.1:9200')
        yield s

    try:
        assert connections.get_connection().indices.delete(index='indicators-*')
        assert connections.get_connection().indices.delete(index='tokens')
    except Exception:
        pass
Exemplo n.º 13
0
def store():
    with Store(store_type='rdflib') as s:
        s._load_plugin()
        yield s
def store():
    with Store(store_type='elasticsearch') as s:
        yield s
Exemplo n.º 15
0
def store():
    dbfile = tempfile.mktemp()
    with Store(store_type='sqlite', dbfile=dbfile) as s:
        yield s

    os.unlink(dbfile)
Exemplo n.º 16
0
 def _init_store(self, store_address, store_type, nodes=False):
     logger.info('launching store...')
     self.store_s = self.context.socket(zmq.DEALER)
     self.store_s.bind(store_address)
     self.store_p = mp.Process(target=Store(store_address=store_address, store_type=store_type, nodes=nodes).start)
     self.store_p.start()
Exemplo n.º 17
0
 def __init__(self, **kwargs):
     self.store = Store(store_type=STORE_DEFAULT, nodes=STORE_NODES)
     self.store._load_plugin(store_type=STORE_DEFAULT, nodes=STORE_NODES)
def store():
    with Store(store_type='rdflib') as s:
        yield s