Skip to content

Commit

Permalink
Release 0.9.1
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1te909 committed Nov 7, 2021
2 parents fb54d4b + b84d4a9 commit 62ec8c8
Show file tree
Hide file tree
Showing 16 changed files with 357 additions and 28 deletions.
2 changes: 1 addition & 1 deletion api/tacticalrmm/checks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,4 +679,4 @@ class CheckHistory(models.Model):
results = models.JSONField(null=True, blank=True)

def __str__(self):
return self.x
return str(self.x)
32 changes: 32 additions & 0 deletions api/tacticalrmm/clients/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -839,3 +839,35 @@ def test_delete_deployments_permissions(self, delete):

self.check_authorized("delete", url)
self.check_not_authorized("delete", unauthorized_url)

def test_restricted_user_creating_clients(self):
from accounts.models import User

# when a user that is limited to a specific subset of clients creates a client. It should allow access to that client
client = baker.make("clients.Client")
user = self.create_user_with_roles(["can_manage_clients"])
self.client.force_authenticate(user=user) # type: ignore
user.role.can_view_clients.set([client])

data = {"client": {"name": "New Client"}, "site": {"name": "New Site"}}

self.client.post(f"{base_url}/", data, format="json")

# make sure two clients are allowed now
self.assertEqual(User.objects.get(id=user.id).role.can_view_clients.count(), 2)

def test_restricted_user_creating_sites(self):
from accounts.models import User

# when a user that is limited to a specific subset of clients creates a client. It should allow access to that client
site = baker.make("clients.Site")
user = self.create_user_with_roles(["can_manage_sites"])
self.client.force_authenticate(user=user) # type: ignore
user.role.can_view_sites.set([site])

data = {"site": {"client": site.client.id, "name": "New Site"}}

self.client.post(f"{base_url}/sites/", data, format="json")

# make sure two sites are allowed now
self.assertEqual(User.objects.get(id=user.id).role.can_view_sites.count(), 2)
8 changes: 8 additions & 0 deletions api/tacticalrmm/clients/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def post(self, request):
serializer.is_valid(raise_exception=True)
serializer.save()

# add user to allowed clients in role if restricted user created the client
if request.user.role and request.user.role.can_view_clients.exists():
request.user.role.can_view_clients.add(client)

return Response(f"{client.name} was added")


Expand Down Expand Up @@ -167,6 +171,10 @@ def post(self, request):
serializer.is_valid(raise_exception=True)
serializer.save()

# add user to allowed sites in role if restricted user created the client
if request.user.role and request.user.role.can_view_sites.exists():
request.user.role.can_view_sites.add(site)

return Response(f"Site {site.name} was added!")


Expand Down
13 changes: 8 additions & 5 deletions api/tacticalrmm/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,10 @@ def email_is_configured(self):
return False

def send_mail(self, subject, body, alert_template=None, test=False):

if not alert_template or not self.email_is_configured:
if test:
return "Missing required fields (need at least 1 recipient)"
if test and not self.email_is_configured:
return "There needs to be at least one email recipient configured"
# return since email must be configured to continue
elif not self.email_is_configured:
return False

# override email from if alert_template is passed and is set
Expand All @@ -170,6 +170,9 @@ def send_mail(self, subject, body, alert_template=None, test=False):
else:
email_recipients = ", ".join(self.email_alert_recipients)

if not email_recipients:
return "There needs to be at least one email recipient configured"

try:
msg = EmailMessage()
msg["Subject"] = subject
Expand Down Expand Up @@ -197,7 +200,7 @@ def send_mail(self, subject, body, alert_template=None, test=False):
return True

def send_sms(self, body, alert_template=None, test=False):
if not alert_template or not self.sms_is_configured:
if not self.sms_is_configured:
return "Sms alerting is not setup correctly."

# override email recipients if alert_template is passed and is set
Expand Down
3 changes: 2 additions & 1 deletion api/tacticalrmm/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def put(self, request, format=None):


class GetEditCoreSettings(APIView):
@permission_classes([IsAuthenticated, CoreSettingsPerms])
permission_classes = [IsAuthenticated, CoreSettingsPerms]

def get(self, request):
settings = CoreSettings.objects.first()
return Response(CoreSettingsSerializer(settings).data)
Expand Down
4 changes: 2 additions & 2 deletions api/tacticalrmm/tacticalrmm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
AUTH_USER_MODEL = "accounts.User"

# latest release
TRMM_VERSION = "0.9.0"
TRMM_VERSION = "0.9.1"

# bump this version everytime vue code is changed
# to alert user they need to manually refresh their browser
APP_VER = "0.0.148"
APP_VER = "0.0.149"

# https://github.com/wh1te909/rmmagent
LATEST_AGENT_VER = "1.6.2"
Expand Down
13 changes: 13 additions & 0 deletions scripts_wip/Win_User_Logon_Details.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Takes a long time to run. Probably needs at 5mins.
# Want to add logon events too

$events = Get-WinEvent -Path C:\Windows\System32\winevt\Logs\Security.evtx | where { ($_.Id -eq 4624 -and $_.properties[8].value -eq 10) -or ($_.Id -eq 4634 -and $_.properties[4].value -eq 2) }

foreach ($event in $events) {

# userid will vary depending on event type:
if ($event.Id -eq 4624) { $userid = $event.properties[5].value }
if ($event.Id -eq 4634) { $userid = $event.properties[1].value }

$event | Select TimeCReated, TaskDisplayName, Machinename, @{"Name" = "UserID"; "Expression" = { $userid } }
}
35 changes: 31 additions & 4 deletions scripts_wip/Win_Veeam_Backup_Script_Notification.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,40 @@
# Untested probably doesn't work

# Create RMMAlerts when a backup fails
if (Test-Path -Path "C:\Program Files\Veeam\Endpoint Backup") {
Write-Output "Veeam Installed"

$event = Get-EventLog "Veeam Backup" -newest 1 -After (Get-Date).AddDays(-1) | Where-Object { $_.EventID -eq 0 }

if ($event.entrytype -eq "Error") {
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
}
else {
write-host "No errors here"
}

}
else {
Write-Output "Veeam not Installed
exit 0"
}


Exit $LASTEXITCODE

$event = Get-EventLog "Veeam Backup" -newest 1 -After (Get-Date).AddDays(-1) | Where-Object { $_.EventID -eq 0 }

if ($event.entrytype -eq "Error") {
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
}
else {
write-host "No errors here"
write-host "No errors here"
}
else {
Write-Output "Veeam not Installed
exit 0"
}


Exit $LASTEXITCODE
18 changes: 18 additions & 0 deletions scripts_wip/Win_Veeam_Backup_Script_Notification2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Untested probably doesn't work

$event = Get-EventLog "Veeam Backup" -newest 1 -After (Get-Date).AddDays(-1) | Where-Object { $_.EventID -eq 0 }

if ($event.entrytype -eq "Error") {
write-host "We got an event that is an error from Veeam Backup!"
Rmm-Alert -Category "veeam_backup_failed" -Body "Veeam Backup Failed on $(%computername%) - message: $($event.message)"
}
else {
write-host "No errors here"
}
else {
Write-Output "Veeam not Installed
exit 0"
}


Exit $LASTEXITCODE
Loading

0 comments on commit 62ec8c8

Please sign in to comment.