Make changing engine-run code superuser-only

Writing node source, installing modules and any flow save that adds,
retypes or repoints a code node (Function, Command), edits a Command
node's settings or changes a node's resources.env now answer 403 for
everyone but a superuser. MCP tools and the assistant reach the same
routes, so they inherit the gate. Node types report runs_code.

The editor shows code read-only with a note, disables a Command node's
settings, leaves code nodes and reusable nodes out of the palette and
paste, and the Modules page offers no install.
This commit is contained in:
2026-10-06 11:36:30 +02:00
parent 2914d860b1
commit 6802cd2203
19 changed files with 391 additions and 26 deletions
+6
View File
@@ -303,6 +303,9 @@ class NodeType:
# Constructor signatures differ per node type.
cls: Any
has_source: bool = False
#: Runs code its definition supplies — a source file, or a command among
#: its settings — with everything the engine can reach.
runs_code: bool = False
free_params: bool = False
params_schema: dict[str, Any] = field(default_factory=dict)
#: Which installed package supplied this type, for the ones that are not
@@ -321,6 +324,7 @@ NODE_TYPES: dict[str, NodeType] = {
description="Your own Python code, run on every incoming message.",
cls=Node,
has_source=True,
runs_code=True,
free_params=True,
),
"mqtt": NodeType(
@@ -399,6 +403,7 @@ NODE_TYPES: dict[str, NodeType] = {
title="Command",
description="Run a command in the engine's container and read its output.",
cls=ExecNode,
runs_code=True,
params_schema=_schema_of(ExecNode),
),
"file": NodeType(
@@ -424,6 +429,7 @@ def node_type_info() -> list[NodeTypeInfo]:
description=spec.description,
params_schema=spec.params_schema,
has_source=spec.has_source,
runs_code=spec.runs_code,
free_params=spec.free_params,
plugin=spec.plugin,
)