فینورا پرو - سامانه جامع حسابداری و صدور فاکتور
fix(a02): ensure PowerShell DataTable return is not enumerated and selftest accepts escaped literal
davoodmehraban89 committed
Oct 30, 2026 at 17:11 UTC
f64fb01cf2fcf8485413400fb0ed655322624739
1 file changed
+6
-7
scripts/a02-sql-backup-readonly-preflight.ps1
+6
-7
@@ -64,7 +64,7 @@ function Invoke-SqlTable($Connection, [string]$Query) {
64
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter($command)
65
try {
66
[void]$adapter.Fill($table)
67
- return $table
67
+ return ,$table
68
} finally {
69
$adapter.Dispose()
70
$command.Dispose()
@@ -83,12 +83,11 @@ if ($SelfTest) {
83
$commands.Verify -notlike 'RESTORE VERIFYONLY FROM DISK = N*') {
84
throw 'SELFTEST_COMMAND_SCOPE_FAILED'
85
}
86
- if (($commands.Values | Where-Object {
87
- $_ -match '(?i)\b(CREATE|DROP|ALTER|REPLACE|ATTACH|DETACH)\s+(DATABASE|TABLE)\b'
88
- }).Count -gt 0) {
89
- # Synthetic injection string is inside a quoted SQL literal; this
90
- # test must instead establish proper doubled quote escape above.
91
- throw 'SELFTEST_UNEXPECTED_SQL'
86
+ # The synthetic SQL-like text is deliberately part of the quoted
87
+ # filename; its embedded single quote has been escaped to two quotes.
88
+ if ($commands.Header -ne ('RESTORE HEADERONLY FROM DISK = N' +
89
+ "'" + $testPath.Replace("'", "''") + "'")) {
90
+ throw 'SELFTEST_SQL_LITERAL_MISMATCH'
91
}
92
@{ status = 'selftest-passed'; sourceRead = $false; connectionOpened = $false;
93
databaseModified = $false; canImport = $false } |