Last active
July 3, 2024 14:11
-
-
Save felickz/9688dd0f5182cab22386efecfa41eb74 to your computer and use it in GitHub Desktop.
Count the secret scanning patterns from GHAS
This file contains 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
# Install the PowerShell-yaml module if not already installed | |
if (-not (Get-Module -Name PowerShell-yaml -ListAvailable)) { | |
Install-Module -Name PowerShell-yaml -Scope CurrentUser | |
} | |
# Read the YAML file from https://github.com/github/docs/blob/main/data/secret-scanning.yml | |
$url = 'https://raw.githubusercontent.com/github/docs/main/data/secret-scanning.yml' | |
$data = Invoke-RestMethod -Uri $url | ConvertFrom-Yaml | |
$inventory = @() | |
foreach ($node in $data) { | |
$inventory += New-Object PSObject -Property @{ | |
'Provider' = $node.provider | |
'SecretType' = $node.secretType | |
'HasPushProtection' = $node.hasPushProtection | |
#'OrigHasValidityCheck' = $node.hasValidityCheck | |
'HasValidityCheck' = $node.hasValidityCheck.ToString() -ne 'False' | |
} | |
} | |
#$inventory | Format-Table -AutoSize | |
$Providers = $inventory | Select-Object -Property Provider -Unique | |
$Push = $inventory | Where-Object { $_.HasPushProtection -eq $true } | Measure-Object | Select-Object -Property Count | |
$Validity = $inventory | Where-Object { $_.HasValidityCheck -eq $true } | Measure-Object | Select-Object -Property Count | |
Write-Host "Secret Scanning Inventory $($(Get-Date -AsUTC).ToString('u'))" | |
Write-Host "Number of Secret Types: $($inventory.Count)" | |
Write-Host "Number of Unique Providers: $($Providers.Count)" | |
Write-Host "Number of Secret Types with Push Protection: $($Push.Count)" | |
Write-Host "Number of Secret Types with Validity Check: $($Validity.Count)" | |
Write-Host "See: [Inventory Commit History](https://github.com/github/docs/commits/main/data/secret-scanning.yml) and [Secret Scanning Changelog](https://github.blog/changelog/label/secret-scanning)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Secret Scanning Inventory 2024-07-03 14:09:55Z
Number of Secret Types: 318
Number of Unique Providers: 124
Number of Secret Types with Push Protection: 190
Number of Secret Types with Validity Check: 38
Non-Partner Patterns: 8
See: Inventory Commit History and Secret Scanning Changelog