django-restit 4.2.164__py3-none-any.whl → 4.2.165__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- account/models/device.py +7 -4
- {django_restit-4.2.164.dist-info → django_restit-4.2.165.dist-info}/METADATA +1 -1
- {django_restit-4.2.164.dist-info → django_restit-4.2.165.dist-info}/RECORD +9 -8
- incident/migrations/0016_rule_notify_template.py +18 -0
- incident/models/incident.py +24 -3
- incident/models/rules.py +1 -0
- rest/__init__.py +1 -1
- {django_restit-4.2.164.dist-info → django_restit-4.2.165.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.164.dist-info → django_restit-4.2.165.dist-info}/WHEEL +0 -0
account/models/device.py
CHANGED
@@ -6,6 +6,8 @@ from rest import settings
|
|
6
6
|
from objict import objict
|
7
7
|
from datetime import datetime
|
8
8
|
|
9
|
+
from rest import helpers as rh
|
10
|
+
|
9
11
|
CM_BACKENDS = objict()
|
10
12
|
DEVICE_USE_BUID = settings.get("DEVICE_USE_BUID", False)
|
11
13
|
|
@@ -85,8 +87,9 @@ class MemberDevice(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
85
87
|
md.state = 1
|
86
88
|
md.touch(request.ip)
|
87
89
|
metadata = request.DATA.get("device_metadata", None)
|
88
|
-
|
89
|
-
|
90
|
+
rh.debug("md.metadata", metadata)
|
91
|
+
if metadata is not None:
|
92
|
+
md.setProperty("device", metadata)
|
90
93
|
return md
|
91
94
|
md = MemberDevice(
|
92
95
|
uuid=device_id, buid=buid,
|
@@ -100,8 +103,8 @@ class MemberDevice(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
100
103
|
md.save()
|
101
104
|
md.setProperty("user_agent", request.META.get('HTTP_USER_AGENT', ''))
|
102
105
|
metadata = request.DATA.get("device_metadata", None)
|
103
|
-
if
|
104
|
-
md.
|
106
|
+
if metadata is not None:
|
107
|
+
md.setProperty("device", metadata)
|
105
108
|
return md
|
106
109
|
|
107
110
|
@classmethod
|
@@ -26,7 +26,7 @@ account/migrations/0021_alter_cloudcredentials_group.py,sha256=zoFYmE-hd3uRGX6DR
|
|
26
26
|
account/migrations/0022_alter_memberdevice_modified.py,sha256=9eeKcdr9p6qFJ8ZxSnKSj1KxZjW8NZfM0YCMck6i0QQ,424
|
27
27
|
account/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
28
28
|
account/models/__init__.py,sha256=cV_lMnT2vL_mjiYtT4hlcIHo52ocFbGSNVkOIHHLXZY,385
|
29
|
-
account/models/device.py,sha256=
|
29
|
+
account/models/device.py,sha256=8D-Sbv9PZWAnX6UVpp1lNJ03P24fknNnN1VOhqY7RVg,6306
|
30
30
|
account/models/feeds.py,sha256=vI7fG4ASY1M0Zjke24RdnfDcuWeATl_yR_25jPmT64g,2011
|
31
31
|
account/models/group.py,sha256=N9Ow7AtV4xN5zSE9E5-msthJy0G5-3DEr2MTmvFO1kU,22887
|
32
32
|
account/models/legacy.py,sha256=zYdtv4LC0ooxPVqWM-uToPwV-lYWQLorSE6p6yn1xDw,2720
|
@@ -111,12 +111,13 @@ incident/migrations/0012_rule_match_by.py,sha256=PGclGnnc_8JEsJZ8znoXm-iAC6Y0i2W
|
|
111
111
|
incident/migrations/0013_rulecheck_is_required.py,sha256=cL7tOj5XGPpKd2f5BojIKfNJeDB1IL-jGRU6-g-Co5o,387
|
112
112
|
incident/migrations/0014_event_group_alter_rulecheck_index.py,sha256=v3gm5k0LVoas27qUDOt7el7YtK4yjFVLeEpuFUCoXaQ,724
|
113
113
|
incident/migrations/0015_rule_title_template_alter_incident_state.py,sha256=FPUDhFwqBC39EjeknRT7BPddEf6ExCjsXVb9LMqIn3U,687
|
114
|
+
incident/migrations/0016_rule_notify_template.py,sha256=4WGdMxiELujLIy9bzHovHWbAORupodN1Ty3vsy3mLjg,425
|
114
115
|
incident/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
116
|
incident/models/__init__.py,sha256=NMphuhb0RTMf7Ov4QkNv7iv6_I8Wtr3xQ54yjX_a31M,209
|
116
117
|
incident/models/event.py,sha256=FEzEKKQKLkdRrPCvv-3Um9E2UPQjyIJp314Zr2LHuiw,7976
|
117
|
-
incident/models/incident.py,sha256=
|
118
|
+
incident/models/incident.py,sha256=dSveWs0VawYePeFxwZT8ni85CS_4jxpGV8nXPVGXokk,22607
|
118
119
|
incident/models/ossec.py,sha256=eUDRGawzuLWobKEVGKfdZisDnyjS_Hlxi0T_GCSLCCI,2252
|
119
|
-
incident/models/rules.py,sha256=
|
120
|
+
incident/models/rules.py,sha256=PPp8oJDW1gop9i_21lhP50qgt_TrdWErp2mYqZCMfd4,7065
|
120
121
|
incident/models/ticket.py,sha256=S3kqGQpYLE6Y4M9IKu_60sgW-f592xNr8uufqHnvDoU,2302
|
121
122
|
incident/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
122
123
|
incident/parsers/ossec.py,sha256=fouUsSnrdkEuqDzJ-MxmCP7ny5pCGFS3Tyf6lQSMBc4,11609
|
@@ -378,7 +379,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
|
|
378
379
|
rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
|
379
380
|
rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
|
380
381
|
rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
|
381
|
-
rest/__init__.py,sha256=
|
382
|
+
rest/__init__.py,sha256=L-9nmqhBVg-KjQ-1szS_16HPFP4D1t7aJ05kVd52Qy4,122
|
382
383
|
rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
|
383
384
|
rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
|
384
385
|
rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
|
@@ -514,7 +515,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
514
515
|
ws4redis/settings.py,sha256=KKq00EwoGnz1yLwCZr5Dfoq2izivmAdsNEEM4EhZwN4,1610
|
515
516
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
516
517
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
517
|
-
django_restit-4.2.
|
518
|
-
django_restit-4.2.
|
519
|
-
django_restit-4.2.
|
520
|
-
django_restit-4.2.
|
518
|
+
django_restit-4.2.165.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
519
|
+
django_restit-4.2.165.dist-info/METADATA,sha256=rRvGoqgmYwOEx1u5zs7YdPfoWe29f3kBTCybt3bueeQ,7663
|
520
|
+
django_restit-4.2.165.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
521
|
+
django_restit-4.2.165.dist-info/RECORD,,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Generated by Django 4.2.11 on 2025-01-03 19:20
|
2
|
+
|
3
|
+
from django.db import migrations, models
|
4
|
+
|
5
|
+
|
6
|
+
class Migration(migrations.Migration):
|
7
|
+
|
8
|
+
dependencies = [
|
9
|
+
('incident', '0015_rule_title_template_alter_incident_state'),
|
10
|
+
]
|
11
|
+
|
12
|
+
operations = [
|
13
|
+
migrations.AddField(
|
14
|
+
model_name='rule',
|
15
|
+
name='notify_template',
|
16
|
+
field=models.TextField(default=None, null=True),
|
17
|
+
),
|
18
|
+
]
|
incident/models/incident.py
CHANGED
@@ -280,9 +280,7 @@ class Incident(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
280
280
|
try:
|
281
281
|
action, perm = self.rule.action.split(":")
|
282
282
|
members = Member.GetWithNotification(perm)
|
283
|
-
|
284
|
-
url = F"{settings.INCIDENT_PORTAL_URL}?incident={self.pk}"
|
285
|
-
msg = f"Incident #{self.pk}\n{self.description}\n{url}"
|
283
|
+
msg = self.renderTemplate()
|
286
284
|
for m in members:
|
287
285
|
m.sendSMS(msg)
|
288
286
|
except Exception:
|
@@ -363,6 +361,29 @@ class Incident(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
363
361
|
context=dict(incident=self, portal_url=settings.INCIDENT_PORTAL_URL),
|
364
362
|
email_only=True, from_email=INCIDENT_EMAIL_FROM)
|
365
363
|
|
364
|
+
def renderTemplate(self):
|
365
|
+
has_template = self.rule and self.rule.notify_template and not self.rule.notify_template.startswith("http")
|
366
|
+
url = self.renderURL()
|
367
|
+
if not has_template:
|
368
|
+
return f"Incident #{self.pk}\n{self.description}\n{url}"
|
369
|
+
template = self.rule.notify_template
|
370
|
+
try:
|
371
|
+
template = template.format(event=self)
|
372
|
+
except Exception:
|
373
|
+
pass
|
374
|
+
return template
|
375
|
+
|
376
|
+
def renderURL(self):
|
377
|
+
has_template = self.rule and self.rule.notify_template and self.rule.notify_template.startswith("http")
|
378
|
+
if not has_template:
|
379
|
+
return F"{settings.INCIDENT_PORTAL_URL}?incident={self.pk}"
|
380
|
+
url = self.rule.notify_template
|
381
|
+
try:
|
382
|
+
url = url.format(event=self)
|
383
|
+
except Exception:
|
384
|
+
pass
|
385
|
+
return url
|
386
|
+
|
366
387
|
def lastSentAge(self):
|
367
388
|
# prevent spams, only allow emails every 5 minutes
|
368
389
|
if self.action_sent is None:
|
incident/models/rules.py
CHANGED
@@ -65,6 +65,7 @@ class Rule(models.Model, rm.RestModel):
|
|
65
65
|
|
66
66
|
name = models.CharField(max_length=200)
|
67
67
|
title_template = models.CharField(max_length=200, default=None, null=True)
|
68
|
+
notify_template = models.TextField(default=None, null=True)
|
68
69
|
# the group the rule gets assigned to when triggered
|
69
70
|
group = models.ForeignKey("account.Group", on_delete=models.CASCADE, null=True, default=None)
|
70
71
|
# category allows us to limit running rules to only those with a category
|
rest/__init__.py
CHANGED
File without changes
|
File without changes
|