no-electron-untrusted-open-external
Disallow untrusted or unsafe protocols in Electron shell.openExternal(...) calls.
Targeted pattern scopeโ
This rule targets direct shell.openExternal(...) and
electron.shell.openExternal(...) call sites.
What this rule reportsโ
This rule reports shell.openExternal(...) calls when the URL argument is
non-literal, dynamically constructed, or uses a protocol other than https: or
mailto:.
Why this rule existsโ
openExternal launches external handlers and browsers. Passing untrusted or
unexpected URLs can create phishing or command-surface abuse paths.
โ Incorrectโ
shell.openExternal("http://example.com");
shell.openExternal(userProvidedUrl);
shell.openExternal(`https://${host}`);
โ Correctโ
shell.openExternal("https://example.com/docs");
shell.openExternal("mailto:security@example.com");
ESLint flat config exampleโ
import sdl from "eslint-plugin-sdl-2";
export default [
{
plugins: { sdl },
rules: {
"sdl/no-electron-untrusted-open-external": "error",
},
},
];
When not to use itโ
Disable if your project uses a centralized URL-validation helper and dynamic
values are already strictly validated before openExternal.
Package documentationโ
Further readingโ
Rule catalog ID: R017