-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1fc123e
commit 9e7a3c7
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/GitHub/public/Repositories/Repositories/Test-GitHubRepositoryVulnerabilityAlert.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
filter Test-GitHubRepositoryVulnerabilityAlert { | ||
<# | ||
.SYNOPSIS | ||
Check if vulnerability alerts are enabled for a repository | ||
.DESCRIPTION | ||
Shows whether dependency alerts are enabled or disabled for a repository. | ||
The authenticated user must have admin read access to the repository. | ||
For more information, see | ||
"[About security alerts for vulnerable dependencies](https://docs.github.com/articles/about-security-alerts-for-vulnerable-dependencies)". | ||
.EXAMPLE | ||
Test-GitHubRepositoryVulnerabilityAlert -Owner 'PSModule' -Repo 'GitHub' | ||
Checks if vulnerability alerts are enabled for the PSModule/GitHub repository. | ||
.NOTES | ||
https://docs.github.com/rest/repos/repos#list-repository-tags | ||
#> | ||
[OutputType([bool])] | ||
[CmdletBinding()] | ||
[Alias('Test-GitHubRepositoryVulnerabilityAlerts')] | ||
param ( | ||
# The account owner of the repository. The name is not case sensitive. | ||
[Parameter()] | ||
[Alias('org')] | ||
[string] $Owner = (Get-GitHubConfig -Name Owner), | ||
|
||
# The name of the repository without the .git extension. The name is not case sensitive. | ||
[Parameter()] | ||
[string] $Repo = (Get-GitHubConfig -Name Repo) | ||
) | ||
|
||
$inputObject = @{ | ||
APIEndpoint = "/repos/$Owner/$Repo/vulnerability-alerts" | ||
Method = 'GET' | ||
} | ||
|
||
try { | ||
(Invoke-GitHubAPI @inputObject).StatusCode -eq 204 | ||
} catch { | ||
if ($_.Exception.Response.StatusCode.Value__ -eq 404) { | ||
return $false | ||
} else { | ||
throw $_ | ||
} | ||
} | ||
} |