Files
jobtrackingapp/docs/audits/2026-09-07/validation/evidence/b05-excel-probe.ps1
cesnimda 0954876295 fix(security): enforce audited account, network and resource boundaries
Implement B01-B06 with regression coverage and retained validation evidence. Preserve the production ingress preflight; F04 runtime verification remains open.
2026-09-09 18:21:47 +02:00

38 lines
1.8 KiB
PowerShell

param([string[]]$CsvPaths)
$ErrorActionPreference = 'Stop'
$excel = $null
$results = @()
try {
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $false
$excel.DisplayAlerts = $false
$excel.EnableEvents = $false
$excel.AskToUpdateLinks = $false
$excel.AutomationSecurity = 3
foreach ($csvPath in $CsvPaths) {
$book = $null
try {
$resolved = (Resolve-Path -LiteralPath $csvPath).Path
$book = $excel.Workbooks.Open($resolved, 0, $true)
$sheet = $book.Worksheets.Item(1)
$company = $sheet.Cells.Item(2, 1)
$title = $sheet.Cells.Item(2, 4)
$cells = @()
for ($column = 1; $column -le 17; $column++) {
$cell = $sheet.Cells.Item(2, $column)
$cells += [ordered]@{ column = $column; value = $cell.Value2; hasFormula = $cell.HasFormula }
[void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($cell)
}
$results += [ordered]@{ file = [IO.Path]::GetFileName($resolved); excelVersion = $excel.Version; company = $company.Value2; title = $title.Value2; titleHasFormula = $title.HasFormula; cells = $cells }
[void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($company)
[void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($title)
[void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($sheet)
} finally {
if ($null -ne $book) { $book.Close($false); [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($book) }
}
}
} finally {
if ($null -ne $excel) { $excel.Quit(); [void][Runtime.InteropServices.Marshal]::FinalReleaseComObject($excel) }
}
$results | ConvertTo-Json -Depth 6