fix(artifacts): reject malformed serialized keys and integer values
This commit is contained in:
@@ -61,6 +61,13 @@ it.each([
|
||||
functions: [{ selector: "aabbccdd", bytecodeOffset: -1, dispatch: "abi" }],
|
||||
},
|
||||
{ metadata: {} },
|
||||
{
|
||||
metadata: {
|
||||
bytecodeOffset: 1,
|
||||
cborLength: 4,
|
||||
entries: [{ key: "reported", value: { type: "integer", value: 1.5 } }],
|
||||
},
|
||||
},
|
||||
])("rejects producer representations outside the selected profile", (raw) => {
|
||||
expect(() => projectEvmoleInterface(raw)).toThrow();
|
||||
});
|
||||
|
||||
@@ -9,7 +9,11 @@ const reportedMetadata = z.strictObject({
|
||||
key: z.string(),
|
||||
value: z.discriminatedUnion("type", [
|
||||
z.strictObject({ type: z.literal("string"), value: z.string() }),
|
||||
z.strictObject({ type: z.literal("integer"), value: z.number() }),
|
||||
z.strictObject({
|
||||
type: z.literal("integer"),
|
||||
// Reported integers can exceed the safe range; fractions still violate the tag.
|
||||
value: z.number().refine(Number.isInteger, "Expected an integer"),
|
||||
}),
|
||||
z.strictObject({ type: z.literal("bytes"), value: z.string() }),
|
||||
z.strictObject({ type: z.literal("bool"), value: z.boolean() }),
|
||||
z.strictObject({ type: z.literal("undecoded"), value: z.string() }),
|
||||
|
||||
Reference in New Issue
Block a user