Module index#

Indices and tables#

statsservice#

statsservice.get_version()#

Get the current version of the software. First it checks if the environment variable STATSSERVICE_VERSION is defined. If not, if a .git folder is present it uses Git tags, else it uses importlib module.

Return type

str

Models#

class statsservice.models.client.Client(**kwargs)#

Represent a client. A client can be used to represent one or several MONARC clients/instances and all stats are linked to a client.

get_id()#

Return the id of the client.

Return type

int

class statsservice.models.stats.Stats(**kwargs)#

Represent a single stats from a MONARC instance. The type can be one value from the folowing: “risk”, “vulnerability”, “threat”, “cartography”, “compliance”.

Lib#

statsservice.lib.processors.risk_averages(risks_stats, processor_params=None)#

Evaluates the averages for the risks. Averages are evaluated per categories (current/residual, informational/operational, low/medium/high).

statsservice.lib.processors.risk_averages_on_date(risks_stats, processor_params=None)#

Evaluates the averages for the risks per date. Averages are evaluated per categories (current/residual, informational/operational, low/medium/high). Supported parameters: - risks_type: informational or operational - risks_state: current or residual.

statsservice.lib.processors.vulnerability_average_on_date(vulnerabilities_stats, processor_params=None)#

Aggregation and average of vulnerabilities per date for each vulnerability (accross all risk analysis).

Return type

list

statsservice.lib.mosp.is_object_published(uuid, verbose=False)#

Check if an object has been published on MOSP.

Return type

bool

statsservice.lib.utils.dict_hash(dictionary)#

MD5 hash of a dictionary.

Return type

str

statsservice.lib.utils.dict_recursive_walk(dictionary, func, *args, **kwargs)#

Walk recursively in a nested dictionary and apply a function (send()) with parameters.

statsservice.lib.utils.groups_threats(threats)#

Groups stats about threats per ANR (UUID) then per threat UUID. Function not used.

statsservice.lib.utils.groups_vulnerabilities(vulnerabilities)#

Groups stats about vulnerabilities per ANR (UUID) then per vulnerability UUID. Function not used.

statsservice.lib.utils.mean_gen()#

Yields the accumulated mean of sent values.

>>> g = meangen()
>>> g.send(None) # Initialize the generator
>>> g.send(4)
4.0
>>> g.send(10)
7.0
>>> g.send(-2)
4.0
statsservice.lib.utils.tree()#

Autovivification.

statsservice.lib.validation.validate_data(data=None, type='')#

Check the validity of the submitted stats data. Note: an empty JSON object is validated by any schema but we do not accept empty stats.

Commands#