-
Notifications
You must be signed in to change notification settings - Fork 4
fix(source-clean): scan every tracked file and test rejection fixtures #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
cd30be0
fix(source-clean): remove whole-file exemptions and exercise the stri…
masarray c1dabb9
fix(source-clean): remove whole-file exemptions and exercise the stri…
masarray ec5a94b
fix(source-clean): remove whole-file exemptions and exercise the stri…
masarray 6229e27
test(source-clean): add end-to-end negative fixtures for every tracke…
masarray 50c73d6
fix(source-clean): detect prohibited identifiers embedded in symbols
masarray 642d20a
test(source-clean): require fully scoped identifier scanning
masarray 52889b9
fix(test): repair source-clean invariant assertion formatting
masarray d74ffa3
fix(test): use real newline in source-clean invariant assertions
masarray 4500edf
fix(ci): capture expected source-clean failures without native stderr…
masarray 72b07f8
perf(ci): cache clean-room identifier fingerprints
masarray File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # Copyright 2026 Ari Sulistiono | ||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||
| <# | ||
| Tests the complete source-clean scanner against temporary Git-tracked fixtures. | ||
| Construct the known test identifier from code points so this test file itself | ||
| does not need an exemption from the same clean-room gate. | ||
| #> | ||
| [CmdletBinding()] | ||
| param() | ||
|
|
||
| $ErrorActionPreference = "Stop" | ||
| $scanner = Join-Path $PSScriptRoot "verify-source-clean.ps1" | ||
| $identifier = -join (@(73, 69, 68, 83, 99, 111, 117, 116) | ForEach-Object { [char]$_ }) | ||
| $cases = @( | ||
| @{ Path = "Services/Fixture.cs"; Text = "public sealed class ${identifier}Fixture {}"; Expected = "text" }, | ||
| @{ Path = "docs/reference.md"; Text = "# $identifier"; Expected = "text" }, | ||
| @{ Path = "evidence/fixture.json"; Text = "{`"reference`": `"$identifier`"}"; Expected = "text" }, | ||
| @{ Path = ".github/workflows/smart-discovery-post-merge-production.yml"; Text = "name: $identifier"; Expected = "text" }, | ||
| @{ Path = "tests/ARSAS.Tests/SyntheticFixture.cs"; Text = "// $identifier"; Expected = "text" }, | ||
| @{ Path = "docs/${identifier}-fixture.md"; Text = "# independently generated fixture"; Expected = "path" } | ||
| ) | ||
|
|
||
| function Invoke-Case { | ||
| param( | ||
| [Parameter(Mandatory=$true)][string]$RelativePath, | ||
| [Parameter(Mandatory=$true)][string]$Content, | ||
| [Parameter(Mandatory=$true)][bool]$MustReject, | ||
| [string]$Expected = "text" | ||
| ) | ||
| $root = Join-Path ([IO.Path]::GetTempPath()) ("arsas-clean-room-" + [guid]::NewGuid().ToString("N")) | ||
| New-Item -ItemType Directory -Path $root -Force | Out-Null | ||
| try { | ||
| & git -C $root init --quiet | ||
| if ($LASTEXITCODE -ne 0) { throw "Fixture Git initialization failed." } | ||
| $file = Join-Path $root ($RelativePath.Replace('/', [IO.Path]::DirectorySeparatorChar)) | ||
| New-Item -ItemType Directory -Path (Split-Path $file) -Force | Out-Null | ||
| [IO.File]::WriteAllText($file, $Content, [Text.UTF8Encoding]::new($false)) | ||
| & git -C $root add --all | ||
| if ($LASTEXITCODE -ne 0) { throw "Fixture Git staging failed." } | ||
|
|
||
| $startInfo = [System.Diagnostics.ProcessStartInfo]::new() | ||
| $startInfo.FileName = "powershell.exe" | ||
| $startInfo.UseShellExecute = $false | ||
| $startInfo.CreateNoWindow = $true | ||
| $startInfo.RedirectStandardOutput = $true | ||
| $startInfo.RedirectStandardError = $true | ||
|
|
||
| $quotedScanner = '"' + $scanner.Replace('"', '\"') + '"' | ||
| $quotedRoot = '"' + $root.Replace('"', '\"') + '"' | ||
| $startInfo.Arguments = "-NoProfile -ExecutionPolicy Bypass -File $quotedScanner -RepositoryRoot $quotedRoot -ScanOnly" | ||
|
|
||
| $process = [System.Diagnostics.Process]::new() | ||
| $process.StartInfo = $startInfo | ||
| if (-not $process.Start()) { | ||
| throw "Source-clean fixture scanner failed to start." | ||
| } | ||
|
|
||
| $stdoutTask = $process.StandardOutput.ReadToEndAsync() | ||
| $stderrTask = $process.StandardError.ReadToEndAsync() | ||
| $process.WaitForExit() | ||
| $stdout = $stdoutTask.GetAwaiter().GetResult() | ||
| $stderr = $stderrTask.GetAwaiter().GetResult() | ||
| $exitCode = $process.ExitCode | ||
| $output = @($stdout, $stderr) -join [Environment]::NewLine | ||
| $process.Dispose() | ||
| if ($MustReject) { | ||
| if ($exitCode -eq 0 -or $output -notmatch ("Forbidden external identifier in " + $Expected)) { | ||
| throw "Source-clean unexpectedly accepted a forbidden $Expected fixture: $RelativePath; exit=$exitCode; output=$output" | ||
| } | ||
| } | ||
| elseif ($exitCode -ne 0) { | ||
| throw "Source-clean rejected a neutral fixture: $RelativePath; exit=$exitCode; output=$output" | ||
| } | ||
| } | ||
| finally { | ||
| Remove-Item -LiteralPath $root -Recurse -Force -ErrorAction SilentlyContinue | ||
| } | ||
| } | ||
|
|
||
| foreach ($case in $cases) { | ||
| Invoke-Case -RelativePath $case.Path -Content $case.Text -MustReject $true -Expected $case.Expected | ||
| } | ||
| Invoke-Case -RelativePath "docs/synthetic-reference.md" -Content "# ARSAS independent IEC 61850 synthetic evidence" -MustReject $false | ||
| Write-Host "Source-clean negative and positive fixture tests PASS." -ForegroundColor Green |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
scripts/verify-source-clean.ps1itself contains a prohibited plain-text identifier, the gate still accepts it because the loop reachesif ($relative -eq "scripts/verify-source-clean.ps1") { continue }before reading its content. This contradicts the newly stated no-whole-file-exemption invariant, and the fixture suite does not expose it because the scanner executable lives outside each temporary repository. Move the self-skip after the external-identifier check (skipping only the embedded policy-pattern checks) and add a fixture using this reserved path.AGENTS.md reference: AGENTS.md:L172-L176
Useful? React with 👍 / 👎.