Release 0.12.2

This commit is contained in:
wh1te909
2022-04-05 03:44:17 +00:00
12 changed files with 164 additions and 155 deletions

56
.github/workflows/ci-tests.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: Tests CI
on:
push:
branches:
- "*"
pull_request:
branches:
- "*"
jobs:
test:
runs-on: self-hosted
steps:
- uses: actions/checkout@v2
- name: Setup virtual env and install requirements
run: |
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS pipeline'
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS test_pipeline'
sudo -u postgres psql -c 'CREATE DATABASE pipeline'
sudo -u postgres psql -c "SET client_encoding = 'UTF8'" pipeline
pwd
rm -rf /actions-runner/_work/trmm-actions/trmm-actions/api/env
cd api
python3.10 -m venv env
source env/bin/activate
cd tacticalrmm
python --version
SETTINGS_FILE="tacticalrmm/settings.py"
SETUPTOOLS_VER=$(grep "^SETUPTOOLS_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
WHEEL_VER=$(grep "^WHEEL_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
pip install --upgrade pip
pip install setuptools==${SETUPTOOLS_VER} wheel==${WHEEL_VER}
pip install -r requirements.txt -r requirements-test.txt
- name: Run django tests
env:
GHACTIONS: "yes"
run: |
cd api/tacticalrmm
source ../env/bin/activate
coverage run manage.py test -v 2
if [ $? -ne 0 ]; then
exit 1
fi
- name: Codestyle black
run: |
cd api
source env/bin/activate
black --exclude migrations/ --check tacticalrmm
if [ $? -ne 0 ]; then
exit 1
fi

View File

@@ -1,6 +1,6 @@
# Tactical RMM
[![Build Status](https://dev.azure.com/dcparsi/Tactical%20RMM/_apis/build/status/wh1te909.tacticalrmm?branchName=develop)](https://dev.azure.com/dcparsi/Tactical%20RMM/_build/latest?definitionId=4&branchName=develop)
![](https://github.com/amidaware/tacticalrmm/actions/workflows/ci-tests.yml/badge.svg?branch=develop)
[![Coverage Status](https://coveralls.io/repos/github/wh1te909/tacticalrmm/badge.png?branch=develop&kill_cache=1)](https://coveralls.io/github/wh1te909/tacticalrmm?branch=develop)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/python/black)
@@ -28,9 +28,12 @@ Demo database resets every hour. A lot of features are disabled for obvious reas
- Remote software installation via chocolatey
- Software and hardware inventory
## Windows versions supported
## Windows agent versions supported
- Windows 7, 8.1, 10, Server 2008R2, 2012R2, 2016, 2019
- Windows 7, 8.1, 10, 11, Server 2008R2, 2012R2, 2016, 2019, 2022
## Linux agent versions supported
- Any distro with systemd
## Installation / Backup / Restore / Usage

View File

@@ -3,3 +3,4 @@ Werkzeug
django-extensions
isort
types-pytz
django-silk

View File

@@ -1,3 +1,4 @@
coverage==6.3.2
coveralls==3.3.1
model_bakery
coverage
coveralls
model_bakery
black

View File

@@ -17,16 +17,16 @@ LINUX_AGENT_SCRIPT = BASE_DIR / "core" / "agent_linux.sh"
AUTH_USER_MODEL = "accounts.User"
# latest release
TRMM_VERSION = "0.12.1"
TRMM_VERSION = "0.12.2"
# bump this version everytime vue code is changed
# to alert user they need to manually refresh their browser
APP_VER = "0.0.159"
# https://github.com/amidaware/rmmagent
LATEST_AGENT_VER = "2.0.1"
LATEST_AGENT_VER = "2.0.2"
MESH_VER = "0.9.98"
MESH_VER = "1.0.2"
NATS_SERVER_VER = "2.7.4"
@@ -52,6 +52,29 @@ REST_KNOX = {
"MIN_REFRESH_INTERVAL": 600,
}
if "GHACTIONS" in os.environ:
print("-----------------------PIPELINE----------------------------")
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "pipeline",
"USER": "pipeline",
"PASSWORD": "pipeline123456",
"HOST": "127.0.0.1",
"PORT": "",
}
}
SECRET_KEY = "abcdefghijklmnoptravis123456789"
DEBUG = False
ALLOWED_HOSTS = ["api.example.com"]
ADMIN_URL = "abc123456/"
CORS_ORIGIN_WHITELIST = ["https://rmm.example.com"]
MESH_USERNAME = "pipeline"
MESH_SITE = "https://example.com"
MESH_TOKEN_KEY = "bd65e957a1e70c622d32523f61508400d6cd0937001a7ac12042227eba0b9ed625233851a316d4f489f02994145f74537a331415d00047dbbf13d940f556806dffe7a8ce1de216dc49edbad0c1a7399c"
REDIS_HOST = "localhost"
ADMIN_ENABLED = False
try:
from .local_settings import *
except ImportError:
@@ -74,11 +97,34 @@ SPECTACULAR_SETTINGS = {
"AUTHENTICATION_WHITELIST": ["tacticalrmm.auth.APIAuthentication"],
}
if not "AZPIPELINE" in os.environ:
if not DEBUG: # type: ignore
REST_FRAMEWORK.update(
{"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",)}
)
if not DEBUG: # type: ignore
REST_FRAMEWORK.update(
{"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",)}
)
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware", ##
"tacticalrmm.middleware.LogIPMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"tacticalrmm.middleware.AuditMiddleware",
"tacticalrmm.middleware.LinuxMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
if ADMIN_ENABLED: # type: ignore
MIDDLEWARE += ("django.contrib.messages.middleware.MessageMiddleware",)
try:
if DEMO: # type: ignore
MIDDLEWARE += ("tacticalrmm.middleware.DemoMiddleware",)
except:
pass
INSTALLED_APPS = [
"django.contrib.auth",
@@ -107,21 +153,23 @@ INSTALLED_APPS = [
"drf_spectacular",
]
if not "AZPIPELINE" in os.environ:
if DEBUG: # type: ignore
INSTALLED_APPS += ("django_extensions",)
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [(REDIS_HOST, 6379)], # type: ignore
},
if DEBUG: # type: ignore
INSTALLED_APPS += (
"django_extensions",
"silk",
)
MIDDLEWARE.insert(0, "silk.middleware.SilkyMiddleware")
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [(REDIS_HOST, 6379)], # type: ignore
},
}
if "AZPIPELINE" in os.environ:
ADMIN_ENABLED = False
},
}
if ADMIN_ENABLED: # type: ignore
INSTALLED_APPS += (
@@ -130,28 +178,6 @@ if ADMIN_ENABLED: # type: ignore
)
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware", ##
"tacticalrmm.middleware.LogIPMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"tacticalrmm.middleware.AuditMiddleware",
"tacticalrmm.middleware.LinuxMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware",
]
if ADMIN_ENABLED: # type: ignore
MIDDLEWARE += ("django.contrib.messages.middleware.MessageMiddleware",)
try:
if DEMO: # type: ignore
MIDDLEWARE += ("tacticalrmm.middleware.DemoMiddleware",)
except:
pass
ROOT_URLCONF = "tacticalrmm.urls"
@@ -226,38 +252,3 @@ LOGGING = {
"django.request": {"handlers": ["file"], "level": "ERROR", "propagate": True}
},
}
if "AZPIPELINE" in os.environ:
print("PIPELINE")
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"NAME": "pipeline",
"USER": "pipeline",
"PASSWORD": "pipeline123456",
"HOST": "127.0.0.1",
"PORT": "",
}
}
REST_FRAMEWORK = {
"DATETIME_FORMAT": "%b-%d-%Y - %H:%M",
"DEFAULT_PERMISSION_CLASSES": ("rest_framework.permissions.IsAuthenticated",),
"DEFAULT_AUTHENTICATION_CLASSES": (
"knox.auth.TokenAuthentication",
"tacticalrmm.auth.APIAuthentication",
),
"DEFAULT_RENDERER_CLASSES": ("rest_framework.renderers.JSONRenderer",),
}
ALLOWED_HOSTS = ["api.example.com"]
DEBUG = True
SECRET_KEY = "abcdefghijklmnoptravis123456789"
ADMIN_URL = "abc123456/"
SCRIPTS_DIR = os.path.join(Path(BASE_DIR).parents[1], "scripts")
MESH_USERNAME = "pipeline"
MESH_SITE = "https://example.com"
MESH_TOKEN_KEY = "bd65e957a1e70c622d32523f61508400d6cd0937001a7ac12042227eba0b9ed625233851a316d4f489f02994145f74537a331415d00047dbbf13d940f556806dffe7a8ce1de216dc49edbad0c1a7399c"
REDIS_HOST = "localhost"

