发布 0.2.1 并完善工具边界与安全性

This commit is contained in:
mid
2026-08-10 14:49:43 +08:00
parent aca004c513
commit 32b7cc827c
47 changed files with 681 additions and 172 deletions
+11
View File
@@ -1,5 +1,6 @@
import { describe, expect, it } from 'vitest'
import {
DEFAULT_MAX_INTEL_HEX_BYTES,
DEFAULT_MAX_INTEL_HEX_RECORDS,
MAX_UINT32_ADDRESS,
parseIntelHex,
@@ -63,6 +64,16 @@ describe('Intel HEX structural limits', () => {
expect(() => parseIntelHex(record(0, 0, [1]), { maxRecords: 1.5 })).toThrow('正整数')
expect(() => parseIntelHex(record(0, 0, [1]), { maxRecords: Number.POSITIVE_INFINITY })).toThrow('正整数')
expect(() => parseIntelHex(record(0, 0, [1]), { maxRecords: Number.MAX_SAFE_INTEGER + 1 })).toThrow('正整数')
expect(() => parseIntelHex(record(0, 0, [1]), { maxBytes: 0 })).toThrow('正整数')
expect(DEFAULT_MAX_INTEL_HEX_BYTES).toBe(64 * 1024 * 1024)
})
it('rejects a merged data block before allocating beyond the byte limit', () => {
expect(() => parseIntelHex([
record(0, 0, [0xaa]),
record(1, 0, [0xbb]),
eof,
].join('\n'), { maxBytes: 1 })).toThrow('有效数据不能超过 1 bytes')
})
it('rejects records after EOF and malformed control records', () => {