Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions packages/launcher/scripts/azure-sign.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { execSync } = require("child_process");
const { execFileSync } = require("child_process");
const path = require("path");

// Custom sign function for electron-builder using Azure Trusted Signing.
Expand Down Expand Up @@ -29,6 +29,31 @@ exports.default = async function azureSign(configuration) {
return;
}

let parsedEndpoint;
try {
parsedEndpoint = new URL(endpoint);
} catch (_err) {
throw new Error("Invalid AZURE_ENDPOINT format.");
}

if (parsedEndpoint.protocol !== "https:") {
throw new Error("AZURE_ENDPOINT must use https.");
}

if (!/^[a-zA-Z0-9][a-zA-Z0-9-]{0,62}$/.test(account)) {
throw new Error("Invalid AZURE_CODE_SIGNING_ACCOUNT format.");
}

if (!/^[a-zA-Z0-9._-]+$/.test(certProfile)) {
throw new Error("Invalid AZURE_CERT_PROFILE format.");
}

if (typeof filePath !== "string" || filePath.includes("\0")) {
throw new Error("Invalid file path for signing.");
}

const signTarget = path.resolve(filePath);

console.log(`Signing: ${path.basename(filePath)}`);

const args = [
Expand All @@ -38,11 +63,11 @@ exports.default = async function azureSign(configuration) {
"-c", certProfile,
"-r", "http://timestamp.acs.microsoft.com",
"-d", "sha256",
filePath,
signTarget,
];

try {
execSync(`sign code ${args.join(" ")}`, {
execFileSync("sign", ["code", ...args], {
stdio: "inherit",
timeout: 120000,
});
Expand Down
2 changes: 0 additions & 2 deletions packages/launcher/src/main/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ contextBridge.exposeInMainWorld('api', {

// Shell
openExternal: (url) => ipcRenderer.invoke('shell:open-external', url),
shellExec: (cmd) => ipcRenderer.invoke('shell:exec', cmd),
openTerminal: (cmd) => ipcRenderer.invoke('shell:open-terminal', cmd),
updateCore: () => ipcRenderer.invoke('core:update'),
onCoreUpdate: (cb) => ipcRenderer.on('core-update-available', (_e, info) => cb(info)),

Expand Down
Loading