Merge pull request #61 from bhaumikmaan/feat/security-fix-1

Fix URL check
main
Bhaumik Maan 2 years ago committed by GitHub
commit 46fe6b22fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -293,11 +293,19 @@ async function createWindow(): Promise<void> {
} }
state.mainWindow.webContents.setWindowOpenHandler(({ url }) => { state.mainWindow.webContents.setWindowOpenHandler(({ url }) => {
console.log("Attempting to open URL:", url) console.log("Attempting to open URL:", url)
if (url.includes("google.com") || url.includes("supabase.co")) { try {
shell.openExternal(url) const parsedURL = new URL(url);
return { action: "deny" } const hostname = parsedURL.hostname;
const allowedHosts = ["google.com", "supabase.co"];
if (allowedHosts.includes(hostname) || hostname.endsWith(".google.com") || hostname.endsWith(".supabase.co")) {
shell.openExternal(url);
return { action: "deny" }; // Do not open this URL in a new Electron window
}
} catch (error) {
console.error("Invalid URL %d in setWindowOpenHandler: %d" , url , error);
return { action: "deny" }; // Deny access as URL string is malformed or invalid
} }
return { action: "allow" } return { action: "allow" };
}) })
// Enhanced screen capture resistance // Enhanced screen capture resistance

Loading…
Cancel
Save