View File

@@ -43,6 +43,9 @@ if getattr(settings, "ADMIN_ENABLED", False):
urlpatterns += (path(settings.ADMIN_URL, admin.site.urls),)
if getattr(settings, "DEBUG", False):
urlpatterns += [path("silk/", include("silk.urls", namespace="silk"))]
if getattr(settings, "SWAGGER_ENABLED", False):
from drf_spectacular.views import SpectacularAPIView, SpectacularSwaggerView

View File

@@ -161,14 +161,28 @@ def convert_to_iso_duration(string: str) -> str:
def reload_nats():
users = [{"user": "tacticalrmm", "password": settings.SECRET_KEY}]
users = [
{
"user": "tacticalrmm",
"password": settings.SECRET_KEY,
"permissions": {"publish": ">", "subscribe": ">"},
}
]
agents = Agent.objects.prefetch_related("user").only(
"pk", "agent_id"
) # type:ignore
for agent in agents:
try:
users.append(
{"user": agent.agent_id, "password": agent.user.auth_token.key}
{
"user": agent.agent_id,
"password": agent.user.auth_token.key,
"permissions": {
"publish": {"allow": agent.agent_id},
"subscribe": {"allow": agent.agent_id},
"allow_responses": True,
},
}
)
except:
DebugLog.critical(

View File

@@ -1,65 +0,0 @@
trigger:
- master
- develop
jobs:
- job: setup_env
displayName: "Setup"
strategy:
matrix:
Debian10:
AGENT_NAME: "az-pipeline-fran"
pool:
name: linux-vms
demands:
- agent.name -equals $(AGENT_NAME)
steps:
- script: |
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS pipeline'
sudo -u postgres psql -c 'DROP DATABASE IF EXISTS test_pipeline'
sudo -u postgres psql -c 'CREATE DATABASE pipeline'
sudo -u postgres psql -c "SET client_encoding = 'UTF8'" pipeline
SETTINGS_FILE="/myagent/_work/1/s/api/tacticalrmm/tacticalrmm/settings.py"
rm -rf /myagent/_work/1/s/api/env
cd /myagent/_work/1/s/api
python3.10 -m venv env
source env/bin/activate
cd /myagent/_work/1/s/api/tacticalrmm
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --upgrade pip
SETUPTOOLS_VER=$(grep "^SETUPTOOLS_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
WHEEL_VER=$(grep "^WHEEL_VER" "$SETTINGS_FILE" | awk -F'[= "]' '{print $5}')
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org setuptools==${SETUPTOOLS_VER} wheel==${WHEEL_VER}
pip install --trusted-host pypi.org --trusted-host pypi.python.org --trusted-host files.pythonhosted.org -r requirements.txt -r requirements-test.txt -r requirements-dev.txt
displayName: "Install Python Dependencies"
- script: |
cd /myagent/_work/1/s/api
source env/bin/activate
cd /myagent/_work/1/s/api/tacticalrmm
coverage run manage.py test -v 2
if [ $? -ne 0 ]; then
exit 1
fi
displayName: "Run django tests"
- script: |
cd /myagent/_work/1/s/api
source env/bin/activate
black --exclude migrations/ --check tacticalrmm
if [ $? -ne 0 ]; then
exit 1
fi
displayName: "Codestyle black"
- script: |
cd /myagent/_work/1/s/api
source env/bin/activate
cd /myagent/_work/1/s/api/tacticalrmm
export CIRCLE_BRANCH=$BUILD_SOURCEBRANCH
coveralls
displayName: "coveralls"
env:
CIRCLECI: 1
CIRCLE_BUILD_NUM: $(Build.BuildNumber)

View File

@@ -129,11 +129,13 @@ processes = ${uwsgiprocs}
threads = ${uwsgiprocs}
enable-threads = true
socket = 0.0.0.0:8080
harakiri = 300
chmod-socket = 660
buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 2000
max-requests = 500
disable-logging = true
EOF
)"

View File

@@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="59"
SCRIPT_VERSION="60"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/install.sh'
sudo apt install -y curl wget dirmngr gnupg lsb-release
@@ -406,6 +406,7 @@ buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
disable-logging = true
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini

View File

@@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="34"
SCRIPT_VERSION="35"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/restore.sh'
sudo apt update
@@ -276,6 +276,7 @@ buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
disable-logging = true
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini

View File

@@ -1,6 +1,6 @@
#!/bin/bash
SCRIPT_VERSION="131"
SCRIPT_VERSION="132"
SCRIPT_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/update.sh'
LATEST_SETTINGS_URL='https://raw.githubusercontent.com/amidaware/tacticalrmm/master/api/tacticalrmm/tacticalrmm/settings.py'
YELLOW='\033[1;33m'
@@ -144,6 +144,7 @@ buffer-size = 65535
vacuum = true
die-on-term = true
max-requests = 500
disable-logging = true
EOF
)"
echo "${uwsgini}" > /rmm/api/tacticalrmm/app.ini