Database

Database connection

Database helpers

Generic database functions

class CveXplore.database.helpers.generic_db.GenericDatabaseFactory(collection)[source]

Bases: DatasourceConnection

The GenericDatabaseFactory handles the creation of general, collection based, functions which provide an instance of CveXplore functions that apply to the given collection.

__init__(collection)[source]

Create a new GenericDatabaseFactory and create field specific functions based on the __default_fields and the __fields_mapping.

__repr__()[source]

String representation of object

field_list(*doc_ids)[source]

Method to fetch all field names from a specific collection

Return type:

list

get_by_id(doc_id)[source]

Method to fetch a specific collection entry via it’s id number

mget_by_id(*doc_ids)[source]

Method to fetch a specific collection entry via it’s id number

Return type:

Union[Iterable[CveXploreObject], Iterable]

class CveXplore.database.helpers.generic_db.GenericDatabaseFieldsFunctions(field, collection)[source]

Bases: DatasourceConnection

The GenericDatabaseFieldsFunctions handles the creation of general, field based, functions

__init__(field, collection)[source]

Create a new GenericDatabaseFieldsFunctions and create field specific functions.

__repr__()[source]

String representation of object

find(value=None)[source]

Method to find a given value.

search(value)[source]

Method for searching for a given value. The value shall be converted to a regex.

Specific database functions

class CveXplore.database.helpers.specific_db.CWEDatabaseFunctions(collection)[source]

Bases: GenericDatabaseFactory

The CWEDatabaseFunctions is a specific class that provides the cwe attribute of a CveXplore instance additional functions that only apply to the ‘cwe’ collection

__init__(collection)[source]

Create a new GenericDatabaseFactory and create field specific functions based on the __default_fields and the __fields_mapping.

class CveXplore.database.helpers.specific_db.CapecDatabaseFunctions(collection)[source]

Bases: GenericDatabaseFactory

The CapecDatabaseFunctions is a specific class that provides the capec attribute of a CveXplore instance additional functions that only apply to the ‘capec’ collection

__init__(collection)[source]

Create a new GenericDatabaseFactory and create field specific functions based on the __default_fields and the __fields_mapping.

class CveXplore.database.helpers.specific_db.CpeDatabaseFunctions(collection)[source]

Bases: GenericDatabaseFactory

The CpeDatabaseFunctions is a specific class that provides the cpe attribute of a CveXplore instance additional functions that only apply to the ‘cpe’ collection

__init__(collection)[source]

Create a new GenericDatabaseFactory and create field specific functions based on the __default_fields and the __fields_mapping.

find_active_cpes(field, value, limit=0, sorting=1)[source]

Function to find cpe based on value in string. Only active (deprecated == false) cpe records are returned.

Return type:

Optional[List[CveXploreObject]]

search_active_cpes(field, value, limit=0, sorting=1)[source]

Function to regex search for cpe based on value in string. Only active (deprecated == false) cpe records are returned.

Return type:

Optional[List[CveXploreObject]]

class CveXplore.database.helpers.specific_db.CvesDatabaseFunctions(collection)[source]

Bases: GenericDatabaseFactory

The CvesDatabaseFunctions is a specific class that provides the cves attribute of a CveXplore instance additional functions that only apply to the ‘cves’ collection

__init__(collection)[source]

Create a new GenericDatabaseFactory and create field specific functions based on the __default_fields and the __fields_mapping.

get_by_id(doc_id)[source]

Method to retrieve a single CVE from the database by its CVE ID number. The number format should be either CVE-2000-0001, cve-2000-0001 or 2000-0001.

get_cves_for_vendor(vendor, limit=0)[source]

Function to return cves based on a given vendor. By default, to result is sorted descending on th cvss field.

Return type:

Optional[List[CveXploreObject]]

Mongodb specific

class CveXplore.database.helpers.cvesearch_mongo_database.CveSearchCollection(database, name, **kwargs)[source]

Bases: Collection

The CveSearchCollection is a custom Collection based on the pymongo Collection class which has been altered to return a CveSearchCursor reference on the find method.

__init__(database, name, **kwargs)[source]

Get / create a custon cve-search Mongo collection.

__repr__()[source]

Return string representation of this class

find(*args, **kwargs)[source]

Query the database as you would do so with a pymongo Collection.

class CveXplore.database.helpers.cvesearch_mongo_database.CveSearchCursor(collection, *args, **kwargs)[source]

Bases: Cursor

The CveSearchCursor is a custom cursor based on the pymongo cursor which will return database objects instead of the raw data from the mongodb database.

__init__(collection, *args, **kwargs)[source]

Create a new cve-search cursor.

__next__()

Advance the cursor and return CveXplore objects

__repr__()[source]

Return string representation of this class

next()[source]

Advance the cursor and return CveXplore objects

Database Maintenance