@@ -362,3 +362,40 @@ jobs:
362362 throw 'MAML help was not served on a case-sensitive filesystem.'
363363 }
364364 Write-Host 'All commands served full help from MAML.'
365+
366+ # The static analysis is the one part of the module a Linux host can use: it needs the
367+ # file and nothing else. This step keeps that true. The script type is inferred from
368+ # folder names, so the fixtures use the layouts the suite template describes, with the
369+ # separators this host writes; the harness and the log readers stay Windows-only.
370+ - name : Analyze scripts on Linux
371+ shell : pwsh
372+ run : |
373+ $ErrorActionPreference = 'Stop'
374+ Import-Module ./IntuneScriptLab.psd1 -Force
375+
376+ $root = Join-Path ([System.IO.Path]::GetTempPath()) "isl-linux-$([guid]::NewGuid().ToString('N'))"
377+ $remediation = Join-Path $root 'Remediations/Widget'
378+ $win32 = Join-Path $root 'Win32/Widget'
379+ New-Item -ItemType Directory -Path $remediation, $win32 -Force | Out-Null
380+ # return before exit 1: the remediation never runs (IslExitCodeIssue, Error)
381+ Set-Content -Path (Join-Path $remediation 'Detect.ps1') -Value "if (Test-Path /tmp/x) { return 'ok' }`nexit 1"
382+ # exit 0 with nothing on stdout: the app is never detected (IslOutputIssue, Error)
383+ Set-Content -Path (Join-Path $win32 'Detect.ps1') -Value "if (Test-Path /tmp/x) { exit 0 }`nexit 1"
384+
385+ $findings = @(Test-IntuneScript -Path $root)
386+ $findings | Format-Table Severity, RuleName, Line, @{ n = 'Script'; e = { Split-Path (Split-Path $_.ScriptPath) -Leaf } } -AutoSize | Out-String | Write-Host
387+
388+ $failed = @()
389+ $exit = @($findings | Where-Object { $_.RuleName -eq 'IslExitCodeIssue' -and $_.Severity -eq 'Error' -and $_.ScriptPath -like '*Remediations*' })
390+ if (-not $exit) { $failed += 'the return-before-exit detection was not reported' }
391+ $output = @($findings | Where-Object { $_.RuleName -eq 'IslOutputIssue' -and $_.Severity -eq 'Error' -and $_.ScriptPath -like '*Win32*' })
392+ if (-not $output) { $failed += 'the silent Win32 detection was not reported' }
393+ $context = @($findings | Where-Object { $_.RuleName -eq 'IslAssumedContext' -and $_.Message -like '*Win32Detection*' })
394+ if (-not $context) { $failed += 'the Win32 folder did not set the script type' }
395+ Remove-Item -Path $root -Recurse -Force
396+
397+ if ($failed) {
398+ $failed | ForEach-Object { Write-Host "FAILED: $_" }
399+ throw 'Test-IntuneScript did not analyze the fixtures on Linux.'
400+ }
401+ Write-Host 'Test-IntuneScript analyzed both fixtures on Linux with the expected findings.'
0 commit comments