Skip to content

Build your personal knowledge base with Trilium Notes

chore(core): rename the config for backend scripting

Elian Dorane3c22b71659e
diff --git a/apps/server/src/assets/config-sample.ini b/apps/server/src/assets/config-sample.ini
index a91575b25a..5e19fd8687 100644
--- a/apps/server/src/assets/config-sample.ini
+++ b/apps/server/src/assets/config-sample.ini
@@ -74,7 +74,7 @@ oauthIssuerIcon=
# all users with admin-level access to the server.
# Frontend scripts are always allowed (they run in a sandboxed browser context).
# Desktop builds override this to true automatically.
-enabled=false
+backendScriptingEnabled=false
# Enable the SQL console (allows raw SQL execution against the database)
sqlConsoleEnabled=false
diff --git a/apps/server/src/services/config.ts b/apps/server/src/services/config.ts
index 0f8e5761a3..cf5454fb55 100644
--- a/apps/server/src/services/config.ts
+++ b/apps/server/src/services/config.ts
@@ -141,7 +141,7 @@ export interface TriliumConfig {
/** Scripting and code execution configuration */
Scripting: {
/** Whether backend script execution is enabled (default: false for server, true for desktop) */
- enabled: boolean;
+ backendScriptingEnabled: boolean;
/** Whether the SQL console is accessible (default: false) */
sqlConsoleEnabled: boolean;
};
@@ -472,9 +472,9 @@ const configMapping = {
}
},
Scripting: {
- enabled: {
- standardEnvVar: 'TRILIUM_SCRIPTING_ENABLED',
- iniGetter: () => getIniSection("Scripting")?.enabled,
+ backendScriptingEnabled: {
+ standardEnvVar: 'TRILIUM_SCRIPTING_BACKEND_ENABLED',
+ iniGetter: () => getIniSection("Scripting")?.backendScriptingEnabled,
defaultValue: false,
transformer: transformBoolean
},
@@ -540,14 +540,14 @@ const config: TriliumConfig = {
retentionDays: getConfigValue(configMapping.Logging.retentionDays)
},
Scripting: {
- enabled: getConfigValue(configMapping.Scripting.enabled),
+ backendScriptingEnabled: getConfigValue(configMapping.Scripting.backendScriptingEnabled),
sqlConsoleEnabled: getConfigValue(configMapping.Scripting.sqlConsoleEnabled)
}
};
// Desktop builds always have scripting enabled (single-user trusted environment)
if (process.versions["electron"]) {
- config.Scripting.enabled = true;
+ config.Scripting.backendScriptingEnabled = true;
config.Scripting.sqlConsoleEnabled = true;
}
diff --git a/apps/server/src/services/scripting_guard.ts b/apps/server/src/services/scripting_guard.ts
index 1e43352049..7d0c3655b1 100644
--- a/apps/server/src/services/scripting_guard.ts
+++ b/apps/server/src/services/scripting_guard.ts
@@ -5,12 +5,12 @@ import { isElectron } from "./utils.js";
* Throws if backend scripting is disabled. Desktop (Electron) always allows scripting.
*/
export function assertScriptingEnabled(): void {
- if (isElectron || config.Scripting.enabled) {
+ if (isElectron || config.Scripting.backendScriptingEnabled) {
return;
}
throw new Error(
- "Backend script execution is disabled. Set [Scripting] enabled=true in config.ini or " +
- "TRILIUM_SCRIPTING_ENABLED=true to enable. WARNING: Backend scripts have full server access."
+ "Backend script execution is disabled. Set [Scripting] backendScriptingEnabled=true in config.ini or " +
+ "TRILIUM_SCRIPTING_BACKEND_ENABLED=true to enable. WARNING: Backend scripts have full server access."
);
}
@@ -24,5 +24,5 @@ export function assertSqlConsoleEnabled(): void {
}
export function isScriptingEnabled(): boolean {
- return isElectron || config.Scripting.enabled;
+ return isElectron || config.Scripting.backendScriptingEnabled;
}
diff --git a/apps/server/src/share/routes.spec.ts b/apps/server/src/share/routes.spec.ts
index 0fcecd981a..1fe0024409 100644
--- a/apps/server/src/share/routes.spec.ts
+++ b/apps/server/src/share/routes.spec.ts
@@ -42,8 +42,8 @@ describe("Share API test", () => {
it("renders custom share template", async () => {
// Custom EJS templates require scripting to be enabled
- const originalEnabled = config.Scripting.enabled;
- config.Scripting.enabled = true;
+ const originalEnabled = config.Scripting.backendScriptingEnabled;
+ config.Scripting.backendScriptingEnabled = true;
try {
const response = await supertest(app)
.get("/share/pQvNLLoHcMwH")
@@ -52,7 +52,7 @@ describe("Share API test", () => {
expect(response.text).toContain("Content Start");
expect(response.text).toContain("Content End");
} finally {
- config.Scripting.enabled = originalEnabled;
+ config.Scripting.backendScriptingEnabled = originalEnabled;
}
});
diff --git a/apps/server/src/www.ts b/apps/server/src/www.ts
index 75f92804ce..046c205415 100644
--- a/apps/server/src/www.ts
+++ b/apps/server/src/www.ts
@@ -97,7 +97,7 @@ async function displayStartupMessage() {
getLog().info("WARNING: Backend script execution is ENABLED. Backend scripts have full server access including " +
"filesystem, network, and OS commands. Only enable in trusted environments.");
} else {
- getLog().info("Backend script execution is DISABLED. Set [Scripting] enabled=true in config.ini to enable.");
+ getLog().info("Backend script execution is DISABLED. Set [Scripting] backendScriptingEnabled=true in config.ini to enable.");
}
getLog().info("");
diff --git a/packages/trilium-core/src/services/config.ts b/packages/trilium-core/src/services/config.ts
index fe9390e1d7..f9014d30cb 100644
--- a/packages/trilium-core/src/services/config.ts
+++ b/packages/trilium-core/src/services/config.ts
@@ -20,7 +20,7 @@ export interface CoreConfig {
syncProxy: string;
};
Scripting: {
- enabled: boolean;
+ backendScriptingEnabled: boolean;
sqlConsoleEnabled: boolean;
};
}
@@ -36,7 +36,7 @@ const EMPTY_CONFIG: CoreConfig = {
syncProxy: ""
},
Scripting: {
- enabled: false,
+ backendScriptingEnabled: false,
sqlConsoleEnabled: false
}
};
diff --git a/packages/trilium-core/src/services/scripting_guard.ts b/packages/trilium-core/src/services/scripting_guard.ts
index f2d2fdfd52..ba9efcc9bb 100644
--- a/packages/trilium-core/src/services/scripting_guard.ts
+++ b/packages/trilium-core/src/services/scripting_guard.ts
@@ -5,12 +5,12 @@ import { isElectron } from "./utils/index.js";
* Throws if backend scripting is disabled. Desktop (Electron) always allows scripting.
*/
export function assertScriptingEnabled(): void {
- if (isElectron() || config.Scripting.enabled) {
+ if (isElectron() || config.Scripting.backendScriptingEnabled) {
return;
}
throw new Error(
- "Backend script execution is disabled. Set [Scripting] enabled=true in config.ini or " +
- "TRILIUM_SCRIPTING_ENABLED=true to enable. WARNING: Backend scripts have full server access."
+ "Backend script execution is disabled. Set [Scripting] backendScriptingEnabled=true in config.ini or " +
+ "TRILIUM_SCRIPTING_BACKEND_ENABLED=true to enable. WARNING: Backend scripts have full server access."
);
}
@@ -24,5 +24,5 @@ export function assertSqlConsoleEnabled(): void {
}
export function isScriptingEnabled(): boolean {
- return isElectron() || config.Scripting.enabled;
+ return isElectron() || config.Scripting.backendScriptingEnabled;
}