diff --git a/core/lib/opensearch.py b/core/lib/opensearch.py index 3a3be8e..b66c713 100644 --- a/core/lib/opensearch.py +++ b/core/lib/opensearch.py @@ -14,6 +14,7 @@ from core.views.helpers import ( hash_list, hash_lookup, obfuscate_list, + randomise_list, ) # from json import dumps @@ -571,6 +572,9 @@ def query_results( if settings.OBFUSCATION: obfuscate_list(request.user, results_parsed) + if settings.RANDOMISATION: + randomise_list(request.user, results_parsed) + # process_list(reqults) # IMPORTANT! - DO NOT PASS query_params to the user! @@ -586,6 +590,9 @@ def query_results( if settings.DELAY_RESULTS: if not request.user.has_perm("bypass_delay"): context["delay"] = settings.DELAY_DURATION + if settings.RANDOMISATION: + if not request.user.has_perm("bypass_randomisation"): + context["randomised"] = True return context diff --git a/core/migrations/0009_alter_perms_options.py b/core/migrations/0009_alter_perms_options.py new file mode 100644 index 0000000..66a05b7 --- /dev/null +++ b/core/migrations/0009_alter_perms_options.py @@ -0,0 +1,17 @@ +# Generated by Django 4.0.6 on 2022-08-27 12:05 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0008_alter_perms_options'), + ] + + operations = [ + migrations.AlterModelOptions( + name='perms', + options={'permissions': (('bypass_hashing', 'Can bypass field hashing'), ('bypass_blacklist', 'Can bypass the blacklist'), ('bypass_encryption', 'Can bypass field encryption'), ('bypass_obfuscation', 'Can bypass field obfuscation'), ('bypass_delay', 'Can bypass data delay'), ('bypass_randomisation', 'Can bypass data randomisation'), ('post_irc', 'Can post to IRC'), ('post_discord', 'Can post to Discord'), ('query_search', 'Can search with query strings'), ('use_insights', 'Can use the Insights page'), ('index_int', 'Can use the internal index'), ('index_meta', 'Can use the meta index'))}, + ), + ] diff --git a/core/models.py b/core/models.py index 72528ce..a18e3b3 100644 --- a/core/models.py +++ b/core/models.py @@ -112,6 +112,7 @@ class Perms(models.Model): ("bypass_encryption", "Can bypass field encryption"), ("bypass_obfuscation", "Can bypass field obfuscation"), ("bypass_delay", "Can bypass data delay"), + ("bypass_randomisation", "Can bypass data randomisation"), ("post_irc", "Can post to IRC"), ("post_discord", "Can post to Discord"), ("query_search", "Can search with query strings"), diff --git a/core/templates/ui/drilldown/table_results.html b/core/templates/ui/drilldown/table_results.html index 616c2d8..7917352 100644 --- a/core/templates/ui/drilldown/table_results.html +++ b/core/templates/ui/drilldown/table_results.html @@ -28,7 +28,18 @@ {% endif %} {% if delay is not None %}
delayed by {{ delay }} days
+