import { describe, expect, test } from 'bun:test' import { isProviderFilePath } from './provider-files.ts' describe('isProviderFilePath', () => { test('订阅缓存和规则清单的标准形状放行', () => { expect(isProviderFilePath('./providers/subs.yaml')).toBe(true) expect(isProviderFilePath('./providers/rules/ads.txt')).toBe(true) expect(isProviderFilePath('./providers/rules/直连清单.yaml')).toBe(true) }) test('目录逃逸和绝对路径全拦', () => { expect(isProviderFilePath('./providers/../config.yaml')).toBe(false) expect(isProviderFilePath('providers/subs.yaml')).toBe(false) expect(isProviderFilePath('/etc/mihomo/config.yaml')).toBe(false) expect(isProviderFilePath('./providers/rules/../../x.yaml')).toBe(false) expect(isProviderFilePath('./providers/a/b.yaml')).toBe(false) }) test('mrs 是二进制格式,不走文本上传', () => { expect(isProviderFilePath('./providers/rules/geo.mrs')).toBe(false) }) })