Skip to content

Commit 4733c0f

Browse files
committed
Feat: Add Anchore Grype detailed scan type for per-file-path deduplication documentation
Reference: DefectDojo#14573
1 parent 523e68b commit 4733c0f

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

docs/content/supported_tools/parsers/file/anchore_grype.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,3 +203,31 @@ By default, DefectDojo identifies duplicate Findings using these [hashcode field
203203
- severity
204204
- component name
205205
- component version
206+
207+
### Anchore Grype Detailed
208+
209+
Both scan types accept the same JSON report format. The difference is in how Findings are deduplicated:
210+
211+
- **`Anchore Grype`** — Aggregates all matches for the same CVE, component name, and version into a single Finding, regardless of file path. Deduplication is based on hashcode fields (`title`, `severity`, `component_name`, `component_version`).
212+
- **`Anchore Grype detailed`** — Creates a separate Finding for each unique file path. Deduplication is based on `unique_id_from_tool`, composed as `{vuln_id}|{component_name}|{component_version}|{file_path}`.
213+
214+
A typical case is a package installed at multiple paths in a container image (e.g., /usr/lib/x86_64-linux-gnu/libc.so.6 and /lib/x86_64-linux-gnu/libc.so.6) — the same CVE would produce one Finding in default mode and two in detailed mode.
215+
216+
**Field mapping:**
217+
218+
| Finding Field | Grype JSON Source |
219+
|---|---|
220+
| `title` | `{vulnerability.id} in {artifact.name}:{artifact.version}` |
221+
| `severity` | `vulnerability.severity` (mapped: `Unknown`/`Negligible``Info`) |
222+
| `description` | `vulnerability.namespace`, `vulnerability.description`, `matchDetails[].matcher`, `artifact.purl` |
223+
| `component_name` | `artifact.name` |
224+
| `component_version` | `artifact.version` |
225+
| `file_path` | `artifact.locations[0].path` |
226+
| `vuln_id_from_tool` | `vulnerability.id` |
227+
| `unique_id_from_tool` | `vuln_id\|component_name\|component_version\|file_path` (detailed mode only) |
228+
| `references` | `vulnerability.dataSource`, `vulnerability.urls`, `relatedVulnerabilities[0].dataSource`, `relatedVulnerabilities[0].urls` |
229+
| `mitigation` | `vulnerability.fix.versions` |
230+
| `fix_available` | `true` if `vulnerability.fix.versions` is non-empty |
231+
| `fix_version` | `vulnerability.fix.versions[0]` (or comma-joined if multiple) |
232+
| `cvssv3` | `vulnerability.cvss` or `relatedVulnerabilities[0].cvss` |
233+
| `epss_score` / `epss_percentile` | `vulnerability.epss` or `relatedVulnerabilities[0].epss` |

dojo/tools/anchore_grype/parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def get_findings(self, file, test):
225225
)
226226
if self.mode == "detailed":
227227
dupes[dupe_key].unique_id_from_tool = dupe_key
228-
dupes[dupe_key].unsaved_vulnerability_ids = vulnerability_ids
228+
dupes[dupe_key].unsaved_vulnerability_ids = vulnerability_ids
229229
if settings.V3_FEATURE_LOCATIONS and artifact_purl:
230230
dupes[dupe_key].unsaved_locations.append(
231231
LocationData.dependency(purl=artifact_purl, file_path=file_path),

0 commit comments

Comments
 (0)