From 06b974c8a4561ed452004096ef0e635fba2a56e3 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 28 Mar 2024 04:18:01 +0000 Subject: [PATCH 01/10] back to dev --- 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 84652c00aa..6299c6a2ae 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -21,7 +21,7 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.18.0" +TRMM_VERSION = "0.18.1-dev" # https://github.com/amidaware/tacticalrmm-web WEB_VERSION = "0.101.43" From 7a20be4aff720271db261936bcb85ad9b6c525a4 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 28 Mar 2024 04:18:25 +0000 Subject: [PATCH 02/10] fix for mesh sync if trmm username is an email --- api/tacticalrmm/core/tasks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/api/tacticalrmm/core/tasks.py b/api/tacticalrmm/core/tasks.py index b627157692..e513ccf12e 100644 --- a/api/tacticalrmm/core/tasks.py +++ b/api/tacticalrmm/core/tasks.py @@ -444,7 +444,8 @@ def sync_mesh_perms_task(self): # make sure that doesn't happen by making a random email rand_str1 = make_random_password(len=6) rand_str2 = make_random_password(len=5) - email = f"{user.username}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local" + email_prefix = lambda s: "".join(filter(str.isalnum, s)) + email = f"{email_prefix(user.username)}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local" mesh_users_dict[user.mesh_user_id] = { "_id": user.mesh_user_id, "username": user.mesh_username, From a468faad20eeb21b8b2dd7be618fe2d7f00fb17d Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 28 Mar 2024 04:30:31 +0000 Subject: [PATCH 03/10] fix lint --- api/tacticalrmm/.flake8 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tacticalrmm/.flake8 b/api/tacticalrmm/.flake8 index 3f1049b11f..0e6ff58e89 100644 --- a/api/tacticalrmm/.flake8 +++ b/api/tacticalrmm/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E501,W503,E722,E203 +ignore = E501,W503,E722,E203,E731 exclude = .mypy* .pytest* From 10ca38f91ddc5477d69eccafe432d3c3e4892db8 Mon Sep 17 00:00:00 2001 From: silversword411 Date: Thu, 28 Mar 2024 02:24:18 -0400 Subject: [PATCH 04/10] Tweaking bug report template --- .github/ISSUE_TEMPLATE/bug_report.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index b48323236a..7e73f1c4d3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -14,11 +14,12 @@ assignees: '' **Installation Method:** - [ ] Standard + - [ ] Standard with `--insecure` flag at install - [ ] Docker **Agent Info (please complete the following information):** - Agent version (as shown in the 'Summary' tab of the agent from web UI): -- Agent OS: [e.g. Win 10 v2004, Server 2012 R2] +- Agent OS: [e.g. Win 10 v2004, Server 2016] **Describe the bug** A clear and concise description of what the bug is. From bda8555190ca22c4b9490e4e2303349fe6e1830f Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 28 Mar 2024 07:32:54 +0000 Subject: [PATCH 05/10] remove lambda --- api/tacticalrmm/.flake8 | 2 +- api/tacticalrmm/core/tasks.py | 7 ++++--- api/tacticalrmm/core/utils.py | 4 ++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/api/tacticalrmm/.flake8 b/api/tacticalrmm/.flake8 index 0e6ff58e89..3f1049b11f 100644 --- a/api/tacticalrmm/.flake8 +++ b/api/tacticalrmm/.flake8 @@ -1,5 +1,5 @@ [flake8] -ignore = E501,W503,E722,E203,E731 +ignore = E501,W503,E722,E203 exclude = .mypy* .pytest* diff --git a/api/tacticalrmm/core/tasks.py b/api/tacticalrmm/core/tasks.py index e513ccf12e..503e29844e 100644 --- a/api/tacticalrmm/core/tasks.py +++ b/api/tacticalrmm/core/tasks.py @@ -30,7 +30,7 @@ transform_trmm, ) from core.models import CoreSettings -from core.utils import get_core_settings, get_mesh_ws_url +from core.utils import get_core_settings, get_mesh_ws_url, make_alpha_numeric from logs.models import PendingAction from logs.tasks import prune_audit_log, prune_debug_log from tacticalrmm.celery import app @@ -444,8 +444,9 @@ def sync_mesh_perms_task(self): # make sure that doesn't happen by making a random email rand_str1 = make_random_password(len=6) rand_str2 = make_random_password(len=5) - email_prefix = lambda s: "".join(filter(str.isalnum, s)) - email = f"{email_prefix(user.username)}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local" + # for trmm users whos usernames are emails + email_prefix = make_alpha_numeric(user.username) + email = f"{email_prefix}.{rand_str1}@tacticalrmm-do-not-change-{rand_str2}.local" mesh_users_dict[user.mesh_user_id] = { "_id": user.mesh_user_id, "username": user.mesh_username, diff --git a/api/tacticalrmm/core/utils.py b/api/tacticalrmm/core/utils.py index 23eed4a95f..a162f15fcd 100644 --- a/api/tacticalrmm/core/utils.py +++ b/api/tacticalrmm/core/utils.py @@ -205,3 +205,7 @@ def get_meshagent_url( } return base + "/meshagents?" + urllib.parse.urlencode(params) + + +def make_alpha_numeric(s: str): + return "".join(filter(str.isalnum, s)) From b4a05160df47d3becd515c36b3452465ef8bcc1b Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Thu, 28 Mar 2024 23:43:18 +0000 Subject: [PATCH 06/10] skip if no mesh node id #1814 --- api/tacticalrmm/core/tasks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/tacticalrmm/core/tasks.py b/api/tacticalrmm/core/tasks.py index 503e29844e..9919a77fb9 100644 --- a/api/tacticalrmm/core/tasks.py +++ b/api/tacticalrmm/core/tasks.py @@ -456,6 +456,8 @@ def sync_mesh_perms_task(self): new_trmm_agents = [] for agent in Agent.objects.defer(*AGENT_DEFER): + if not agent.mesh_node_id: + continue agent_dict = { "node_id": f"node//{agent.hex_mesh_node_id}", "hostname": agent.hostname, From a0ee7a59eb00012b8e070ac76445ca34424a65a6 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 29 Mar 2024 08:36:03 +0000 Subject: [PATCH 07/10] remove old funcs --- api/tacticalrmm/core/mesh_utils.py | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/api/tacticalrmm/core/mesh_utils.py b/api/tacticalrmm/core/mesh_utils.py index a6083fbb0b..9f715b8cea 100644 --- a/api/tacticalrmm/core/mesh_utils.py +++ b/api/tacticalrmm/core/mesh_utils.py @@ -172,23 +172,3 @@ def delete_user_from_mesh(self, *, mesh_user_id: str) -> None: "userid": mesh_user_id, } self.mesh_action(payload=payload, wait=False) - - def add_agent_to_user(self, *, user_id: str, node_id: str) -> None: - payload = { - "action": "adddeviceuser", - "nodeid": node_id, - "userids": [user_id], - "rights": 72, - "remove": False, - } - self.mesh_action(payload=payload, wait=False) - - def remove_agent_from_user(self, *, user_id: str, node_id: str) -> None: - payload = { - "action": "adddeviceuser", - "nodeid": node_id, - "userids": [user_id], - "rights": 0, - "remove": True, - } - self.mesh_action(payload=payload, wait=False) From e4c5a4e886ab6d99d964b7c9f00a3701889ea2af Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 29 Mar 2024 08:39:18 +0000 Subject: [PATCH 08/10] fix rights --- api/tacticalrmm/core/mesh_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/tacticalrmm/core/mesh_utils.py b/api/tacticalrmm/core/mesh_utils.py index 9f715b8cea..ee6b2ad982 100644 --- a/api/tacticalrmm/core/mesh_utils.py +++ b/api/tacticalrmm/core/mesh_utils.py @@ -128,7 +128,7 @@ def add_users_to_node(self, *, node_id: str, user_ids: list[str]): "action": "adddeviceuser", "nodeid": node_id, "usernames": [s.replace("user//", "") for s in user_ids], - "rights": 72, + "rights": 3563736, "remove": False, } self.mesh_action(payload=payload, wait=False) From 04b3fc54b0d110fbc3da3bc18cdd0ca658ea06a5 Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 29 Mar 2024 20:10:35 +0000 Subject: [PATCH 09/10] add nonalpha chars to mesh password #1814 --- api/tacticalrmm/core/mesh_utils.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/api/tacticalrmm/core/mesh_utils.py b/api/tacticalrmm/core/mesh_utils.py index ee6b2ad982..98f7280c39 100644 --- a/api/tacticalrmm/core/mesh_utils.py +++ b/api/tacticalrmm/core/mesh_utils.py @@ -1,6 +1,8 @@ import asyncio import json import re +import secrets +import string import traceback from typing import TYPE_CHECKING, Any @@ -8,7 +10,6 @@ from accounts.utils import is_superuser from tacticalrmm.constants import TRMM_WS_MAX_SIZE -from tacticalrmm.helpers import make_random_password from tacticalrmm.logger import logger if TYPE_CHECKING: @@ -40,6 +41,14 @@ def has_mesh_perms(*, user: "User") -> bool: return user.role and getattr(user.role, "can_use_mesh") +def make_mesh_password() -> str: + alpha = string.ascii_letters + string.digits + nonalpha = "!@#$" + passwd = [secrets.choice(alpha) for _ in range(29)] + [secrets.choice(nonalpha)] + secrets.SystemRandom().shuffle(passwd) + return "".join(passwd) + + def transform_trmm(obj): ret = [] try: @@ -156,7 +165,7 @@ def add_user_to_mesh(self, *, user_info: dict[str, Any]) -> None: "action": "adduser", "username": user_info["username"], "email": user_info["email"], - "pass": make_random_password(len=30), + "pass": make_mesh_password(), "resetNextLogin": False, "randomPassword": False, "removeEvents": False, From 4aa413e6979757660a021d4e4909f15da9c57ada Mon Sep 17 00:00:00 2001 From: wh1te909 Date: Fri, 29 Mar 2024 21:07:33 +0000 Subject: [PATCH 10/10] bump version --- 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 6299c6a2ae..cbf211d8f6 100644 --- a/api/tacticalrmm/tacticalrmm/settings.py +++ b/api/tacticalrmm/tacticalrmm/settings.py @@ -21,7 +21,7 @@ AUTH_USER_MODEL = "accounts.User" # latest release -TRMM_VERSION = "0.18.1-dev" +TRMM_VERSION = "0.18.1" # https://github.com/amidaware/tacticalrmm-web WEB_VERSION = "0.101.43"