From 53be8a275330e03699e260012d0fb8284705d1bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Sundling?= Date: Mon, 24 Oct 2022 23:44:55 +0200 Subject: [PATCH] fix directory separator for xplat --- .ignoresecrets | 18 ++++++++++-------- Source/Private/GetExclusions.ps1 | 3 +++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/.ignoresecrets b/.ignoresecrets index f965180..74044d8 100644 --- a/.ignoresecrets +++ b/.ignoresecrets @@ -1,17 +1,19 @@ # Comments supported # Relative paths supported (starting with .\) -.\Docs\Help\Find-Secret.md -.\Source\config.json +./Docs/Help/Find-Secret.md +./Source/config.json # Wildcards supported. All files within this and subfolders will be excluded. -.\bin\* +./bin/* # Paths to files. All matches in these files will be excluded -.\Tests\RegexPatternTests\TestCases.json -C:\MyRepo\PSSecretScanner\README.md +./Tests/RegexPatternTests/TestCases.json +C:/MyRepo/PSSecretScanner/README.md + +# Any directory separator character should work (Linux and Windows) +.\README.md # Patterns on specific lines supported in the format -# ;; -.\ExcludeList.csv;1;"C:\BicepLab\template.json;51;-----BEGIN RSA PRIVATE KEY-----" -C:\MyRepo\PSSecretScanner\Docs\Help\Find-Secret.md;51;"C:\MyFiles\template.json;51;-----BEGIN RSA PRIVATE KEY-----" +# ;; +C:/MyRepo/PSSecretScanner/Docs/Help/Find-Secret.md;51;"C:\MyFiles\template.json;51;-----BEGIN RSA PRIVATE KEY-----" diff --git a/Source/Private/GetExclusions.ps1 b/Source/Private/GetExclusions.ps1 index 54c7f82..bdd4afc 100644 --- a/Source/Private/GetExclusions.ps1 +++ b/Source/Private/GetExclusions.ps1 @@ -9,6 +9,9 @@ function GetExclusions { foreach ($e in $Exclusions) { $eObj = ConvertFrom-Csv -InputObject $e -Delimiter ';' -Header 'Path', 'LineNumber', 'Line' + # Normalize path + $eObj.Path = $eObj.Path -replace '[\\\/]', [IO.Path]::DirectorySeparatorChar + if ($eObj.Path -match '^\..*') { # Path starts with '.', is relative. Replace with root folder $BasePath = split-path (Resolve-Path $Excludelist).Path