django-restit 4.2.87__py3-none-any.whl → 4.2.88__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/group.py +7 -0
- account/rpc/group.py +8 -1
- {django_restit-4.2.87.dist-info → django_restit-4.2.88.dist-info}/METADATA +1 -1
- {django_restit-4.2.87.dist-info → django_restit-4.2.88.dist-info}/RECORD +9 -9
- incident/models/incident.py +11 -2
- incident/parsers/ossec.py +2 -1
- medialib/models.py +2 -0
- {django_restit-4.2.87.dist-info → django_restit-4.2.88.dist-info}/LICENSE.md +0 -0
- {django_restit-4.2.87.dist-info → django_restit-4.2.88.dist-info}/WHEEL +0 -0
account/models/group.py
CHANGED
@@ -209,6 +209,13 @@ class Group(models.Model, RestModel, MetaDataModel):
|
|
209
209
|
self.name = value.strip()
|
210
210
|
else:
|
211
211
|
self.name = None
|
212
|
+
|
213
|
+
def set_parent(self, value):
|
214
|
+
if isinstance(value, (str, int)):
|
215
|
+
if int(value) == self.pk:
|
216
|
+
raise RestValidationError("cannot set self as parent", 1101)
|
217
|
+
value = Group.objects.filter(pk=value).last()
|
218
|
+
self.parent = value
|
212
219
|
|
213
220
|
def set_child_of(self, value):
|
214
221
|
# this is a helper to add this group to another group
|
account/rpc/group.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
from rest import decorators as rd
|
2
2
|
from rest import views as rv
|
3
|
+
from rest import helpers as rh
|
3
4
|
from account.models import Group, Membership, Member, GroupFeed, MemberFeed
|
4
|
-
from taskqueue import models as tq
|
5
5
|
|
6
6
|
|
7
7
|
@rd.url(r'^group$')
|
@@ -105,3 +105,10 @@ def rest_on_group_feed(request, pk=None):
|
|
105
105
|
@rd.login_required
|
106
106
|
def rest_on_member_feed(request, pk=None):
|
107
107
|
return MemberFeed.on_rest_request(request, pk)
|
108
|
+
|
109
|
+
|
110
|
+
@rd.urlGET('group/stats/kinds')
|
111
|
+
@rd.login_required
|
112
|
+
def rest_on_group_stats(request):
|
113
|
+
out = rh.countOccurences(Group.objects.filter(is_active=True), "kind")
|
114
|
+
return rv.restResult(request, dict(data=out))
|
@@ -26,7 +26,7 @@ account/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
|
|
26
26
|
account/models/__init__.py,sha256=cV_lMnT2vL_mjiYtT4hlcIHo52ocFbGSNVkOIHHLXZY,385
|
27
27
|
account/models/device.py,sha256=TloXvvrx3khF3BeGFuVYn6DhXjOW0AMZb4F9Fl5nBII,5491
|
28
28
|
account/models/feeds.py,sha256=vI7fG4ASY1M0Zjke24RdnfDcuWeATl_yR_25jPmT64g,2011
|
29
|
-
account/models/group.py,sha256=
|
29
|
+
account/models/group.py,sha256=Zsclyi83t-X-OshkaauObImVimiI2crTsKEM_aC2vvE,22262
|
30
30
|
account/models/legacy.py,sha256=zYdtv4LC0ooxPVqWM-uToPwV-lYWQLorSE6p6yn1xDw,2720
|
31
31
|
account/models/member.py,sha256=8xi-NahJipic_ut81vCFG-hY9x1U-trZ9KhnhIHAaFM,53092
|
32
32
|
account/models/membership.py,sha256=90EpAhOsGaqphDAkONP6j_qQ0OWSRaQsI8H7E7fgMkE,9249
|
@@ -42,7 +42,7 @@ account/periodic.py,sha256=-u0n-7QTJgDOkasGhBAPwHAwjpqWGA-MZLEFkVTqCGU,874
|
|
42
42
|
account/rpc/__init__.py,sha256=SGF0M_-H0dKh3b1apSX29BotNWAvITYccGQVC0MIjL8,336
|
43
43
|
account/rpc/auth.py,sha256=p62tyihWvSY2zn7eaVxKcCG9qLnnZBIkwdRH81sS5_Y,16615
|
44
44
|
account/rpc/device.py,sha256=mB14a6qvJIBnCa9ivLhPXwEt5Gk2foyqsKBtZxC506k,3070
|
45
|
-
account/rpc/group.py,sha256=
|
45
|
+
account/rpc/group.py,sha256=Iiefop0XmnuTZtZJTSyXbIAa7jD1cRLfreHMZWdhteE,4230
|
46
46
|
account/rpc/member.py,sha256=VNRSD38mmTUCbq3cCSy3qRyquzeVEwW_8zzrtS0-vAA,1817
|
47
47
|
account/rpc/notify.py,sha256=Q2YWejP36egeF060Hih5uX4Psv_B8NWlLLPi7iDYlIw,3344
|
48
48
|
account/rpc/oauth.py,sha256=ISLVsR5HvKALANokaOFRvF4FTRxWtXPvVnZAYANKxpo,2864
|
@@ -112,12 +112,12 @@ incident/migrations/0015_rule_title_template_alter_incident_state.py,sha256=FPUD
|
|
112
112
|
incident/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
113
113
|
incident/models/__init__.py,sha256=NMphuhb0RTMf7Ov4QkNv7iv6_I8Wtr3xQ54yjX_a31M,209
|
114
114
|
incident/models/event.py,sha256=Dw6fUi2tbLeA_ZRDcvGQNFkCkMGMBdtNeaLikXdAyE8,7769
|
115
|
-
incident/models/incident.py,sha256=
|
115
|
+
incident/models/incident.py,sha256=uKF7fUjZUPjLlfpRIlFMocGaanng2wmHmglP5RAzv_w,19847
|
116
116
|
incident/models/ossec.py,sha256=eUDRGawzuLWobKEVGKfdZisDnyjS_Hlxi0T_GCSLCCI,2252
|
117
117
|
incident/models/rules.py,sha256=aRkJ0ZnTv87nAUC1sHVkPExfb3OJ8fgHQIhnCIpIbhQ,7001
|
118
118
|
incident/models/ticket.py,sha256=S3kqGQpYLE6Y4M9IKu_60sgW-f592xNr8uufqHnvDoU,2302
|
119
119
|
incident/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
120
|
-
incident/parsers/ossec.py,sha256=
|
120
|
+
incident/parsers/ossec.py,sha256=fouUsSnrdkEuqDzJ-MxmCP7ny5pCGFS3Tyf6lQSMBc4,11609
|
121
121
|
incident/periodic.py,sha256=eX1rQK6v65A9ugofTvJPSmAWei6C-3EYgzCMuGZ03jM,381
|
122
122
|
incident/rpc.py,sha256=6JVWTTAr4CN2tAjjIUcXug1z3RhU_ar5CDLzedkduA4,8187
|
123
123
|
incident/templates/email/incident_change.html,sha256=tQYphypwLukkVdwH0TB2Szz2VEJ7GnsfRS3_ZJ-MYeE,13895
|
@@ -170,7 +170,7 @@ medialib/fixtures/medialib_test_fixture.json,sha256=7M7zvGI2S5G3ENV8OQ3Ks4149lEi
|
|
170
170
|
medialib/forms.py,sha256=nrE6QTPNPiIeX7Nx4l9DEmAQeQXqFyCg1C3JEDBYJfE,5442
|
171
171
|
medialib/migrations/0001_initial.py,sha256=H3JliH5aw7tiHef8MhrJr_9rGetqgA7UjTF-eKziRSM,20518
|
172
172
|
medialib/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
173
|
-
medialib/models.py,sha256=
|
173
|
+
medialib/models.py,sha256=eFT19hkG28OxSlrw2VFh3i9yiQGObPSY5Y76QmSORYk,52201
|
174
174
|
medialib/ocr.py,sha256=zlP7-NBiXhW7jR9pljmEPl5xzLVZpLN5QLAELQgU0Fk,1189
|
175
175
|
medialib/pdf.py,sha256=l28WwM0JKbT9boV-b_9TFh9jhvGcrquR8GqC8wfEaLk,1275
|
176
176
|
medialib/qrcode.py,sha256=vHyA5egXOX70EFiUDgr1njI9zcF6bXQJ_hKAQrppRow,545
|
@@ -506,7 +506,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
|
|
506
506
|
ws4redis/settings.py,sha256=K0yBiLUuY81iDM4Yr-k8hbvjn5VVHu5zQhmMK8Dtz0s,1536
|
507
507
|
ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
|
508
508
|
ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
|
509
|
-
django_restit-4.2.
|
510
|
-
django_restit-4.2.
|
511
|
-
django_restit-4.2.
|
512
|
-
django_restit-4.2.
|
509
|
+
django_restit-4.2.88.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
|
510
|
+
django_restit-4.2.88.dist-info/METADATA,sha256=kNtJO38wHtEHLW03kxVgMPBEsRgcgLr8-jwlHYwMwUc,7645
|
511
|
+
django_restit-4.2.88.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
512
|
+
django_restit-4.2.88.dist-info/RECORD,,
|
incident/models/incident.py
CHANGED
@@ -19,7 +19,12 @@ EVENT_META_TO_INCIDENT = [
|
|
19
19
|
"phone",
|
20
20
|
"group_name",
|
21
21
|
"group_id",
|
22
|
-
"http_user_agent",
|
22
|
+
("http_user_agent", "user_agent"),
|
23
|
+
"user_agent",
|
24
|
+
"http_url",
|
25
|
+
"error",
|
26
|
+
"error_code",
|
27
|
+
"rule_id",
|
23
28
|
"path"
|
24
29
|
]
|
25
30
|
|
@@ -135,13 +140,17 @@ class Incident(models.Model, rm.RestModel, rm.MetaDataModel):
|
|
135
140
|
|
136
141
|
def updateMeta(self, event):
|
137
142
|
for key in EVENT_META_TO_INCIDENT:
|
143
|
+
new_key = key
|
144
|
+
if isinstance(key, tuple):
|
145
|
+
key, new_key = key
|
138
146
|
if key in event.metadata:
|
139
|
-
self.setProperty(
|
147
|
+
self.setProperty(new_key, event.metadata[key])
|
140
148
|
self.setProperty("details", event.details)
|
141
149
|
if event.metadata.geoip and event.metadata.geoip.city:
|
142
150
|
self.setProperty("city", event.metadata.geoip.city)
|
143
151
|
self.setProperty("state", event.metadata.geoip.state)
|
144
152
|
self.setProperty("country", event.metadata.geoip.country)
|
153
|
+
self.setProperty("isp", event.metadata.geoip.isp)
|
145
154
|
|
146
155
|
def shouldTriggerAction(self):
|
147
156
|
count = self.events.all().count()
|
incident/parsers/ossec.py
CHANGED
@@ -164,6 +164,7 @@ def parse_alert_metadata(alert):
|
|
164
164
|
return dict(package=match.group(1))
|
165
165
|
return match_patterns(patterns, alert.text)
|
166
166
|
|
167
|
+
|
167
168
|
def match_patterns(patterns, text):
|
168
169
|
# Search for matches in the text
|
169
170
|
return {key: pattern.search(text).group(1) for key, pattern in patterns.items() if pattern.search(text)}
|
@@ -172,7 +173,7 @@ def match_patterns(patterns, text):
|
|
172
173
|
def parse_alert_json(data):
|
173
174
|
try:
|
174
175
|
if isinstance(data, str):
|
175
|
-
data = objict.fromJSON(data.replace('\n', '\\n'))
|
176
|
+
data = objict.fromJSON(removeNonAscii(data.replace('\n', '\\n')))
|
176
177
|
except Exception:
|
177
178
|
data = objict.fromJSON(removeNonAscii(data))
|
178
179
|
for key in data:
|
medialib/models.py
CHANGED
@@ -324,11 +324,13 @@ class MediaLibrary(models.Model, RestModel):
|
|
324
324
|
except (KeyError, AttributeError):
|
325
325
|
return settings.MEDIALIB_DEFAULT_STORE
|
326
326
|
|
327
|
+
|
327
328
|
class MediaItem(models.Model, RestModel, MetaDataModel):
|
328
329
|
"""
|
329
330
|
Media Item (a video or image)
|
330
331
|
"""
|
331
332
|
class RestMeta:
|
333
|
+
SEARCH_FIELDS = ["name", "description"]
|
332
334
|
VIEW_PERMS = ["view_media", "manage_users", "manage_media"]
|
333
335
|
SAVE_PERMS = ["manage_media", "manage_users"]
|
334
336
|
OWNER_FIELD = "owner"
|
File without changes
|
File without changes
|