From cee65d0b2e275221ea3bc3bbd6f20525aea054a4 Mon Sep 17 00:00:00 2001 From: 4gray Date: Fri, 17 Jul 2026 18:03:27 +0200 Subject: [PATCH] fix(packaging): reject inherited profile names --- tools/packaging/linux-frame-copy-profile.cjs | 5 ++--- .../packaging/linux-frame-copy-profile.test.mjs | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/tools/packaging/linux-frame-copy-profile.cjs b/tools/packaging/linux-frame-copy-profile.cjs index 6f00a0fab..85d505f82 100644 --- a/tools/packaging/linux-frame-copy-profile.cjs +++ b/tools/packaging/linux-frame-copy-profile.cjs @@ -51,13 +51,12 @@ function findLinuxFrameCopyProfile(value) { } const name = typeof value === 'string' ? value.trim() : String(value); - const profile = LINUX_FRAME_COPY_PROFILES[name]; - if (!profile) { + if (!Object.hasOwn(LINUX_FRAME_COPY_PROFILES, name)) { throw new Error( `Unsupported Linux frame-copy profile "${name}". Expected one of: ${expectedProfileNames()}.` ); } - return profile; + return LINUX_FRAME_COPY_PROFILES[name]; } function resolveLinuxFrameCopyProfile(value) { diff --git a/tools/packaging/linux-frame-copy-profile.test.mjs b/tools/packaging/linux-frame-copy-profile.test.mjs index 17af18438..2cae643f5 100644 --- a/tools/packaging/linux-frame-copy-profile.test.mjs +++ b/tools/packaging/linux-frame-copy-profile.test.mjs @@ -109,6 +109,23 @@ test('rejects missing and unsupported profile names with clear errors', () => { ); }); +test('rejects inherited object property names as unsupported profiles', () => { + for (const value of ['constructor', 'toString', '__proto__']) { + const unsupportedProfileError = new RegExp( + `Unsupported Linux frame-copy profile "${value}"` + ); + + assert.throws( + () => resolveLinuxFrameCopyProfile(value), + unsupportedProfileError + ); + assert.throws( + () => validateLinuxProfileTargets(value, ['deb']), + unsupportedProfileError + ); + } +}); + test('validates profile targets case-insensitively with deterministic errors', () => { const targets = ['DEB', 'AppImage', 'RPM'];