Skip to content

Commit 22a95a0

Browse files
authored
Bump and docs: v2.12.0 (#923)
1 parent 694c219 commit 22a95a0

11 files changed

+134
-17
lines changed

docker-compose.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
depends_on:
1010
- postgres
1111
- redis
12-
image: certpl/mwdb:v2.11.0
12+
image: certpl/mwdb:v2.12.0
1313
restart: on-failure
1414
env_file:
1515
# NOTE: use gen_vars.sh in order to generate this file
@@ -22,7 +22,7 @@ services:
2222
build:
2323
context: .
2424
dockerfile: deploy/docker/Dockerfile-web
25-
image: certpl/mwdb-web:v2.11.0
25+
image: certpl/mwdb-web:v2.12.0
2626
ports:
2727
- "80:80"
2828
restart: on-failure

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
author = 'CERT Polska'
2222

2323
# The full version, including alpha/beta/rc tags
24-
release = '2.11.0'
24+
release = '2.12.0'
2525

2626

2727
# -- General configuration ---------------------------------------------------

docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Features
2828
karton-guide
2929
oauth-guide
3030
rich-attributes-guide
31+
prometheus-guide
3132

3233
Indices and tables
3334
==================

docs/prometheus-guide.rst

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Prometheus metrics
2+
==================
3+
4+
.. versionadded:: 2.12.0
5+
6+
MWDB allows to enable Prometheus metrics to grab information about API usage by users.
7+
8+
Available metrics:
9+
10+
- ``mwdb_api_requests (method, endpoint, user, status_code)`` that tracks usage of specific endpoints by users and status codes.
11+
- ``mwdb_deprecated_usage (feature, method, endpoint, user)`` that tracks usage of deprecated API endpoints
12+
13+
Useful PromQL queries (in most cases we use 5-minute window):
14+
15+
- ``sum(increase(mwdb_api_requests{}[5m])/5) by (user)`` - counts general API usage by MWDB users in requests per minute
16+
- ``sum(increase(mwdb_api_requests{status_code != "200"}[5m])) by (user, status_code)`` - API error rate grouped by user and status_code
17+
- ``sum(increase(mwdb_api_requests{endpoint=~"api.filedownloadresource|api.requestsampledownloadresource|api.downloadresource|api.filedownloadzipresource", method="GET"}[5m])/5) by (user)`` - file download rate
18+
- ``sum(increase(mwdb_api_requests{endpoint=~"api.fileresource|api.fileitemresource", method="POST"}[5m])/5) by (user)`` - file upload rate
19+
20+
Setup guide
21+
-----------
22+
23+
1. First, you need to configure Redis server where metric counters are stored. Redis instance can be configured in MWDB via
24+
``redis_uri`` option in mwdb.ini file or ``MWDB_REDIS_URI`` environment variable.
25+
26+
2. Then you need to enable metrics by setting ``enable_prometheus_metrics=1`` in configuration or ``MWDB_ENABLE_PROMETHEUS_METRICS=1`` in env vars
27+
28+
3. Log in as admin in MWDB and go to http://<mwdb>/settings/users. Create user account that will be used to access prometheus metrics.
29+
30+
4. Go to ``Check user capabilities`` or http://<mwdb>/settings/user/<username>/capabilities to set ``access_prometheus_metrics`` ACL for created account.
31+
32+
5. Then generate API key on http://<mwdb>>/settings/user/<username>/api-keys that will be used to scrape metrics by Prometheus
33+
34+
After setup, metrics can be scraped using ``http://<mwdb-api>/api/varz`` endpoint with API key provided in ``Authorization: Bearer <api_key>`` HTTP header.
35+
36+
You can test it before setting up Prometheus using curl:
37+
38+
.. code-block:: console
39+
40+
$ curl http://<mwdb-api>/api/varz -H 'Authorization: Bearer <api_key>'
41+
42+
Detailed instructions about Prometheus configuration can be found in `Prometheus docs <https://prometheus.io/docs/prometheus/latest/configuration/configuration/>`_.

docs/requirements.txt

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Sphinx==4.5.0
2-
sphinx-rtd-theme==0.5.2
3-
jsx-lexer==1.0.0
4-
# FIX: https://github.com/readthedocs/sphinx_rtd_theme/issues/1115
5-
docutils==0.16
1+
Sphinx==7.2.6
2+
sphinx-rtd-theme==2.0.0
3+
jsx-lexer==2.0.1

docs/setup-and-configuration.rst

+7-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,15 @@ MWDB was tested on Debian-based systems, but should work as well on other Linux
4141

4242
For production environments, you need to install:
4343

44-
4544
* **PostgreSQL database** (minimum supported version: 12, https://www.postgresql.org/download/linux/debian/)
4645
* libfuzzy2 for ssdeep evaluation
46+
* other native dependencies listed below
4747

48-
Optionally you can install:
48+
.. code-block:: console
4949
50+
$ apt install gcc libfuzzy-dev python3-dev python3-venv postgresql-client postgresql-common
51+
52+
Optionally you can install:
5053

5154
* **Docker engine and Docker-Compose** if you want to use the Docker-based setup (https://docs.docker.com/engine/install/)
5255
* **Redis database** needed by extra features like rate-limiting (https://redis.io/topics/quickstart)
@@ -311,6 +314,8 @@ Extra features:
311314
* ``enable_registration`` (0 or 1) - Turns on user registration features. Requires additional configuration. Default is ``0``.
312315
* ``enable_maintenance`` (0 or 1) - Turns on maintenance mode, making MWDB unavailable for users other than ``admin``. Default is ``0``.
313316
* ``enable_json_logger`` (0 or 1) - Enables JSON logging which may be more convenient for automated log processing. Default is ``0``.
317+
* ``enable_prometheus_metrics`` (0 or 1) - Enables Prometheus metrics (\ ``/api/varz`` endpoint\ )
318+
* ``enable_debug_log`` (0 or 1) - Enables debug logging
314319
* ``redis_uri`` (string) - Redis database connection string, required by rate limiter.
315320
* ``remotes`` (comma separated strings) - list of MWDB remotes (experimental)
316321
* ``enable_hooks`` (0 or 1) - enable plugin hooks

docs/whats-changed.rst

+73-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,78 @@ This page describes the most significant changes in the following versions, that
55
integration and plugin developers. We usually don't break API compatibility within major version, but plugins may
66
have compatibility problems after minor mwdb-core upgrade.
77

8-
For upgrade instructions, see :ref:`Upgrade mwdb-core to latest version`.
8+
For upgrade instructions, see :ref:`Upgrading mwdb-core to latest version`.
9+
10+
v2.12.0
11+
-------
12+
13+
This release contains major changes in search mechanism and drops usage of Flask-RESTful, which might break plugin
14+
compatibility.
15+
16+
Complete changelog can be found here: `v2.12.0 changelog <https://github.com/CERT-Polska/mwdb-core/releases/tag/v2.12.0>`_.
17+
18+
[Important change] Refactor of search engine
19+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20+
21+
Search engine uses ``@>`` and ``@?`` PostgreSQL operators and can utilize GIN index on JSONB and ARRAY columns. It means that queries like:
22+
23+
- ``file.name:"sample.exe"``
24+
- ``cfg.url:"https://example.com"``
25+
- ``attribute.url:"https://example.com"``
26+
27+
will work much faster. In addition, new search engine comes with various improvements:
28+
29+
- Both inclusive and exclusive ranges are allowed for detatime-columns
30+
- Range boundaries can be reversed and are automatically sorted
31+
- Escape parser is no longer regex-based and should be much more consistent
32+
33+
As search engine uses a bit different approach, some things may work a bit different:
34+
35+
- >=, >, <, <= are regular range operators, so they need to be put outside term
36+
37+
correct form: ``size:>="5kB"``
38+
39+
incorrect form: ``size:">=5kB"``
40+
41+
Complete description of changes can be found here: https://github.com/CERT-Polska/mwdb-core/pull/906
42+
43+
[Important change] Replaced Flask-RESTful with own lightweight implementation
44+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
45+
46+
Flask-RESTful is nice framework for creating REST API Flask services, but it's a bit abandoned which blocks us
47+
from further development and causes issues with newer Flask version. We switched to our own implementation of ``Resource`` classes.
48+
49+
For API users this change is completely transparent, but if you develop your own plugins, you should change imports:
50+
51+
.. code-block:: diff
52+
53+
- from flask_restful import Resource
54+
+ from mwdb.core.service import Resource
55+
56+
Complete description of changes can be found here: https://github.com/CERT-Polska/mwdb-core/pull/916
57+
58+
[Important change] Changes in logging, introduced Prometheus metrics
59+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
60+
61+
We're buried in tons of non-meaningful logs without any option to set the verbosity. Examples of non-meaningful logs:
62+
63+
- information about usage of deprecated endpoints
64+
- 'before_request'/'request' logs which are useful for debugging hanging or slow endpoints, but only for debugging
65+
- threadName, moduleName, lineNo which doesn't carry any useful information that can't be read from the log itself
66+
67+
That's why in v2.12.0 debug verbosity level was introduced and is turned off by default. If you want to turn on
68+
debug logs, you can enable it via ``enable_debug_log=1`` option in configuration.
69+
70+
As a replacement for flooding our disk space with log files, we introduced Prometheus metrics that can be
71+
tracked using Grafana platform. Read more about setup in :ref:`Prometheus metrics`.
72+
73+
v2.11.0
74+
-------
75+
76+
Minor release with small QoL improvement: added forms to upload configs and blobs directly from eb UI.
77+
78+
Complete changelog can be found here: `v2.11.0 changelog <https://github.com/CERT-Polska/mwdb-core/releases/tag/v2.11.0>`_.
79+
980

1081
v2.10.1
1182
-------
@@ -125,7 +196,7 @@ Plugin modules are imported dynamically (using `import() <https://developer.mozi
125196
Check for any runtime errors in DevTools, especially noting messages like ``Plugin ${pluginName} failed to load``.
126197

127198
[Important change] Replaced uWSGI with Gunicorn
128-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
199+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
129200

130201
``certpl/mwdb`` Docker image uses `Gunicorn <https://docs.gunicorn.org/en/stable/index.html>`_ instead of `uWSGI <https://uwsgi-docs.readthedocs.io/en/latest/>`_
131202
for serving Python WSGI application. If you have uWSGI-dependent configuration customized via environment variables, you need to change it

mwdb/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
except IOError:
55
git_revision = ""
66

7-
app_version = "2.11.0"
7+
app_version = "2.12.0"
88
app_build_version = f"{app_version}+{git_revision}" if git_revision else app_version

mwdb/web/package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mwdb/web/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mwdb-web",
3-
"version": "2.11.0",
3+
"version": "2.12.0",
44
"private": true,
55
"scripts": {
66
"dev": "vite",

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88

99
setup(name="mwdb-core",
10-
version="2.11.0",
10+
version="2.12.0",
1111
description="MWDB Core malware database",
1212
long_description=LONG_DESCRIPTION,
1313
author="CERT Polska",

0 commit comments

Comments
 (0)