Skip to content

Build your personal knowledge base with Trilium Notes

feat(call_to_action): inform about backend scripts being disabled by default

Elian Doran358a9ecc129e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 8c748a1385..e1a75696e1 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2337,6 +2337,9 @@
"new_layout_title": "New layout",
"new_layout_message": "We’ve introduced a modernized layout for Trilium. The ribbon has been removed and seamlessly integrated into the main interface, with a new status bar and expandable sections (such as promoted attributes) taking over key functions.\n\nThe new layout is enabled by default, and can be temporarily disabled via Options → Appearance.",
"new_layout_button": "More info",
+ "scripting_disabled_title": "Backend scripting has been disabled",
+ "scripting_disabled_message": "Backend scripting is now disabled by default for security. Your notes contain backend scripts (notes with a #run label) that will no longer execute automatically.\n\nIf you rely on these scripts, you can re-enable backend scripting in the security settings.",
+ "scripting_disabled_button": "Open security settings",
"dismiss": "Dismiss"
},
"settings": {
diff --git a/apps/client/src/widgets/dialogs/call_to_action_definitions.ts b/apps/client/src/widgets/dialogs/call_to_action_definitions.ts
index afaecbdfa3..042c6a3ab8 100644
--- a/apps/client/src/widgets/dialogs/call_to_action_definitions.ts
+++ b/apps/client/src/widgets/dialogs/call_to_action_definitions.ts
@@ -70,6 +70,18 @@ const CALL_TO_ACTIONS: CallToAction[] = [
}
]
},
+ {
+ id: "scripting_disabled",
+ title: t("call_to_action.scripting_disabled_title"),
+ message: t("call_to_action.scripting_disabled_message"),
+ enabled: () => !options.is("backendScriptingEnabled") && options.is("hasUserBackendScripts"),
+ buttons: [
+ {
+ text: t("call_to_action.scripting_disabled_button"),
+ onClick: () => appContext.tabManager.openInNewTab("_optionsSecurity", "_hidden", true)
+ }
+ ]
+ },
{
id: "next_theme",
title: t("call_to_action.next_theme_title"),
diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.ts
index 73dd3143d7..e1b6036b3c 100644
--- a/packages/commons/src/lib/options_interface.ts
+++ b/packages/commons/src/lib/options_interface.ts
@@ -148,6 +148,7 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
databaseReadonly: boolean;
backendScriptingEnabled: boolean;
sqlConsoleEnabled: boolean;
+ hasUserBackendScripts: boolean;
isPasswordSet: boolean;
overrideThemeFonts: boolean;
spellCheckEnabled: boolean;
diff --git a/packages/trilium-core/src/routes/api/options.ts b/packages/trilium-core/src/routes/api/options.ts
index bb46661e9a..d160ae9388 100644
--- a/packages/trilium-core/src/routes/api/options.ts
+++ b/packages/trilium-core/src/routes/api/options.ts
@@ -3,6 +3,7 @@
import type { OptionNames } from "@triliumnext/commons";
import type { Request } from "express";
+import attributeService from "../../services/attributes.js";
import config from "../../services/config.js";
import { changeLanguage } from "../../services/i18n.js";
import { getLog } from "../../services/log.js";
@@ -157,6 +158,12 @@ function getOptions() {
resultMap["backendScriptingEnabled"] = config.Security.backendScriptingEnabled ? "true" : "false";
resultMap["sqlConsoleEnabled"] = config.Security.sqlConsoleEnabled ? "true" : "false";
+ // Detect if the user has any backend scripts with #run labels (backendStartup, hourly, daily).
+ // Filter by MIME type since #run can also appear on frontend scripts.
+ const hasUserBackendScripts = attributeService.getNotesWithLabel("run")
+ .some((note) => note.mime === "application/javascript;env=backend");
+ resultMap["hasUserBackendScripts"] = hasUserBackendScripts ? "true" : "false";
+
// if database is read-only, disable editing in UI by setting 0 here
if (config.General.readOnly) {
resultMap["autoReadonlySizeText"] = "0";