Skip to content

Commit b0e83f4

Browse files
committed
Update views.py
1 parent 33a2a8c commit b0e83f4

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

web/apiv2/views.py

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,8 +1148,12 @@ def tasks_report(request, task_id, report_format="json", make_zip=False):
11481148
resp = {"error": True, "error_value": "Task Report API is Disabled"}
11491149
return Response(resp)
11501150

1151+
ALLOW_DL = False
1152+
if hasattr(request.user, "userprofile") and request.user.userprofile.reports:
1153+
ALLOW_DL = True
1154+
11511155
# check if allowed to download to all + if no if user has permissions
1152-
if not settings.ALLOW_DL_REPORTS_TO_ALL and not request.user.userprofile.reports:
1156+
if not settings.ALLOW_DL_REPORTS_TO_ALL and ALLOW_DL is False:
11531157
return render(
11541158
request,
11551159
"error.html",
@@ -1787,39 +1791,6 @@ def tasks_surifile(request, task_id):
17871791
resp = {"error": True, "error_value": "No suricata files captured for task %s" % task_id}
17881792
return Response(resp)
17891793

1790-
1791-
@csrf_exempt
1792-
@api_view(["GET"])
1793-
def tasks_rollingsuri(request, window=60):
1794-
window = int(window)
1795-
1796-
if not apiconf.rollingsuri.get("enabled"):
1797-
resp = {"error": True, "error_value": "Suricata Rolling Alerts API is disabled"}
1798-
return Response(resp)
1799-
maxwindow = apiconf.rollingsuri.get("maxwindow")
1800-
if maxwindow > 0:
1801-
if window > maxwindow:
1802-
resp = {"error": True, "error_value": "The Window You Specified is greater than the configured maximum"}
1803-
return Response(resp)
1804-
1805-
gen_time = datetime.now() - timedelta(minutes=window)
1806-
dummy_id = ObjectId.from_datetime(gen_time)
1807-
result = list(
1808-
mongo_find(
1809-
"analysis",
1810-
{"suricata.alerts": {"$exists": True}, "_id": {"$gte": dummy_id}},
1811-
{"suricata.alerts": 1, "info.id": 1},
1812-
)
1813-
)
1814-
resp = []
1815-
for e in result:
1816-
for alert in e["suricata"]["alerts"]:
1817-
alert["id"] = e["info"]["id"]
1818-
resp.append(alert)
1819-
1820-
return Response(resp)
1821-
1822-
18231794
@csrf_exempt
18241795
@api_view(["GET"])
18251796
def tasks_procmemory(request, task_id, pid="all"):

0 commit comments

Comments
 (0)