Skip to content

Commit ab3e571

Browse files
kzzz1kzzz1
andauthored
add aqua vulnerabilities format (#12000)
* add aqua scan format report for api v2 * fix ruff * Update aqua.md --------- Co-authored-by: kzzz1 <karine.desrochers.4@gmail.com>
1 parent c7331cc commit ab3e571

File tree

5 files changed

+5545
-5
lines changed

5 files changed

+5545
-5
lines changed

docs/content/en/connecting_your_tools/parsers/file/aqua.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,37 @@
22
title: "Aqua"
33
toc_hide: true
44
---
5-
JSON report format.
5+
6+
### File Types
7+
DefectDojo parser accepts JSON report format.
8+
9+
See Aqua documention: https://docs.aquasec.com
10+
11+
### CI/CD Scans
12+
Aqua scanning can be integrated with several types of third-party CI/CD systems.
13+
14+
If there is no plugin available for a particular development tool, Aqua can be integrated with the CI/CD pipeline using Scanner CLI.
15+
16+
CI/CD scans produces JSON scan reports that are supported by the parser. With this kind of report, the parser is able to retrieve vulnerabilities as well as sensitive datas.
17+
18+
### REST API
19+
20+
You can also retrieve the JSON directly from Aqua if you use one of the following endpoint:
21+
22+
- `/api/v1/scanner/registry/<registryName>/image/<imageName>/scan_result`
23+
24+
- `/api/v2/risks/vulnerabilities`
25+
26+
Example
27+
```
28+
curl -X GET <aquaseceurl>/api/v1/scanner/registry/<registryName>/image/<imageName>/scan_result > report.json
29+
```
30+
31+
```
32+
curl -X GET <aquaseceurl>/api/v2/risks/vulnerabilities?show_negligible=true&image_name_exact_match=true&registry_name=<registryName>&image_name=<imageName> > report.json
33+
```
34+
35+
Those JSON files will only list vulnerabilities. Thus, DefectDojo parser will not retrieve findings such as sensitive datas.
636

737
### Sample Scan Data
8-
Sample Aqua scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/aqua).
38+
Sample Aqua scans can be found [here](https://github.com/DefectDojo/django-DefectDojo/tree/master/unittests/scans/aqua).

dojo/tools/aqua/parser.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,16 @@ def get_findings(self, json_output, test):
107107

108108
def get_items(self, tree, test):
109109
self.items = {}
110-
if isinstance(tree, list): # Aqua Scan Report coming from Azure Devops jobs.
110+
if isinstance(tree, list): # Aqua Scan Report coming from Azure Devops jobs (Windows based image)
111111
vulnerabilitytree = tree[0]["results"]["resources"] if tree else []
112112
self.vulnerability_tree(vulnerabilitytree, test)
113-
elif "resources" in tree: # Aqua Scan Report not from Azure Devops jobs.
113+
elif "resources" in tree: # CICD Scan Report
114114
vulnerabilitytree = tree["resources"]
115115
self.vulnerability_tree(vulnerabilitytree, test)
116-
elif "cves" in tree: # Aqua Scan Report not from Azure Devops jobs.
116+
elif "result" in tree: # Aqua Scan Report from apiv2
117+
resulttree = tree["result"]
118+
self.result_tree(resulttree, test)
119+
elif "cves" in tree: # Aqua Scan Report from apiv1
117120
for cve in tree["cves"]:
118121
unique_key = cve.get("file") + cve.get("name")
119122
self.items[unique_key] = get_item_v2(cve, test)
@@ -137,6 +140,13 @@ def vulnerability_tree(self, vulnerabilitytree, test):
137140
unique_key = resource.get("cpe") + resource.get("path", "None") + str(sensitive_item)
138141
self.items[unique_key] = item
139142

143+
def result_tree(self, resulttree, test):
144+
for vuln in resulttree:
145+
resource = vuln.get("resource")
146+
item = get_item(resource, vuln, test)
147+
unique_key = resource.get("cpe") + vuln.get("name", "None") + resource.get("path", "None")
148+
self.items[unique_key] = item
149+
140150

141151
def get_item(resource, vuln, test):
142152
resource_name = resource.get("name", resource.get("path"))

0 commit comments

Comments
 (0)