From aff96a45c626c33b7ab8e4db4527ad60c6ade02a Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Wed, 1 Nov 2023 23:31:26 +0000 Subject: [PATCH 01/10] back to dev [skip ci] --- api/tacticalrmm/tacticalrmm/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index 86641be0c2..eb2b0cc381 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -20,7 +20,7 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.17.0" +TRMM_VERSION = "0.17.1-dev" # https://github.com/amidaware/tacticalrmm-web WEB_VERSION = "0.101.34" From 2b316aeae9cabb0d4e5e664310170e196cb7f01e Mon Sep 17 00:00:00 2001 From: sadnub Date: Thu, 2 Nov 2023 16:37:23 -0400 Subject: [PATCH 02/10] expose datetime and re modules to template --- api/tacticalrmm/ee/reporting/utils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index c709be1c55..13c073ccca 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -21,6 +21,8 @@ from .markdown.config import Markdown from .models import ReportAsset, ReportDataQuery, ReportHTMLTemplate, ReportTemplate +import datetime + # regex for db data replacement # will return 3 groups of matches in a tuple when uses with re.findall # i.e. - {{client.name}}, client.name, client @@ -59,6 +61,10 @@ def db_template_loader(template_name: str) -> Optional[str]: comment_end_string="=}", ) +# expose datetime and re to the template +env.globals["datetime"] = datetime +env.globals["re"] = re + def generate_pdf(*, html: str, css: str = "") -> bytes: font_config = FontConfiguration() From ac74d2b7c2042b971ea2dce002710c82e80fdd1d Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 2 Nov 2023 21:25:24 +0000 Subject: [PATCH 03/10] remove debug stuff --- install.sh | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index 8b05f7ce3c..e416060f0a 100644 --- a/install.sh +++ b/install.sh @@ -1,24 +1,7 @@ #!/usr/bin/env bash -REPO=amidaware -BRANCH=master -while [[ $# -gt 0 ]]; do - case $1 in - -r | --repo) - REPO="$2" - shift # past argument - shift # past value - ;; - -b | --branch) - BRANCH="$2" - shift # past argument - shift # past value - ;; - esac -done - -SCRIPT_VERSION="79" -SCRIPT_URL="https://raw.githubusercontent.com/${REPO}/tacticalrmm/${BRANCH}/install.sh" +SCRIPT_VERSION="80" +SCRIPT_URL="https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh" sudo apt install -y curl wget dirmngr gnupg lsb-release ca-certificates @@ -338,11 +321,11 @@ sudo mkdir /rmm sudo chown ${USER}:${USER} /rmm sudo mkdir -p /var/log/celery sudo chown ${USER}:${USER} /var/log/celery -git clone https://github.com/${REPO}/tacticalrmm.git /rmm/ +git clone https://github.com/amidaware/tacticalrmm.git /rmm/ cd /rmm git config user.email "admin@example.com" git config user.name "Bob" -git checkout ${BRANCH} +git checkout master sudo mkdir -p ${SCRIPTS_DIR} sudo chown ${USER}:${USER} ${SCRIPTS_DIR} From 8aaa27350d7a91ca0494a22378d00aa3d0e01414 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 3 Nov 2023 16:22:11 +0000 Subject: [PATCH 04/10] expose ZoneInfo to template --- api/tacticalrmm/ee/reporting/utils.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index 13c073ccca..dd4a595758 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -4,25 +4,26 @@ For details, see: https://license.tacticalrmm.com/ee """ +import datetime import json import re from enum import Enum from typing import Any, Dict, List, Literal, Optional, Tuple, Type, Union, cast +from zoneinfo import ZoneInfo import yaml from django.apps import apps from jinja2 import Environment, FunctionLoader from rest_framework.serializers import ValidationError -from tacticalrmm.utils import get_db_value from weasyprint import CSS, HTML from weasyprint.text.fonts import FontConfiguration +from tacticalrmm.utils import get_db_value + from .constants import REPORTING_MODELS from .markdown.config import Markdown from .models import ReportAsset, ReportDataQuery, ReportHTMLTemplate, ReportTemplate -import datetime - # regex for db data replacement # will return 3 groups of matches in a tuple when uses with re.findall # i.e. - {{client.name}}, client.name, client @@ -63,6 +64,7 @@ def db_template_loader(template_name: str) -> Optional[str]: # expose datetime and re to the template env.globals["datetime"] = datetime +env.globals["ZoneInfo"] = ZoneInfo env.globals["re"] = re From a5259baab0b4d6bffb4bfdb9982d9723259ba9b8 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 3 Nov 2023 16:58:43 +0000 Subject: [PATCH 05/10] start adding support for custom jinja filters --- api/tacticalrmm/ee/reporting/custom_filters.py | 5 +++++ api/tacticalrmm/ee/reporting/utils.py | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 api/tacticalrmm/ee/reporting/custom_filters.py diff --git a/api/tacticalrmm/ee/reporting/custom_filters.py b/api/tacticalrmm/ee/reporting/custom_filters.py new file mode 100644 index 0000000000..2e17c81f51 --- /dev/null +++ b/api/tacticalrmm/ee/reporting/custom_filters.py @@ -0,0 +1,5 @@ +from zoneinfo import ZoneInfo + + +def as_tz(date_obj, tz, format="%b %d, %I:%M %p"): + return date_obj.astimezone(ZoneInfo(tz)).strftime(format) diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index dd4a595758..db4efdf1b8 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -21,6 +21,7 @@ from tacticalrmm.utils import get_db_value from .constants import REPORTING_MODELS +from .custom_filters import as_tz from .markdown.config import Markdown from .models import ReportAsset, ReportDataQuery, ReportHTMLTemplate, ReportTemplate @@ -66,6 +67,7 @@ def db_template_loader(template_name: str) -> Optional[str]: env.globals["datetime"] = datetime env.globals["ZoneInfo"] = ZoneInfo env.globals["re"] = re +env.filters["as_tz"] = as_tz def generate_pdf(*, html: str, css: str = "") -> bytes: From 931069458d4913bc2da6c1cb55380f19debb4dee Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 3 Nov 2023 17:17:54 +0000 Subject: [PATCH 06/10] add custom filter for local_ips and rework imports --- .../ee/reporting/custom_filters.py | 23 +++++++++++++++++++ api/tacticalrmm/ee/reporting/utils.py | 21 ++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/api/tacticalrmm/ee/reporting/custom_filters.py b/api/tacticalrmm/ee/reporting/custom_filters.py index 2e17c81f51..5ac83e9789 100644 --- a/api/tacticalrmm/ee/reporting/custom_filters.py +++ b/api/tacticalrmm/ee/reporting/custom_filters.py @@ -1,5 +1,28 @@ +from contextlib import suppress from zoneinfo import ZoneInfo +import validators + def as_tz(date_obj, tz, format="%b %d, %I:%M %p"): return date_obj.astimezone(ZoneInfo(tz)).strftime(format) + + +def local_ips(wmi_detail): + ret = [] + with suppress(Exception): + ips = wmi_detail["network_config"] + for i in ips: + try: + addr = [x["IPAddress"] for x in i if "IPAddress" in x][0] + except: + continue + + if addr is None: + continue + + for ip in addr: + if validators.ipv4(ip): + ret.append(ip) + + return ret diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index db4efdf1b8..bbc7997b8f 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -21,7 +21,7 @@ from tacticalrmm.utils import get_db_value from .constants import REPORTING_MODELS -from .custom_filters import as_tz +from .custom_filters import as_tz, local_ips from .markdown.config import Markdown from .models import ReportAsset, ReportDataQuery, ReportHTMLTemplate, ReportTemplate @@ -63,11 +63,20 @@ def db_template_loader(template_name: str) -> Optional[str]: comment_end_string="=}", ) -# expose datetime and re to the template -env.globals["datetime"] = datetime -env.globals["ZoneInfo"] = ZoneInfo -env.globals["re"] = re -env.filters["as_tz"] = as_tz + +custom_globals = { + "datetime": datetime, + "ZoneInfo": ZoneInfo, + "re": re, +} + +custom_filters = { + "as_tz": as_tz, + "local_ips": local_ips, +} + +env.globals.update(custom_globals) +env.filters.update(custom_filters) def generate_pdf(*, html: str, css: str = "") -> bytes: From a69f14f504000ff8643866583a15218292b72522 Mon Sep 17 00:00:00 2001 From: sadnub Date: Fri, 3 Nov 2023 15:49:10 -0400 Subject: [PATCH 07/10] add loop controls and expression extensions to jinja --- api/tacticalrmm/ee/reporting/utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/api/tacticalrmm/ee/reporting/utils.py b/api/tacticalrmm/ee/reporting/utils.py index bbc7997b8f..36449acd5a 100644 --- a/api/tacticalrmm/ee/reporting/utils.py +++ b/api/tacticalrmm/ee/reporting/utils.py @@ -61,6 +61,7 @@ def db_template_loader(template_name: str) -> Optional[str]: loader=FunctionLoader(db_template_loader), comment_start_string="{=", comment_end_string="=}", + extensions=["jinja2.ext.do", "jinja2.ext.loopcontrols"], ) From 7e1fc32a1c35ea4b38594ead8edb3a2b6c57bf1a Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 7 Nov 2023 17:17:37 +0000 Subject: [PATCH 08/10] forgot to bump version of backup script last update --- backup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backup.sh b/backup.sh index 7b58026669..dc27cfad7b 100755 --- a/backup.sh +++ b/backup.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -SCRIPT_VERSION="30" +SCRIPT_VERSION="31" GREEN='\033[0;32m' YELLOW='\033[1;33m' From dce4f1a5aef2340a46312ac7283493613e5c9858 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 7 Nov 2023 17:19:23 +0000 Subject: [PATCH 09/10] update reqs --- api/tacticalrmm/requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/requirements.txt b/api/tacticalrmm/requirements.txt index e8ff8a4b09..8796e7209d 100644 --- a/api/tacticalrmm/requirements.txt +++ b/api/tacticalrmm/requirements.txt @@ -6,7 +6,7 @@ cffi==1.15.1 channels==4.0.0 channels_redis==4.1.0 cryptography==41.0.5 -Django==4.2.6 +Django==4.2.7 django-cors-headers==4.3.0 django-filter==23.3 django-ipware==5.0.0 @@ -41,7 +41,7 @@ zipp==3.17.0 pandas==2.1.2 kaleido==0.2.1 jinja2==3.1.2 -markdown==3.5 +markdown==3.5.1 plotly==5.18.0 weasyprint==60.1 ocxsect==0.1.5 \ No newline at end of file From 5fed81c27b94f14984e9a966504606ffd58e2529 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Tue, 7 Nov 2023 17:19:35 +0000 Subject: [PATCH 10/10] bump versions --- api/tacticalrmm/tacticalrmm/settings.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/tacticalrmm/tacticalrmm/settings.py b/api/tacticalrmm/tacticalrmm/settings.py index eb2b0cc381..e77cdcf3db 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -20,14 +20,14 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.17.1-dev" +TRMM_VERSION = "0.17.1" # https://github.com/amidaware/tacticalrmm-web -WEB_VERSION = "0.101.34" +WEB_VERSION = "0.101.35" # bump this version everytime vue code is changed # to alert user they need to manually refresh their browser -APP_VER = "0.0.186" +APP_VER = "0.0.187" # https://github.com/amidaware/rmmagent LATEST_AGENT_VER = "2.5.0"