Skip to content

Commit

Permalink
Possibility to disable modules by default (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet committed Jan 19, 2024
1 parent 4146e08 commit fccf63f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
5 changes: 5 additions & 0 deletions artemis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. "
Expand Down
10 changes: 9 additions & 1 deletion artemis/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 8 additions & 1 deletion templates/add.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,20 @@
(<a href="" onclick="setSelectionForAllModules(true); return false;">select all</a>
<a href="" onclick="setSelectionForAllModules(false); return false;">unselect all</a>)

{% if modules_disabled_by_default %}
<div class="alert alert-info">
The following modules are disabled by default: {{ ", ".join(modules_disabled_by_default) }}. Select the checkbox to start them.
To change this, update the <tt>MODULES_DISABLED_BY_DEFAULT</tt> setting.
</div>
{% endif %}

<input type="hidden" name="choose_modules_to_enable" value="1">

<div class="row m-0">
{% for bind in binds %}
<div class="form-check col-md-4">
<label class="form-check-label">
<input class="form-check-input" type="checkbox" value="" name="module_enabled_{{ bind.identity }}" checked>
<input class="form-check-input" type="checkbox" value="" name="module_enabled_{{ bind.identity }}" {% if bind.identity not in modules_disabled_by_default %}checked{% endif %}>
{{ bind.identity }}<br/>
<span class="small text-muted">{{ bind.info|dedent|render_markdown|safe }}</span>
</label>
Expand Down

0 comments on commit fccf63f

Please sign in to comment.