From fccf63f1db0d35843242f17bfede3299336e6233 Mon Sep 17 00:00:00 2001 From: kazet Date: Fri, 19 Jan 2024 13:49:07 +0100 Subject: [PATCH] Possibility to disable modules by default (#728) --- artemis/config.py | 5 +++++ artemis/frontend.py | 10 +++++++++- templates/add.jinja2 | 9 ++++++++- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/artemis/config.py b/artemis/config.py index c65fc06ef..9cd8656f6 100644 --- a/artemis/config.py +++ b/artemis/config.py @@ -189,6 +189,11 @@ class Miscellaneous: "In order not to overload the DB and bandwidth, this determines how long the downloaded content would be (in bytes).", ] = get_config("CONTENT_PREFIX_SIZE", default=1024 * 100, cast=int) + MODULES_DISABLED_BY_DEFAULT: Annotated[ + List[str], + "Artemis modules that are disabled by default (but may easily be enabled in the UI)", + ] = get_config("MODULES_DISABLED_BY_DEFAULT", default="humble", cast=decouple.Csv(str, delimiter=",")) + SUBDOMAIN_ENUMERATION_TTL_DAYS: Annotated[ int, "If we request a domain for subdomain enumeration, we will save that it has already been enumerated, so that e.g. " diff --git a/artemis/frontend.py b/artemis/frontend.py index 3b530dedc..93adac25f 100644 --- a/artemis/frontend.py +++ b/artemis/frontend.py @@ -10,6 +10,7 @@ from karton.core.inspect import KartonState from starlette.datastructures import Headers +from artemis.config import Config from artemis.db import DB, ColumnOrdering, TaskFilter from artemis.json_utils import JSONEncoderAdditionalTypes from artemis.karton_utils import restart_crashed_tasks @@ -79,7 +80,14 @@ def get_root(request: Request) -> Response: def get_add_form(request: Request) -> Response: binds = sorted(get_binds_that_can_be_disabled(), key=lambda bind: bind.identity.lower()) - return templates.TemplateResponse("add.jinja2", {"request": request, "binds": binds}) + return templates.TemplateResponse( + "add.jinja2", + { + "request": request, + "binds": binds, + "modules_disabled_by_default": Config.Miscellaneous.MODULES_DISABLED_BY_DEFAULT, + }, + ) @router.post("/add", include_in_schema=False) diff --git a/templates/add.jinja2 b/templates/add.jinja2 index b0bbd1099..bed248cf2 100644 --- a/templates/add.jinja2 +++ b/templates/add.jinja2 @@ -35,13 +35,20 @@ (select all unselect all) + {% if modules_disabled_by_default %} +
+ The following modules are disabled by default: {{ ", ".join(modules_disabled_by_default) }}. Select the checkbox to start them. + To change this, update the MODULES_DISABLED_BY_DEFAULT setting. +
+ {% endif %} +
{% for bind in binds %}