فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(holoo): restrict direct SQL preflight to verified lab target
Davood Mehraban committed
Nov 22, 2026 at 20:43 UTC
66a5f0431ae2964501d884ea73da3e4de11b35ff
2 files changed
+9
-2
scripts/holoo-direct-sql-readiness.ps1
+6
-1
@@ -4,7 +4,8 @@ param([string]$Server='ARAM\TNC',[string]$Database='HolooBackup_050808_LAB_20261
4
$ErrorActionPreference='Stop'
5
$checks=New-Object System.Collections.Generic.List[object]
6
function Add-Check($Name,$Status,$Detail){$checks.Add([pscustomobject]@{name=$Name;status=$Status;detail=$Detail})}
7
-if($Database -notmatch '^Holoo[A-Za-z0-9_]+LAB_[0-9]{8}$') {Add-Check 'database-selection' 'BLOCKED' 'Only explicitly named LAB databases are accepted'} else {Add-Check 'database-selection' 'PASS' 'Explicit LAB database selected'}
7
+if($Server -ne 'ARAM\TNC' -or $Database -ne 'HolooBackup_050808_LAB_20261110') {Add-Check 'database-selection' 'BLOCKED' 'Only the verified Aram SQL instance and disposable backup LAB database are accepted'} else {Add-Check 'database-selection' 'PASS' 'Explicit LAB database selected'}
8
+if ($checks[0].status -eq 'PASS') {
9
try {
10
Add-Type -AssemblyName System.Data
11
$c=New-Object System.Data.SqlClient.SqlConnection("Server=$Server;Database=master;Integrated Security=True;Connection Timeout=5")
@@ -18,7 +19,11 @@ try {
19
}
20
$r.Close();$c.Close()
21
} catch {Add-Check 'connection' 'BLOCKED' ('SQL connectivity failed: '+$_.Exception.GetType().Name)}
22
+}
23
$blocked=@($checks|Where-Object {$_.status -eq 'BLOCKED'}).Count
24
$result=[pscustomobject]@{schemaVersion=1;readyForLabSql=($blocked -eq 0);checks=$checks.ToArray();note='Readiness does not authorize writes or prove Holoo behavioral parity'}
25
if($Json){$result|ConvertTo-Json -Depth 5}else{$checks|Format-Table -AutoSize;Write-Output ('READY_FOR_LAB_SQL='+$result.readyForLabSql)}
26
if($blocked -gt 0){exit 2}
27
+
28
+
29
+
tests/holoo-direct-sql-readiness.test.mjs
+3
-1
@@ -3,7 +3,8 @@ import assert from 'node:assert/strict';
3
import { readFileSync } from 'node:fs';
4
const script = readFileSync(new URL('../scripts/holoo-direct-sql-readiness.ps1', import.meta.url), 'utf8');
5
test('direct SQL lab preflight is read-only and fails closed for non-lab databases', () => {
6
- assert.match(script, /Database -notmatch/);
6
+ assert.match(script, /Database -ne/);
7
+ assert.match(script, /Server -ne/);
8
assert.match(script, /LAB_/);
9
assert.match(script, /sys\.databases/);
10
assert.match(script, /readyForLabSql/);
@@ -12,3 +13,4 @@ test('direct SQL lab preflight is read-only and fails closed for non-lab databas
13
test('direct SQL lab preflight does not require a virtual machine or Hyper-V', () => {
14
assert.doesNotMatch(script, /Hyper-V|MSSQL\$FINORA_LAB|VirtualizationFirmwareEnabled/i);
15
});
16
+