public/Add-NexposeAssetVulnerabilityValidation.ps1
Function Add-NexposeAssetVulnerabilityValidation { <# .SYNOPSIS Adds a vulnerability validation for a vulnerability for an asset .DESCRIPTION Adds a vulnerability validation for a vulnerability for an asset .PARAMETER AssetId The identifier of the asset .PARAMETER VulnerabilityId The identifier of the vulnerability .PARAMETER ValidationDate The date and time the vulnerability was validated, in the ISO8601 format .PARAMETER SourceName The name of the source used to validate the vulnerability. Valid values are 'Metasploit' or 'Other' .PARAMETER SourceKey The identifier or name of the exploit that was used to validate the vulnerability .EXAMPLE Add-NexposeAssetVulnerabilityValidation -AssetId 42 -VulnerabilityId '7-zip-cve-2008-6536' -SourceName 'Other' -SourceKey '...' .NOTES For additional information please see my GitHub wiki page .FUNCTIONALITY POST: assets/{id}/vulnerabilities/{vulnerabilityId}/validations .LINK https://github.com/My-Random-Thoughts/Rapid7Nexpose #> [CmdletBinding(SupportsShouldProcess)] Param ( [Parameter(Mandatory = $true)] [int]$AssetId, [Parameter(Mandatory = $true)] [string]$VulnerabilityId, [datetime]$ValidationDate = (Get-Date), [Parameter(Mandatory = $true)] [ValidateSet('Metasploit','Other')] [string]$SourceName, [Parameter(Mandatory = $true)] [string]$SourceKey ) Begin { } Process { $apiQuery = @{ date = ($ValidationDate.ToString('yyyy-MM-ddTHH:mm:ssZ')) source = @{ key = $SourceKey.ToLower() name = $SourceName.ToLower() } } If ($PSCmdlet.ShouldProcess($ValidationId)) { Write-Output (Invoke-NexposeQuery -UrlFunction "assets/$AssetId/vulnerabilities/$VulnerabilityId/validations" -ApiQuery $apiQuery -RestMethod Post) } } End { } } |