django-restit 4.2.165__py3-none-any.whl → 4.2.166__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-restit
3
- Version: 4.2.165
3
+ Version: 4.2.166
4
4
  Summary: A Rest Framework for DJANGO
5
5
  License: MIT
6
6
  Author: Ian Starnes
@@ -95,7 +95,7 @@ inbox/utils/parsing.py,sha256=y_71dwz8bm3JvF35ol8698XJ36sBF8fQWUrn0sYd2Fs,5597
95
95
  inbox/utils/render.py,sha256=CU_F2qUBQE7mjb9Q6Dn9ro5CS_O_zEY-wDMHEClKkIA,4331
96
96
  inbox/utils/sending.py,sha256=BKelTZnbkdSLGpjOY6IRTrzj-Hnw2pPZ7RYQGwe-tqk,2179
97
97
  incident/README.md,sha256=4vbZTJj7uUmq8rogYngxqNYjFTlBOujfWUGheLoFKMc,1114
98
- incident/__init__.py,sha256=xgdt3z3z7ygjWv5HxhiWgBtB2W3IUJmmR88NSyUeHuo,3455
98
+ incident/__init__.py,sha256=FXNMmcGP6YAKjwik84ppze33uL0kDTa7YFr3aOEXhhk,3658
99
99
  incident/migrations/0001_initial.py,sha256=KmJRau3a2QFRaUwUrFUgY2p7FQZCODv3F-Sl0ZArpu0,9720
100
100
  incident/migrations/0002_event_component_event_component_id.py,sha256=Qfu3ndJKh4v7953ULTUZlSa3mVI-lnFIq9VFN1Rbs7Q,595
101
101
  incident/migrations/0003_rule_action.py,sha256=LNqV52qOjxxe3L8qEdln-Hd2voFcpyjOZ_cEsasrv7s,425
@@ -122,7 +122,7 @@ incident/models/ticket.py,sha256=S3kqGQpYLE6Y4M9IKu_60sgW-f592xNr8uufqHnvDoU,230
122
122
  incident/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
123
123
  incident/parsers/ossec.py,sha256=fouUsSnrdkEuqDzJ-MxmCP7ny5pCGFS3Tyf6lQSMBc4,11609
124
124
  incident/periodic.py,sha256=eX1rQK6v65A9ugofTvJPSmAWei6C-3EYgzCMuGZ03jM,381
125
- incident/rpc.py,sha256=sFHN1BTTPx-yYd6iCOpcGsKVHZPcD7LWcRcR0XsVquE,8768
125
+ incident/rpc.py,sha256=y1u_op8PiWI4kUVD_DsKXmygdxRDBDxudCFGp829s3E,9056
126
126
  incident/templates/email/incident_change.html,sha256=tQYphypwLukkVdwH0TB2Szz2VEJ7GnsfRS3_ZJ-MYeE,13895
127
127
  incident/templates/email/incident_msg.html,sha256=MZdKhTddUF2MpiH8Z3RTQEmW_ko1n3ajeZ11KLtiLlU,13780
128
128
  incident/templates/email/incident_new.html,sha256=W6nwFQROnyDfMlXub8s02ws4hGnJp16pfgp9xTm_aEc,15185
@@ -379,7 +379,7 @@ pushit/utils.py,sha256=IeTCGa-164nmB1jIsK1lu1O1QzUhS3BKfuXHGjCW-ck,2121
379
379
  rest/.gitignore,sha256=TbEvWRMnAiajCTOdhiNrd9eeCAaIjRp9PRjE_VkMM5g,118
380
380
  rest/README.md,sha256=V3ETc-cJu8PZIbKr9xSe_pA4JEUpC8Dhw4bQeVCDJPw,5460
381
381
  rest/RemoteEvents.py,sha256=nL46U7AuxIrlw2JunphR1tsXyqi-ep_gD9CYGpYbNgE,72
382
- rest/__init__.py,sha256=L-9nmqhBVg-KjQ-1szS_16HPFP4D1t7aJ05kVd52Qy4,122
382
+ rest/__init__.py,sha256=0TxtckfR2izNmII4ddcJuIksqIVi3UW_LKZ9O-p_E4E,122
383
383
  rest/arc4.py,sha256=y644IbF1ec--e4cUJ3KEYsewTCITK0gmlwa5mJruFC0,1967
