Skip to content

Commit

Permalink
Better dependency check (#1182)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazet authored Aug 3, 2024
1 parent 37d2220 commit 56f4f09
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions artemis/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from starlette.datastructures import Headers

from artemis import csrf
from artemis.binds import TaskType
from artemis.config import Config
from artemis.db import DB, ColumnOrdering, ReportGenerationTaskStatus, TaskFilter
from artemis.json_utils import JSONEncoderAdditionalTypes
Expand Down Expand Up @@ -160,12 +161,16 @@ async def post_add(
f"{task} is not supported - Artemis supports domains, IPs or IP ranges. Domains and IPs may also optionally be followed by port number."
)

if "port_scanner" in disabled_modules:
for bind in get_binds_that_can_be_disabled():
if bind.identity not in disabled_modules:
for item in bind.filters:
if "type" in item and item["type"] == "service":
validation_messages.append(f"Module {bind.identity} requires port_scanner to be enabled")
for dependency, task_types in [
("port_scanner", [TaskType.SERVICE.value, TaskType.WEBAPP.value]),
("device_identifier", [TaskType.DEVICE.value]),
]:
if dependency in disabled_modules:
for bind in get_binds_that_can_be_disabled():
if bind.identity not in disabled_modules:
for item in bind.filters:
if "type" in item and item["type"] in task_types:
validation_messages.append(f"Module {bind.identity} requires {dependency} to be enabled")

if validation_messages:
binds = sorted(get_binds_that_can_be_disabled(), key=lambda bind: bind.identity.lower())
Expand Down

0 comments on commit 56f4f09

Please sign in to comment.