Exemple #1
0
def index_count(index_file=config.vulndb_bin_index):
    """
    Method to return the number of indexed items
    :param index_file: Index DB file
    :return: Count of the index
    """
    return len(storage.stream_read(index_file))
Exemple #2
0
def list_all(db):
    """Method to return all data

    :param db: db instance
    :return: List of data stored
    """
    return storage.stream_read(db["db_file"])
Exemple #3
0
def test_create(test_vuln_data):
    with tempfile.NamedTemporaryFile(delete=False) as fp:
        data = storage.store(test_vuln_data, db_file=fp.name)
        assert data
        fp.flush()

        datas = storage.stream_read(db_file=fp.name)
        assert len(datas) > len(test_vuln_data)
        fp.close()
Exemple #4
0
def get(db_file=config.vulndb_bin_file, index_file=config.vulndb_bin_index):
    """Get database instance

    :param db_file: DB file
    :param index_file: Index file
    """
    global index_data
    index_data = build_index(storage.stream_read(index_file))
    return {"db_file": db_file, "index_file": index_file}
Exemple #5
0
def store(db, datas):
    """Store data in the table

    :param table: Table instance
    :param datas: Data list to store
    :return: Stored packed documents
    """
    global index_data, vendor_index_data
    docs = storage.store(datas, db_file=db["db_file"], index_file=db["index_file"])
    # Re-read the index
    index_data, vendor_index_data = build_index(storage.stream_read(db["index_file"]))
    return docs
Exemple #6
0
def index_count(index_file=config.vulndb_bin_index):
    return len(storage.stream_read(index_file))