384
384
  rest/cache.py,sha256=1Qg0rkaCJCaVP0-l5hZg2CIblTdeBSlj_0fP6vlKUpU,83
385
385
  rest/crypto/__init__.py,sha256=Tl0U11rgj1eBYqd6OXJ2_XSdNLumW_JkBZnaJqI6Ldw,72
@@ -515,7 +515,7 @@ ws4redis/servers/uwsgi.py,sha256=VyhoCI1DnVFqBiJYHoxqn5Idlf6uJPHvfBKgkjs34mo,172
515
515
  ws4redis/settings.py,sha256=KKq00EwoGnz1yLwCZr5Dfoq2izivmAdsNEEM4EhZwN4,1610
516
516
  ws4redis/utf8validator.py,sha256=S0OlfjeGRP75aO6CzZsF4oTjRQAgR17OWE9rgZdMBZA,5122
517
517
  ws4redis/websocket.py,sha256=R0TUyPsoVRD7Y_oU7w2I6NL4fPwiz5Vl94-fUkZgLHA,14848
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,,
518
+ django_restit-4.2.166.dist-info/LICENSE.md,sha256=VHN4hhEeVOoFjtG-5fVv4jesA4SWi0Z-KgOzzN6a1ps,1068
519
+ django_restit-4.2.166.dist-info/METADATA,sha256=UFrfXKJj92wJ-lgCMNHKLGE8dsK9hP9MKncpiq9O-jE,7663
520
+ django_restit-4.2.166.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
521
+ django_restit-4.2.166.dist-info/RECORD,,
incident/__init__.py CHANGED
@@ -15,6 +15,9 @@ def _request_to_meta(request, metadata):
15
15
  metadata["buid"] = request.buid
16
16
  if "username" not in metadata and hasattr(request, "member") and request.member is not None:
17
17
  metadata["username"] = request.member.username
18
+ # if "group_name" not in metadata and hasattr(request, "group") and request.group is not None:
19
+ # metadata['group_name'] = request.group.name
20
+ # metadata['group_id'] = request.group.id
18
21
  return metadata
19
22
 
20
23
 
incident/rpc.py CHANGED
@@ -56,69 +56,85 @@ if settings.REPORT_PERMISSION_DENIED:
56
56
  rv.restPermissionDenied = patched_restPermissionDenied
57
57
 
58
58
 
59
+ @rd.urlPOST(r'^ossec/alert/batch$')
60
+ def batch_ossec_alert_creat_from_request(request):
61
+ batch = request.DATA.get("batch")
62
+ if not isinstance(batch, list):
63
+ return rv.restStatus(request, False, error="invalid format")
64
+ for alert in batch:
65
+ on_ossec_alert(request, alert)
66
+ return rv.restStatus(request, True)
67
+
68
+
59
69
  @rd.urlPOST(r'^ossec/alert$')
60
70
  def ossec_alert_creat_from_request(request):
61
71
  payload = request.DATA.get("payload")
