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'];