Skip to content

Commit

Permalink
Adding vulnerabilityreporting coms
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusStorhaug committed Oct 30, 2023
1 parent 679e926 commit 1fc123e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
filter Disable-GitHubRepositoryPrivateVulnerabilityReporting {
<#
.SYNOPSIS
Disable private vulnerability reporting for a repository
.DESCRIPTION
Disables private vulnerability reporting for a repository. The authenticated user must have admin access
to the repository. For more information, see
"[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)".
.EXAMPLE
Disable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub'
Disables private vulnerability reporting for the PSModule/GitHub repository.
.NOTES
https://docs.github.com/rest/repos/repos#disable-private-vulnerability-reporting-for-a-repository
#>
[CmdletBinding(SupportsShouldProcess)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
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/private-vulnerability-reporting"
Method = 'DELETE'
}

if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Disable')) {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
filter Enable-GitHubRepositoryPrivateVulnerabilityReporting {
<#
.SYNOPSIS
Enable private vulnerability reporting for a repository
.DESCRIPTION
Enables private vulnerability reporting for a repository. The authenticated user must have admin access
to the repository. For more information, see
"[Privately reporting a security vulnerability](https://docs.github.com/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability)."
.EXAMPLE
Enable-GitHubRepositoryPrivateVulnerabilityReporting -Owner 'PSModule' -Repo 'GitHub'
Enables private vulnerability reporting for the PSModule/GitHub repository.
.NOTES
https://docs.github.com/rest/repos/repos#enable-private-vulnerability-reporting-for-a-repository
#>
[CmdletBinding(SupportsShouldProcess)]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidLongLines', '', Justification = 'Long links')]
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/private-vulnerability-reporting"
Method = 'PUT'
}

if ($PSCmdlet.ShouldProcess("Private Vulnerability Reporting for [$Owner/$Repo]", 'Enable')) {
Invoke-GitHubAPI @inputObject | ForEach-Object {
Write-Output $_.Response
}
}
}

0 comments on commit 1fc123e

Please sign in to comment.