From 2873773ee7c43c0192803d96a4fcc6f3b88c7aa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Mon, 10 Aug 2020 12:35:16 +0200 Subject: [PATCH] new: trigger to hide a capture from the front page (admin only) --- lookyloo/lookyloo.py | 10 ++++++++++ website/web/__init__.py | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/lookyloo/lookyloo.py b/lookyloo/lookyloo.py index aa55e4f..f6014a1 100644 --- a/lookyloo/lookyloo.py +++ b/lookyloo/lookyloo.py @@ -444,6 +444,16 @@ class Lookyloo(): self.redis.hmset(str(capture_dir), cache) self.redis.hset('lookup_dirs', uuid, str(capture_dir)) + def hide_capture(self, capture_uuid: str) -> None: + """Add the capture in the hidden pool (not shown on the front page) + NOTE: it won't remove the correlations until they are rebuilt. + """ + capture_dir = self.lookup_capture_dir(capture_uuid) + if not capture_dir: + raise MissingUUID(f'Unable to find UUID {capture_uuid} in the cache') + self.redis.hset(str(capture_dir), 'no_index', 1) + (capture_dir / 'no_index').touch() + @property def capture_uuids(self): return self.redis.hkeys('lookup_dirs') diff --git a/website/web/__init__.py b/website/web/__init__.py index 907190d..c52a53e 100644 --- a/website/web/__init__.py +++ b/website/web/__init__.py @@ -355,6 +355,13 @@ def export(tree_uuid: str): as_attachment=True, attachment_filename='capture.zip') +@app.route('/tree//hide', methods=['GET']) +@auth.login_required +def hide_capture(tree_uuid: str): + lookyloo.hide_capture(tree_uuid) + return redirect(url_for('tree', tree_uuid=tree_uuid)) + + @app.route('/redirects/', methods=['GET']) def redirects(tree_uuid: str): cache = lookyloo.capture_cache(tree_uuid)