From dcd24d94a99b497e63f29c764ffab030f52339ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Fri, 22 Nov 2024 14:16:40 +0100 Subject: [PATCH] :lipstick: (#234417) --- build/azure-pipelines/common/sign.js | 4 ++-- build/azure-pipelines/common/sign.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build/azure-pipelines/common/sign.js b/build/azure-pipelines/common/sign.js index 7b4b620d1fa..df25de29399 100644 --- a/build/azure-pipelines/common/sign.js +++ b/build/azure-pipelines/common/sign.js @@ -128,10 +128,10 @@ function main([esrpCliPath, type, folderPath, pattern]) { process.on('exit', () => tmp.dispose()); const key = crypto.randomBytes(32); const iv = crypto.randomBytes(16); - const encryptionDetailsPath = tmp.tmpNameSync(); - fs.writeFileSync(encryptionDetailsPath, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') })); const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); const encryptedToken = cipher.update(process.env['SYSTEM_ACCESSTOKEN'].trim(), 'utf8', 'hex') + cipher.final('hex'); + const encryptionDetailsPath = tmp.tmpNameSync(); + fs.writeFileSync(encryptionDetailsPath, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') })); const encryptedTokenPath = tmp.tmpNameSync(); fs.writeFileSync(encryptedTokenPath, encryptedToken); const patternPath = tmp.tmpNameSync(); diff --git a/build/azure-pipelines/common/sign.ts b/build/azure-pipelines/common/sign.ts index df8e26ff921..e5f42e87da2 100644 --- a/build/azure-pipelines/common/sign.ts +++ b/build/azure-pipelines/common/sign.ts @@ -140,11 +140,12 @@ export function main([esrpCliPath, type, folderPath, pattern]: string[]) { const key = crypto.randomBytes(32); const iv = crypto.randomBytes(16); + const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); + const encryptedToken = cipher.update(process.env['SYSTEM_ACCESSTOKEN']!.trim(), 'utf8', 'hex') + cipher.final('hex'); + const encryptionDetailsPath = tmp.tmpNameSync(); fs.writeFileSync(encryptionDetailsPath, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') })); - const cipher = crypto.createCipheriv('aes-256-cbc', key, iv); - const encryptedToken = cipher.update(process.env['SYSTEM_ACCESSTOKEN']!.trim(), 'utf8', 'hex') + cipher.final('hex'); const encryptedTokenPath = tmp.tmpNameSync(); fs.writeFileSync(encryptedTokenPath, encryptedToken);