//native
/**
* Get Vulnerability Finding
* Retrieve a single vulnerability finding by its ID, including the CVE details and the affected asset.
*/
export async function main(auth: RT.Wiz, finding_id: string) {
const tokenResponse = await fetch(
auth.auth_url || "https://auth.app.wiz.io/oauth/token",
{
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "client_credentials",
audience: auth.audience || "wiz-api",
client_id: auth.client_id,
client_secret: auth.client_secret,
}),
}
)
if (!tokenResponse.ok) {
throw new Error(`${tokenResponse.status} ${await tokenResponse.text()}`)
}
const { access_token } = (await tokenResponse.json()) as {
access_token: string
}
const query = `
query GetVulnerabilityFinding($id: ID!) {
vulnerabilityFinding(id: $id) {
id
name
detailedName
severity: vendorSeverity
CVSSSeverity
CVEDescription
description
score
exploitabilityScore
impactScore
hasExploit
hasCisaKevExploit
status
vulnerabilityExternalId
version
fixedVersion
detectionMethod
firstDetectedAt
lastDetectedAt
resolvedAt
resolutionReason
remediation
locationPath
link
portalUrl
vulnerableAsset {
... on VulnerableAssetBase {
id
type
name
cloudPlatform
subscriptionId
tags
}
... on VulnerableAssetVirtualMachine {
id
type
name
cloudPlatform
subscriptionId
tags
operatingSystem
}
... on VulnerableAssetServerless {
id
type
name
cloudPlatform
subscriptionId
tags
}
... on VulnerableAssetContainerImage {
id
type
name
cloudPlatform
subscriptionId
tags
}
... on VulnerableAssetContainer {
id
type
name
cloudPlatform
subscriptionId
tags
}
}
}
}`
const response = await fetch(auth.api_endpoint, {
method: "POST",
headers: {
Authorization: `Bearer ${access_token}`,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query,
variables: { id: finding_id },
}),
})
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const result = (await response.json()) as { data?: any; errors?: any }
if (result.errors) {
throw new Error(JSON.stringify(result.errors))
}
return result.data.vulnerabilityFinding
}
Submitted by hugo989 5 days ago