From bb31c36b82297fb3eb1ed872dde4124d4b6b287e Mon Sep 17 00:00:00 2001 From: psyray <1230954+psyray@users.noreply.github.com> Date: Wed, 24 Jul 2024 22:19:55 +0200 Subject: [PATCH] feat(version): Rework the version number bump --- .gitignore | 1 + docker-compose.dev.yml | 3 --- web/api/views.py | 8 +++----- web/dashboard/templates/dashboard/index.html | 8 ++++---- web/reNgine/context_processors.py | 4 ++++ web/reNgine/settings.py | 7 ++++++- web/reNgine/version.txt | 1 + web/templates/base/_items/top_bar.html | 8 ++++---- web/templates/base/login.html | 2 +- 9 files changed, 24 insertions(+), 18 deletions(-) create mode 100644 web/reNgine/version.txt diff --git a/.gitignore b/.gitignore index c3b0c643b..7c872ac31 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ web/custom_engines* Pipfile* resume.cfg *.txt +!version.txt *.log *.pot *.pyc diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml index 3b5bdbff4..53554e052 100644 --- a/docker-compose.dev.yml +++ b/docker-compose.dev.yml @@ -121,9 +121,6 @@ services: - POSTGRES_PASSWORD=${POSTGRES_PASSWORD} - POSTGRES_PORT=${POSTGRES_PORT} - POSTGRES_HOST=${POSTGRES_HOST} - # THIS IS A MUST FOR CHECKING UPDATE, EVERYTIME A COMMIT IS MERGED INTO - # MASTER, UPDATE THIS!!! MAJOR.MINOR.PATCH https://semver.org/ - - RENGINE_CURRENT_VERSION='2.0.6' volumes: - ./web:/usr/src/app - github_repos:/usr/src/github diff --git a/web/api/views.py b/web/api/views.py index 90b3facbc..4737612cb 100644 --- a/web/api/views.py +++ b/web/api/views.py @@ -20,6 +20,7 @@ from reNgine.celery import app from reNgine.common_func import * from reNgine.definitions import ABORTED_TASK +from reNgine.settings import RENGINE_CURRENT_VERSION from reNgine.tasks import * from reNgine.gpt import GPTAttackSuggestionGenerator from reNgine.utilities import is_safe_path @@ -799,11 +800,8 @@ def get(self, request): # get current version_number # remove quotes from current_version - current_version = ((os.environ['RENGINE_CURRENT_VERSION' - ])[1:] if os.environ['RENGINE_CURRENT_VERSION' - ][0] == 'v' - else os.environ['RENGINE_CURRENT_VERSION']).replace("'", "") - + current_version = (RENGINE_CURRENT_VERSION[1:] if RENGINE_CURRENT_VERSION[0] == 'v' else RENGINE_CURRENT_VERSION).replace("'", "") + # for consistency remove v from both if exists latest_version = re.search(r'v(\d+\.)?(\d+\.)?(\*|\d+)', ((response[0]['name' diff --git a/web/dashboard/templates/dashboard/index.html b/web/dashboard/templates/dashboard/index.html index 3f5f8356d..d4ead887f 100644 --- a/web/dashboard/templates/dashboard/index.html +++ b/web/dashboard/templates/dashboard/index.html @@ -17,7 +17,7 @@ {% endblock custom_js_css_link %} {% block breadcrumb_title %} -reNgine 2.0.6 +reNgine-ng {{ RENGINE_CURRENT_VERSION }} {% endblock breadcrumb_title %} {% block main_content %} @@ -39,7 +39,7 @@

{{domain
- +

Total Subdomains

{{subdomain_count|intcomma}}

@@ -53,7 +53,7 @@

{{subdom
- +

Total Endpoints

{{endpoint_count|intcomma}}

@@ -67,7 +67,7 @@

{{endpoint_count|intcomma}}

- +

Total Vulnerabilities

{{total_vul_count|intcomma}}

diff --git a/web/reNgine/context_processors.py b/web/reNgine/context_processors.py index 61fae7fa3..0173c5809 100644 --- a/web/reNgine/context_processors.py +++ b/web/reNgine/context_processors.py @@ -1,4 +1,5 @@ from dashboard.models import * +from . import settings def projects(request): projects = Project.objects.all() @@ -11,3 +12,6 @@ def projects(request): 'projects': projects, 'current_project': project } + +def version(request): + return {"RENGINE_CURRENT_VERSION": settings.RENGINE_CURRENT_VERSION} diff --git a/web/reNgine/settings.py b/web/reNgine/settings.py index 3c30fd712..82924f23f 100644 --- a/web/reNgine/settings.py +++ b/web/reNgine/settings.py @@ -1,5 +1,6 @@ import mimetypes import os +from pathlib import Path from reNgine.init import first_run from reNgine.utilities import RengineTaskFormatter @@ -18,6 +19,9 @@ RENGINE_RECORD_ENABLED = bool(int(os.environ.get('RENGINE_RECORD_ENABLED', '1'))) RENGINE_RAISE_ON_ERROR = bool(int(os.environ.get('RENGINE_RAISE_ON_ERROR', '0'))) +with open(Path(RENGINE_HOME) / 'reNgine' / 'version.txt', 'r', encoding="utf-8") as f: + RENGINE_CURRENT_VERSION = f.read().strip() + # Debug env vars UI_DEBUG = bool(int(os.environ.get('UI_DEBUG', '0'))) UI_REMOTE_DEBUG = bool(int(os.environ.get('UI_REMOTE_DEBUG', '0'))) @@ -101,7 +105,8 @@ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'reNgine.context_processors.projects' + 'reNgine.context_processors.projects', + 'reNgine.context_processors.version' ], }, }] diff --git a/web/reNgine/version.txt b/web/reNgine/version.txt new file mode 100644 index 000000000..703cec9e2 --- /dev/null +++ b/web/reNgine/version.txt @@ -0,0 +1 @@ +2.0.6 \ No newline at end of file diff --git a/web/templates/base/_items/top_bar.html b/web/templates/base/_items/top_bar.html index 0ef003ece..b1ef300ba 100644 --- a/web/templates/base/_items/top_bar.html +++ b/web/templates/base/_items/top_bar.html @@ -170,18 +170,18 @@
Welcome {{user.get_username}}!
diff --git a/web/templates/base/login.html b/web/templates/base/login.html index 5aabd4df3..52efb5906 100644 --- a/web/templates/base/login.html +++ b/web/templates/base/login.html @@ -58,7 +58,7 @@

Login to reNgine-ng

-

Current release: v2.0.6

+

Current release: v{{ RENGINE_CURRENT_VERSION }}