diff --git a/Coverage.md b/Coverage.md index 1a59c8f47..e65516446 100644 --- a/Coverage.md +++ b/Coverage.md @@ -5,19 +5,19 @@ - + - + - + - +
Available functions980992
Covered functions156159
Missing functions824833
Coverage15.92%16.03%
@@ -30,10 +30,10 @@ | `/advisories/{ghsa_id}` | | :x: | | | | | `/app` | | :white_check_mark: | | | | | `/app-manifests/{code}/conversions` | | | | :x: | | -| `/app/hook/config` | | :white_check_mark: | :x: | | | +| `/app/hook/config` | | :white_check_mark: | :white_check_mark: | | | | `/app/hook/deliveries` | | :white_check_mark: | | | | -| `/app/hook/deliveries/{delivery_id}` | | :x: | | | | -| `/app/hook/deliveries/{delivery_id}/attempts` | | | | :x: | | +| `/app/hook/deliveries/{delivery_id}` | | :white_check_mark: | | | | +| `/app/hook/deliveries/{delivery_id}/attempts` | | | | :white_check_mark: | | | `/app/installation-requests` | | :x: | | | | | `/app/installations` | | :white_check_mark: | | | | | `/app/installations/{installation_id}` | :x: | :x: | | | | @@ -52,6 +52,12 @@ | `/codes_of_conduct` | | :x: | | | | | `/codes_of_conduct/{key}` | | :x: | | | | | `/emojis` | | :white_check_mark: | | | | +| `/enterprises/{enterprise}/code-security/configurations` | | :x: | | :x: | | +| `/enterprises/{enterprise}/code-security/configurations/defaults` | | :x: | | | | +| `/enterprises/{enterprise}/code-security/configurations/{configuration_id}` | :x: | :x: | :x: | | | +| `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/attach` | | | | :x: | | +| `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/defaults` | | | | | :x: | +| `/enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories` | | :x: | | | | | `/enterprises/{enterprise}/dependabot/alerts` | | :x: | | | | | `/enterprises/{enterprise}/secret-scanning/alerts` | | :x: | | | | | `/events` | | :white_check_mark: | | | | @@ -348,6 +354,8 @@ | `/repos/{owner}/{repo}/check-suites/{check_suite_id}/rerequest` | | | | :x: | | | `/repos/{owner}/{repo}/code-scanning/alerts` | | :x: | | | | | `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}` | | :x: | :x: | | | +| `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix` | | :x: | | :x: | | +| `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/autofix/commits` | | | | :x: | | | `/repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances` | | :x: | | | | | `/repos/{owner}/{repo}/code-scanning/analyses` | | :x: | | | | | `/repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}` | :x: | :x: | | | | diff --git a/src/functions/private/Apps/Get-GitHubAppByName.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 similarity index 100% rename from src/functions/private/Apps/Get-GitHubAppByName.ps1 rename to src/functions/private/Apps/GitHub Apps/Get-GitHubAppByName.ps1 diff --git a/src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1 b/src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 similarity index 100% rename from src/functions/private/Apps/Get-GitHubAuthenticatedApp.ps1 rename to src/functions/private/Apps/GitHub Apps/Get-GitHubAuthenticatedApp.ps1 diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 new file mode 100644 index 000000000..9d0d0be35 --- /dev/null +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByID.ps1 @@ -0,0 +1,60 @@ +function Get-GitHubAppWebhookDeliveryByID { + <# + .SYNOPSIS + Get a delivery for an app webhook + + .DESCRIPTION + Returns a delivery for the webhook configured for a GitHub App. + + You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) + to access this endpoint. + + + .EXAMPLE + Get-GitHubAppWebhookDeliveryByID -ID 123456 + + Returns the webhook configuration for the authenticated app. + + .NOTES + [Get a delivery for an app webhook](https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook) + #> + [CmdletBinding()] + param( + # The ID of the delivery. + [Parameter(Mandatory)] + [Alias('DeliveryID', 'delivery_id')] + [string] $ID, + + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. + [Parameter()] + [object] $Context = (Get-GitHubContext) + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + $Context = Resolve-GitHubContext -Context $Context + Assert-GitHubContext -Context $Context -AuthType APP + } + + process { + try { + $inputObject = @{ + Context = $Context + APIEndpoint = "/app/hook/deliveries/$ID" + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} diff --git a/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 new file mode 100644 index 000000000..9aea3c270 --- /dev/null +++ b/src/functions/private/Apps/Webhooks/Get-GitHubAppWebhookDeliveryByList.ps1 @@ -0,0 +1,54 @@ +function Get-GitHubAppWebhookDeliveryByList { + <# + .SYNOPSIS + List deliveries for an app webhook + + .DESCRIPTION + Returns a list of webhook deliveries for the webhook configured for a GitHub App. + + You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) + to access this endpoint. + + .EXAMPLE + Get-GitHubAppWebhookDeliveryByList + + Returns the webhook configuration for the authenticated app. + + .NOTES + [Get a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app) + #> + [CmdletBinding()] + param( + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. + [Parameter()] + [object] $Context = (Get-GitHubContext) + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + $Context = Resolve-GitHubContext -Context $Context + Assert-GitHubContext -Context $Context -AuthType APP + } + + process { + try { + $inputObject = @{ + Context = $Context + APIEndpoint = '/app/hook/deliveries' + Method = 'GET' + } + + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} diff --git a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 index a548e8e92..8b8518977 100644 --- a/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 +++ b/src/functions/public/Apps/Webhooks/Get-GitHubAppWebhookDelivery.ps1 @@ -1,10 +1,10 @@ function Get-GitHubAppWebhookDelivery { <# .SYNOPSIS - List deliveries for an app webhook + List deliveries for an app webhook or get a delivery for an app webhook by ID. .DESCRIPTION - Returns a list of webhook deliveries for the webhook configured for a GitHub App. + Returns a list of webhook deliveries or a specific delivery for the webhook configured for a GitHub App. You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) to access this endpoint. @@ -12,13 +12,29 @@ .EXAMPLE Get-GitHubAppWebhookDelivery - Returns the webhook configuration for the authenticated app. + Returns a list of webhook deliveries for the webhook for the authenticated app. + + .EXAMPLE + Get-GitHubAppWebhookDelivery -ID 123456 + + Returns the webhook delivery with the ID `123456` for the authenticated app. .NOTES + [Get a delivery for an app webhook](https://docs.github.com/rest/apps/webhooks#get-a-delivery-for-an-app-webhook) [Get a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app) #> - [CmdletBinding()] + [CmdletBinding(DefaultParameterSetName = '__AllParameterSets')] param( + # The ID of the delivery. + [Parameter( + Mandatory, + ParameterSetName = 'ByID', + ValueFromPipeline, + ValueFromPipelineByPropertyName + )] + [Alias('DeliveryID', 'delivery_id')] + [string] $ID, + # The context to run the command in. Used to get the details for the API call. # Can be either a string or a GitHubContext object. [Parameter()] @@ -34,14 +50,13 @@ process { try { - $inputObject = @{ - Context = $Context - APIEndpoint = '/app/hook/deliveries' - Method = 'GET' - } - - Invoke-GitHubAPI @inputObject | ForEach-Object { - Write-Output $_.Response + switch ($PSCmdlet.ParameterSetName) { + 'ByID' { + Get-GitHubAppWebhookDeliveryByID -ID $ID -Context $Context + } + '__AllParameterSets' { + Get-GitHubAppWebhookDeliveryByList -Context $Context + } } } catch { throw $_ diff --git a/src/functions/public/Apps/Webhooks/Redeliver-GitHubAppWebhookDelivery.ps1 b/src/functions/public/Apps/Webhooks/Redeliver-GitHubAppWebhookDelivery.ps1 new file mode 100644 index 000000000..a837dbe87 --- /dev/null +++ b/src/functions/public/Apps/Webhooks/Redeliver-GitHubAppWebhookDelivery.ps1 @@ -0,0 +1,66 @@ +function Redeliver-GitHubAppWebhookDelivery { + <# + .SYNOPSIS + Redeliver a delivery for an app webhook + + .DESCRIPTION + Redeliver a delivery for the webhook configured for a GitHub App. + + You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) + to access this endpoint. + + .EXAMPLE + Redeliver-GitHubAppWebhookDelivery -ID 12345 + + Redelivers the delivery with the ID `12345`. + + .NOTES + [Redeliver a delivery for an app webhook](https://docs.github.com/rest/apps/webhooks#redeliver-a-delivery-for-an-app-webhook) + #> + [OutputType([void])] + [CmdletBinding(SupportsShouldProcess)] + [Diagnostics.CodeAnalysis.SuppressMessageAttribute( + 'PSUseApprovedVerbs', '', Scope = 'Function', + Justification = 'Redeliver is the only thing that makes sense when triggering a webhook delivery again.' + )] + param( + # The ID of the delivery. + [Parameter(Mandatory)] + [Alias('DeliveryID', 'delivery_id')] + [string] $ID, + + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. + [Parameter()] + [object] $Context = (Get-GitHubContext) + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + $Context = Resolve-GitHubContext -Context $Context + Assert-GitHubContext -Context $Context -AuthType APP + } + + process { + try { + $inputObject = @{ + Context = $Context + APIEndpoint = "/app/hook/deliveries/$ID/attempts" + Method = 'post' + } + + if ($PSCmdlet.ShouldProcess('webhook delivery', 'Redeliver')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +} diff --git a/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 new file mode 100644 index 000000000..5bf4316c1 --- /dev/null +++ b/src/functions/public/Apps/Webhooks/Update-GitHubAppWebhookConfiguration.ps1 @@ -0,0 +1,84 @@ +function Update-GitHubAppWebhookConfiguration { + <# + .SYNOPSIS + Update a webhook configuration for an app + + .DESCRIPTION + Updates the webhook configuration for a GitHub App. For more information about configuring a webhook for your app, see + "[Creating a GitHub App](/developers/apps/creating-a-github-app)." + + You must use a [JWT](https://docs.github.com/apps/building-github-apps/authenticating-with-github-apps/#authenticating-as-a-github-app) + to access this endpoint. + + .EXAMPLE + Update-GitHubAppWebhookConfiguration -URL 'https://example.com' -ContentType 'json' -Secret 'mysecret' -InsecureSSL + + Updates the webhook configuration for the authenticated app to deliver payloads to `https://example.com` with a `json` content type + and a secret of `mysecret` disabling SSL verification when delivering payloads. + + .NOTES + [Update a webhook configuration for an app](https://docs.github.com/rest/apps/webhooks#update-a-webhook-configuration-for-an-app) + #> + [OutputType([void])] + [CmdletBinding(SupportsShouldProcess)] + param( + # The URL to which the payloads will be delivered. + [Parameter()] + [string] $URL, + + # The media type used to serialize the payloads. Supported values include `json` and `form`. + [Parameter()] + [ValidateSet('json', 'form')] + [string] $ContentType, + + # If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for delivery signature headers. + [Parameter()] + [string] $Secret, + + # Determines whether the SSL certificate of the host for URL will be verified when delivering payloads. + # We strongly recommend not setting this as you are subject to man-in-the-middle and other attacks. + [switch] $InsecureSSL, + + # The context to run the command in. Used to get the details for the API call. + # Can be either a string or a GitHubContext object. + [Parameter()] + [object] $Context = (Get-GitHubContext) + ) + + begin { + $stackPath = Get-PSCallStackPath + Write-Debug "[$stackPath] - Start" + $Context = Resolve-GitHubContext -Context $Context + Assert-GitHubContext -Context $Context -AuthType APP + } + + process { + try { + $body = @{ + url = $URL + content_type = $ContentType + secret = $Secret + insecure_ssl = $InsecureSSL ? 1 : 0 + } + + $inputObject = @{ + Context = $Context + APIEndpoint = '/app/hook/config' + Method = 'PATCH' + Body = $body + } + + if ($PSCmdlet.ShouldProcess('webhook configuration', 'Update')) { + Invoke-GitHubAPI @inputObject | ForEach-Object { + Write-Output $_.Response + } + } + } catch { + throw $_ + } + } + + end { + Write-Debug "[$stackPath] - End" + } +}