mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
fix(code-runtime): reject forged container prototypes
This commit is contained in:
@@ -97,6 +97,19 @@ describe('snapshotCodeJsonValue', () => {
|
||||
Object.setPrototypeOf(forgedPrototype, null)
|
||||
const forgedArray = [1]
|
||||
Object.setPrototypeOf(forgedArray, forgedPrototype)
|
||||
const spoofedObjectPrototype = Object.create(null) as Record<string, unknown>
|
||||
const SpoofedObject = function Object() {}
|
||||
SpoofedObject.prototype = spoofedObjectPrototype
|
||||
Object.defineProperty(spoofedObjectPrototype, 'constructor', { value: SpoofedObject })
|
||||
const spoofedObject = Object.create(spoofedObjectPrototype) as Record<string, unknown>
|
||||
spoofedObject.value = 1
|
||||
const spoofedArrayPrototype: unknown[] = []
|
||||
Object.setPrototypeOf(spoofedArrayPrototype, Object.prototype)
|
||||
const SpoofedArray = function Array() {}
|
||||
SpoofedArray.prototype = spoofedArrayPrototype
|
||||
Object.defineProperty(spoofedArrayPrototype, 'constructor', { value: SpoofedArray })
|
||||
const spoofedArray = [1]
|
||||
Object.setPrototypeOf(spoofedArray, spoofedArrayPrototype)
|
||||
|
||||
for (const value of [
|
||||
new ExoticObject(),
|
||||
@@ -110,11 +123,15 @@ describe('snapshotCodeJsonValue', () => {
|
||||
symbolObject,
|
||||
customPrototypeObject,
|
||||
forgedArray,
|
||||
spoofedObject,
|
||||
spoofedArray,
|
||||
cyclic,
|
||||
[undefined],
|
||||
{ value: undefined },
|
||||
]) {
|
||||
expect(snapshotCodeJsonValue(value)).toBeUndefined()
|
||||
const canonical = snapshotJsonValue(value)
|
||||
expect(canonical).toBeUndefined()
|
||||
expect(snapshotCodeJsonValue(value)).toEqual(canonical)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user