From a4d784d7748aa7bf15bbfb865309700ca755022b Mon Sep 17 00:00:00 2001 From: Robin Koumis Date: Tue, 12 Nov 2024 17:21:36 -0500 Subject: [PATCH 1/4] Use bump-my-version tool to help manage versioning - Added two makefile targets for bumping the version. --- CHANGELOG.rst | 8 +++++++- Makefile | 9 ++++++++- app/__init__.py | 1 + app/dalton.py | 2 +- app/templates/dalton/about.html | 1 + dalton-agent/.bumpversion.toml | 21 +++++++++++++++++++++ pyproject.toml | 21 +++++++++++++++++++-- 7 files changed, 58 insertions(+), 5 deletions(-) create mode 100644 dalton-agent/.bumpversion.toml diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 9bd6ecd..bc7961c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -149,9 +149,12 @@ Zeek Enhancements (#177) Author: Nikhileswar Reddy -4.0.0 +3.4.0 (2024-11-12) ################## +Version 3.4.x is available initially on the pilot branch, +in a sort of pre-release mode. + * Use pyproject.toml (#184) (#189) * Use ruff format to format the code (#183) (#190) * Use ruff check --fix to make style changes (#183) (#192) @@ -163,3 +166,6 @@ Author: Nikhileswar Reddy * Use ruff to sort and format imports (#207) * Use ruff to detect flake8 bugbears (B) (#209) * Use pre-built zeek images (#181) +* Use bump-my-version to update the version and tag (#197) + * Also, use bump-my-version to update the dalton-agent version + * Also, show the dalton controller version on the About page diff --git a/Makefile b/Makefile index 932e3c7..1d6757f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ PYTEST=$(VENV)/bin/pytest COVERAGE=$(VENV)/bin/coverage RUFF=$(VENV)/bin/ruff ACTIVATE=$(VENV)/bin/activate - +BUMPVERSION=$(VENV)/bin/bump-my-version +BUMPPART ?= patch venv $(VENV): python3 -m venv $(VENV) @@ -30,3 +31,9 @@ fix: $(VENV) hadolint: Dockerfile-dalton Dockerfile-nginx dalton-agent/Dockerfiles/Dockerfile_* docker run -t --rm -v `pwd`:/app -w /app hadolint/hadolint /bin/hadolint $^ + +bumpversion: $(VENV) pyproject.toml + $(BUMPVERSION) bump $(BUMPPART) + +bumpagent: $(VENV) pyproject.toml + $(BUMPVERSION) bump --config-file dalton-agent/.bumpversion.toml $(BUMPPART) diff --git a/app/__init__.py b/app/__init__.py index 9330c4d..68fdba9 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -8,6 +8,7 @@ from app.dalton import dalton_blueprint, ensure_rulesets_exist, setup_dalton_logging from app.flowsynth import flowsynth_blueprint, setup_flowsynth_logging +__version__ = "3.3.6" def create_app(test_config=None): """Create the flask app.""" diff --git a/app/dalton.py b/app/dalton.py index 69ccd00..9d5367e 100644 --- a/app/dalton.py +++ b/app/dalton.py @@ -3071,7 +3071,7 @@ def page_queue_default(): # @login_required() def page_about_default(): """the about/help page""" - return render_template("/dalton/about.html", page="") + return render_template("dalton/about.html", version=app.__version__) ######################################### diff --git a/app/templates/dalton/about.html b/app/templates/dalton/about.html index 807646d..2068583 100644 --- a/app/templates/dalton/about.html +++ b/app/templates/dalton/about.html @@ -3,4 +3,5 @@

About Dalton

Dalton allows pcaps to be run against sundry IDS sensors (e.g. Suricata, Snort) and sensor versions using a defined ruleset and/or bespoke rules.

Official repository and documentation can be found at https://github.com/secureworks/dalton

+

This is Dalton version {{ version }}

{% endblock %} diff --git a/dalton-agent/.bumpversion.toml b/dalton-agent/.bumpversion.toml new file mode 100644 index 0000000..0fc3310 --- /dev/null +++ b/dalton-agent/.bumpversion.toml @@ -0,0 +1,21 @@ +[tool.bumpversion] +current_version = "3.1.1" +parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" +serialize = ["{major}.{minor}.{patch}"] +search = "{current_version}" +replace = "{new_version}" +regex = false +ignore_missing_version = false +ignore_missing_files = false +tag = false +sign_tags = false +allow_dirty = false +commit = true +message = "Bump dalton-agent version: {current_version} → {new_version}" +commit_args = "--no-verify" +setup_hooks = [] +pre_commit_hooks = [] +post_commit_hooks = [] + +[[tool.bumpversion.files]] +filename = "dalton-agent/dalton-agent.py" diff --git a/pyproject.toml b/pyproject.toml index 1dc7330..c594f6f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta" [project] name = "dalton" -version = "4.0.0" description = "Run pcaps against an IDS" +dynamic = ["version"] requires-python = ">=3.10" dependencies = [ "Jinja2==3.0.3", @@ -43,8 +43,9 @@ testing = [ "pytest", ] devtools = [ - "ruff", + "bump-my-version", "coverage", + "ruff", ] [tool.pytest.ini_options] @@ -75,3 +76,19 @@ ignore = ["E501"] [tool.ruff.lint.per-file-ignores] # Defer these fixes to dalton-agent until we have some unit tests "dalton-agent/dalton-agent.py" = ["B"] + +[tool.bumpversion] +current_version = "3.3.6" + +commit = true +allow_dirty = false +message = "Bump version: {current_version} → {new_version}" +commit_args = "--no-verify" + +tag = true +sign_tags = false +tag_name = "v{new_version}" +tag_message = "Bump version: {current_version} → {new_version}" + +[[tool.bumpversion.files]] +filename = "app/__init__.py" From 1612c8202b67349ecd285086670b6956968896b6 Mon Sep 17 00:00:00 2001 From: Robin Koumis Date: Tue, 12 Nov 2024 17:25:34 -0500 Subject: [PATCH 2/4] =?UTF-8?q?Bump=20version:=203.3.6=20=E2=86=92=203.4.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/__init__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 68fdba9..9c2df46 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -8,7 +8,7 @@ from app.dalton import dalton_blueprint, ensure_rulesets_exist, setup_dalton_logging from app.flowsynth import flowsynth_blueprint, setup_flowsynth_logging -__version__ = "3.3.6" +__version__ = "3.4.0" def create_app(test_config=None): """Create the flask app.""" diff --git a/pyproject.toml b/pyproject.toml index c594f6f..2fb51a6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,7 +78,7 @@ ignore = ["E501"] "dalton-agent/dalton-agent.py" = ["B"] [tool.bumpversion] -current_version = "3.3.6" +current_version = "3.4.0" commit = true allow_dirty = false From 42452d60fa1685e97f8b49c1a09c1ddb0a3d7713 Mon Sep 17 00:00:00 2001 From: Robin Koumis Date: Tue, 12 Nov 2024 17:25:47 -0500 Subject: [PATCH 3/4] =?UTF-8?q?Bump=20dalton-agent=20version:=203.1.1=20?= =?UTF-8?q?=E2=86=92=203.1.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dalton-agent/.bumpversion.toml | 2 +- dalton-agent/dalton-agent.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dalton-agent/.bumpversion.toml b/dalton-agent/.bumpversion.toml index 0fc3310..9a4ba28 100644 --- a/dalton-agent/.bumpversion.toml +++ b/dalton-agent/.bumpversion.toml @@ -1,5 +1,5 @@ [tool.bumpversion] -current_version = "3.1.1" +current_version = "3.1.2" parse = "(?P\\d+)\\.(?P\\d+)\\.(?P\\d+)" serialize = ["{major}.{minor}.{patch}"] search = "{current_version}" diff --git a/dalton-agent/dalton-agent.py b/dalton-agent/dalton-agent.py index baa81cd..c33c322 100755 --- a/dalton-agent/dalton-agent.py +++ b/dalton-agent/dalton-agent.py @@ -282,7 +282,7 @@ def hash_file(filenames): # *** Constant Variables *** # ************************** -AGENT_VERSION = "3.1.1" +AGENT_VERSION = "3.1.2" HTTP_HEADERS = {"User-Agent": f"Dalton Agent/{AGENT_VERSION}"} # check options from config file From adf82a186c07a8cc66ec3c2188c0bbef63724bcb Mon Sep 17 00:00:00 2001 From: Robin Koumis Date: Tue, 12 Nov 2024 17:36:05 -0500 Subject: [PATCH 4/4] A couple of issues that the linter did not like --- app/__init__.py | 1 + app/dalton.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/app/__init__.py b/app/__init__.py index 9c2df46..de6ebc3 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -10,6 +10,7 @@ __version__ = "3.4.0" + def create_app(test_config=None): """Create the flask app.""" curdir = os.path.dirname(os.path.abspath(__file__)) diff --git a/app/dalton.py b/app/dalton.py index 9d5367e..f0b436a 100644 --- a/app/dalton.py +++ b/app/dalton.py @@ -3071,6 +3071,9 @@ def page_queue_default(): # @login_required() def page_about_default(): """the about/help page""" + # Need to `import app` here, not at the top of the file. + import app + return render_template("dalton/about.html", version=app.__version__)