fix(json): Don't serialize jsonpath return if only one result (#6066)

Co-authored-by: Hsiao-nan Cheung <niheaven@gmail.com>
This commit is contained in:
ccyykkcyk
2024-07-22 19:02:06 +08:00
committed by GitHub
parent 429ba7af5b
commit 0cb479abf0
3 changed files with 8 additions and 7 deletions

View File

@@ -102,14 +102,14 @@ Function Get-VirusTotalResultByHash ($hash, $url, $app) {
$response = Invoke-WebRequest -Uri $api_url -Method GET -Headers $headers -UseBasicParsing
$result = $response.Content
$stats = json_path $result '$.data.attributes.last_analysis_stats'
[int]$malicious = json_path $stats '$[0].malicious' $null $false $true
[int]$suspicious = json_path $stats '$[0].suspicious' $null $false $true
[int]$timeout = json_path $stats '$[0].timeout' $null $false $true
[int]$undetected = json_path $stats '$[0].undetected' $null $false $true
[int]$malicious = json_path $stats '$[0].malicious'
[int]$suspicious = json_path $stats '$[0].suspicious'
[int]$timeout = json_path $stats '$[0].timeout'
[int]$undetected = json_path $stats '$[0].undetected'
[int]$unsafe = $malicious + $suspicious
[int]$total = $unsafe + $undetected
[int]$fileSize = json_path $result '$.data.attributes.size' $null $false $true
$report_hash = json_path $result '$.data.attributes.sha256' $null $false $true
[int]$fileSize = json_path $result '$.data.attributes.size'
$report_hash = json_path $result '$.data.attributes.sha256'
$report_url = "https://www.virustotal.com/gui/file/$report_hash"
if ($total -eq 0) {
info "$app`: Analysis in progress."