Skip to content

Commit 7c1142e

Browse files
Arta AsadiArta Asadi
authored andcommitted
fix: add software_vulnerabilities_fixes query
1 parent 9c6797c commit 7c1142e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
id: software_vulnerabilities_fixes
2+
type: query
3+
title: Software Vulnerabilities And Fixes
4+
description: Software Vulnerabilities and their details and fixes
5+
integration_type:
6+
- github_account
7+
parameters:
8+
- key: artifactId
9+
value: ""
10+
query: |
11+
WITH ArtifactPackagesWithVulns AS (
12+
SELECT DISTINCT
13+
p.image_url,
14+
p.artifact_id,
15+
p.ecosystem,
16+
p.package_name,
17+
p.version,
18+
v.vulnerabilities
19+
FROM (
20+
SELECT DISTINCT
21+
image_url,
22+
artifact_id,
23+
(jsonb_array_elements(packages)->>'ecosystem') AS ecosystem,
24+
(jsonb_array_elements(packages)->>'name') AS package_name,
25+
(jsonb_array_elements(packages)->>'version') AS version
26+
FROM software_packages
27+
WHERE artifact_id = '{{.artifactId}}';
28+
) AS p
29+
JOIN packages_with_vulnerabilities v ON
30+
p.ecosystem = v.ecosystem AND
31+
p.package_name = v.package_name AND
32+
p.version = v.version
33+
WHERE v.vulnerabilities IS NOT NULL AND v.vulnerabilities <> '[]'::jsonb
34+
)
35+
SELECT
36+
apv.image_url,
37+
apv.artifact_id,
38+
apv.ecosystem,
39+
apv.package_name,
40+
apv.version,
41+
vuln_id,
42+
ovd.*
43+
FROM ArtifactPackagesWithVulns apv
44+
CROSS JOIN LATERAL jsonb_array_elements_text(apv.vulnerabilities) AS v_list(vuln_id)
45+
LEFT JOIN vulnerability_details ovd ON v_list.vuln_id = ovd.id;
46+
tags:
47+
platform_queries_bookmark:
48+
- 'true'
49+
platform_cache_enabled:
50+
- 'true'

0 commit comments

Comments
 (0)