Bypass obfuscation for safe sources
This commit is contained in:
@@ -292,7 +292,16 @@ class DrilldownContextModal(APIView):
|
||||
nicks_sensitive = None
|
||||
query = False
|
||||
# Create the query params from the POST arguments
|
||||
mandatory = ["net", "channel", "num", "src", "index", "nick", "type", "mtype"]
|
||||
mandatory = [
|
||||
"net",
|
||||
"channel",
|
||||
"num",
|
||||
"source",
|
||||
"index",
|
||||
"nick",
|
||||
"type",
|
||||
"mtype",
|
||||
]
|
||||
invalid = [None, False, "—", "None"]
|
||||
|
||||
query_params = {k: v for k, v in request.data.items() if v}
|
||||
@@ -306,8 +315,11 @@ class DrilldownContextModal(APIView):
|
||||
|
||||
# Lookup the hash values but don't disclose them to the user
|
||||
if settings.HASHING:
|
||||
SAFE_PARAMS = deepcopy(query_params)
|
||||
hash_lookup(request.user, SAFE_PARAMS)
|
||||
if query_params["source"] not in settings.SAFE_SOURCES:
|
||||
SAFE_PARAMS = deepcopy(query_params)
|
||||
hash_lookup(request.user, SAFE_PARAMS)
|
||||
else:
|
||||
SAFE_PARAMS = deepcopy(query_params)
|
||||
else:
|
||||
SAFE_PARAMS = query_params
|
||||
|
||||
@@ -346,7 +358,7 @@ class DrilldownContextModal(APIView):
|
||||
SAFE_PARAMS["sorting"] = "desc"
|
||||
|
||||
annotate = False
|
||||
if query_params["src"] == "irc":
|
||||
if query_params["source"] == "irc":
|
||||
if query_params["type"] not in ["znc", "auth"]:
|
||||
annotate = True
|
||||
# Create the query with the context helper
|
||||
@@ -354,7 +366,7 @@ class DrilldownContextModal(APIView):
|
||||
query_params["index"],
|
||||
SAFE_PARAMS["net"],
|
||||
SAFE_PARAMS["channel"],
|
||||
query_params["src"],
|
||||
query_params["source"],
|
||||
SAFE_PARAMS["num"],
|
||||
size,
|
||||
type=type,
|
||||
@@ -374,13 +386,13 @@ class DrilldownContextModal(APIView):
|
||||
return render(request, self.template_name, results)
|
||||
|
||||
if settings.HASHING: # we probably want to see the tokens
|
||||
if query_params["src"] not in settings.SAFE_SOURCES:
|
||||
if query_params["source"] not in settings.SAFE_SOURCES:
|
||||
if not request.user.has_perm("core.bypass_hashing"):
|
||||
for index, item in enumerate(results["object_list"]):
|
||||
if "tokens" in item:
|
||||
results["object_list"][index]["msg"] = results["object_list"][
|
||||
index
|
||||
].pop("tokens")
|
||||
results["object_list"][index]["msg"] = results[
|
||||
"object_list"
|
||||
][index].pop("tokens")
|
||||
# item["msg"] = item.pop("tokens")
|
||||
|
||||
# Make the time nicer
|
||||
@@ -390,7 +402,7 @@ class DrilldownContextModal(APIView):
|
||||
context = {
|
||||
"net": query_params["net"],
|
||||
"channel": query_params["channel"],
|
||||
"src": query_params["src"],
|
||||
"source": query_params["source"],
|
||||
"ts": f"{query_params['date']} {query_params['time']}",
|
||||
"object_list": results["object_list"],
|
||||
"time": query_params["time"],
|
||||
|
||||
Reference in New Issue
Block a user