Treasury & Bank Transfer Management System — سامانه مدیریت خزانهداری و حوالههای بانکی
phase-7-sql-readonly-ux-20261015
ci/public-windows-bridge-probe-20261017
ci/windows-dispatch-bootstrap-20261016
ci/windows-dual-app-lab-20261016
dev/v7-production-failclosed-20261021
feature/reconciliation-guard-20261013
main
phase-1-foundation
phase-1-implementation
phase-2-treasury-core
phase-3-banking-reconciliation
phase-4-operations-enterprise-ux
phase-5-hardening-release
phase-6-production-platform
phase-7-production-infrastructure-bank-golive
phase-7-sql-readonly-ux-20261015
transfer-exe-to-drive-20261006
| 1 | import {describe,expect,it} from 'vitest'; |
| 2 | import {prepareReadOnlySql,validateReadOnlySql,SAMPLE_READ_ONLY_SQL} from './read-only-query'; |
| 3 | describe('SQL Server read-only query contract',()=>{ |
| 4 | it('preserves approved sample',()=>expect(prepareReadOnlySql(SAMPLE_READ_ONLY_SQL)).toBe(SAMPLE_READ_ONLY_SQL)); |
| 5 | it('auto limits SELECT without TOP',()=>expect(prepareReadOnlySql('SELECT Name FROM dbo.Users')).toBe('SELECT TOP (100) Name FROM dbo.Users')); |
| 6 | it('keeps TOP <= 100',()=>expect(prepareReadOnlySql('SELECT TOP 15 Id FROM dbo.Users')).toBe('SELECT TOP 15 Id FROM dbo.Users')); |
| 7 | it.each([ |
| 8 | 'SELECT * INTO dbo.Copied FROM dbo.Source', |
| 9 | 'SELECT 1; DROP TABLE dbo.Users', |
| 10 | 'SELECT TOP 9999 * FROM dbo.Source', |
| 11 | "SELECT * FROM OPENROWSET(BULK 'f', SINGLE_BLOB)", |
| 12 | 'SELECT 1 -- comment', |
| 13 | 'SELECT 1 UNION SELECT 2', |
| 14 | ])('rejects unsafe SQL %s',q=>expect(validateReadOnlySql(q).ok).toBe(false)); |
| 15 | it('does not flag keywords inside SQL string literals',()=>expect(validateReadOnlySql("SELECT Code FROM dbo.Users WHERE Code='DROP;DELETE'").ok).toBe(true)); |
| 16 | }); |