Skip to content

Commit

Permalink
ensure binaryChecksum for download is correct
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed May 6, 2023
1 parent 4ccb930 commit dcd3671
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion x-pack/plugins/screenshotting/server/browsers/install.ts
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ export async function install(
const binaryChecksum = await md5(binaryPath).catch(() => 'MISSING');

if (binaryChecksum === pkg.binaryChecksum) {
// validated a previously extracted browser binary
logger.info(`Browser executable: ${binaryPath}`);
// validated a previously downloaded browser
return binaryPath;
}

@@ -54,6 +54,17 @@ export async function install(
logger.error(error);
}

// check the newly extracted browser binary
const downloadedBinaryChecksum = await md5(binaryPath).catch(() => 'MISSING');
if (downloadedBinaryChecksum !== pkg.binaryChecksum) {
const error = new Error(
`Error installing browsers, binary checksums incorrect for [${architecture}/${platform}]`
);
logger?.error(error);

throw error;
}

logger.info(`Browser executable has been installed: ${binaryPath}`);

return binaryPath;

0 comments on commit dcd3671

Please sign in to comment.