62
- if payload:
63
- try:
64
- # TODO make this a task (background it)
65
- # rh.log_error("parsing payload", payload)
66
- od = ossec.parseAlert(request, payload)
67
- # lets now create a local event
68
- if od is not None:
69
- level = 10
70
- if od.level > 10:
71
- level = 1
72
- elif od.level > 7:
73
- level = 2
74
- elif od.level == 6:
75
- level = 3
76
- elif od.level == 5:
77
- level = 4
78
- elif od.level == 4:
79
- level = 6
80
- elif od.level <= 3:
81
- level = 8
82
- metadata = od.toDict(graph="default")
83
- metadata.update(od.metadata)
84
- # we reuse the ssh_sig because it is a text field to store urls
85
- # ssh_sig = metadata.get("ssh_sig", None)
86
- # if ssh_sig is not None and ssh_sig.startswith("http"):
87
- # metadata["url"] = ssh_sig
88
- # metadata["domain"] = ossec.extractDomain(ssh_sig)
89
- # metadata["path"] = ossec.extractUrlPath(ssh_sig)
90
- # metadata.pop("ssh_sig")
91
- if od.geoip:
92
- metadata["country"] = od.geoip.country
93
- metadata["city"] = od.geoip.city
94
- metadata["province"] = od.geoip.state
95
- metadata["isp"] = od.geoip.isp
96
-
97
- am.Event.createFromDict(None, {
98
- "hostname": od.hostname,
99
- "description": od.title,
100
- "details": od.text,
101
- "level": level,
102
- "category": "ossec",
103
- "component": "incident.ServerOssecAlert",
104
- "component_id": od.id,
105
- "reporter_ip": od.src_ip,
106
- "metadata": metadata
107
- })
108
- return rv.restStatus(request, True)
109
- except Exception as err:
110
- rh.log_exception()
111
- stack = rh.getStackString()
112
- # rh.log_exception("during ossec alert", payload)
113
- metadata = dict(ip=request.ip, payload=payload)
72
+ if not payload:
73
+ return rv.restStatus(request, False, error="no alert data")
74
+ on_ossec_alert(request, payload)
75
+ return rv.restStatus(request, True)
76
+
77
+
78
+ def on_ossec_alert(request, alert):
79
+ try:
80
+ # TODO make this a task (background it)
81
+ # rh.log_error("parsing payload", payload)
82
+ od = ossec.parseAlert(request, alert)
83
+ # lets now create a local event
84
+ if od is not None:
85
+ level = 10
86
+ if od.level > 10:
87
+ level = 1
88
+ elif od.level > 7:
89
+ level = 2
90
+ elif od.level == 6:
91
+ level = 3
92
+ elif od.level == 5:
93
+ level = 4
94
+ elif od.level == 4:
95
+ level = 6
96
+ elif od.level <= 3:
97
+ level = 8
98
+ metadata = od.toDict(graph="default")
99
+ metadata.update(od.metadata)
100
+ # we reuse the ssh_sig because it is a text field to store urls
101
+ # ssh_sig = metadata.get("ssh_sig", None)
102
+ # if ssh_sig is not None and ssh_sig.startswith("http"):
103
+ # metadata["url"] = ssh_sig
104
+ # metadata["domain"] = ossec.extractDomain(ssh_sig)
105
+ # metadata["path"] = ossec.extractUrlPath(ssh_sig)
106
+ # metadata.pop("ssh_sig")
107
+ if od.geoip:
108
+ metadata["country"] = od.geoip.country
109
+ metadata["city"] = od.geoip.city
110
+ metadata["province"] = od.geoip.state
111
+ metadata["isp"] = od.geoip.isp
112
+
114
113
  am.Event.createFromDict(None, {
115
- "hostname": request.get_host(),
116
- "description": f"error parseing alert: {err}",
117
- "details": stack,
118
- "level": 8,
119
- "category": "ossec_error",
114
+ "hostname": od.hostname,
115
+ "description": od.title,
116
+ "details": od.text,
117
+ "level": level,
118
+ "category": "ossec",
119
+ "component": "incident.ServerOssecAlert",
120
+ "component_id": od.id,
121
+ "reporter_ip": od.src_ip,
120
122
  "metadata": metadata
121
123
  })
124
+ return rv.restStatus(request, True)
125
+ except Exception as err:
126
+ rh.log_exception()
127
+ stack = rh.getStackString()
128
+ # rh.log_exception("during ossec alert", payload)
129
+ metadata = dict(ip=request.ip, payload=alert)
130
+ am.Event.createFromDict(None, {
131
+ "hostname": request.get_host(),
132
+ "description": f"error parseing alert: {err}",
133
+ "details": stack,
134
+ "level": 8,
135
+ "category": "ossec_error",
136
+ "metadata": metadata
137
+ })
122
138
  # rh.log_error("ossec alert", request.DATA.asDict())
123
139
  return rv.restStatus(request, False, error="no alert data")
124
140
 
rest/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .uberdict import UberDict # noqa: F401
2
2
  from .settings_helper import settings # noqa: F401
3
3
 
4
- __version__ = "4.2.165"
4
+ __version__ = "4.2.166"