mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Prevent caller overrides from replacing the authorized card identity before private children are loaded. Apply title and description strings to a separate transformed card; refuse all other fields before copying. Summarize extra-field attempts as CopyIdentityBleed while treating malformed text as an ordinary input error. Add unit, source-scan and live browser regressions, and document the reproduced disclosure and remaining review. Update the shared-form regression for the existing multiline title editor. Thanks to xet7 !
19 lines
981 B
JavaScript
19 lines
981 B
JavaScript
'use strict';
|
|
|
|
// The copy dialog edits text, never the identity/placement used to load children
|
|
// or the transformed document's methods. Retain its prototype without mutating
|
|
// the source object returned by ReactiveCache.
|
|
function cardWithCopyOverrides(card, values) {
|
|
if (!values || Object.getPrototypeOf(values) !== Object.prototype ||
|
|
Object.keys(values).some(key => !['title', 'description'].includes(key) || typeof values[key] !== 'string')) {
|
|
const error = new Error('Invalid card copy overrides');
|
|
// Malformed title/description text can come from a mistaken bulk-copy form.
|
|
// Only attempts to supply fields outside that contract are security events.
|
|
error.securityAttempt = !!values && typeof values === 'object' &&
|
|
Object.keys(values).some(key => !['title', 'description'].includes(key));
|
|
throw error;
|
|
}
|
|
return Object.assign(Object.create(Object.getPrototypeOf(card)), card, values);
|
|
}
|
|
module.exports = { cardWithCopyOverrides };
|