Commit db13078
committed
feat(hdf-converters): add Semgrep JSON to HDF mapper
Semgrep's native JSON carries a rule metadata layer that its SARIF output
drops: impact and likelihood, the ASVS control mapping, reference URLs,
vulnerability_class, technology and subcategory, and the bandit rule
cross-reference. SARIF keeps CWE, OWASP and confidence only as untyped prose
tags on the rule object. Converting the native format preserves the
cross-framework links that make the results usable for accreditation.
One control per rule: Semgrep metadata is rule-scoped and identical across
occurrences, so findings collapse into results under a single control keyed
on check_id.
Notes on the format, all confirmed against semgrep 1.174.0 output rather
than its documentation:
- metadata fields documented as arrays arrive as bare strings when a rule
declares a single value (owasp, subcategory, technology); everything
list-shaped is normalized on read
- CWEs are emitted in prose form ('CWE-89: Improper Neutralization of ...'),
so the id is parsed out before the NIST lookup
- extra.lines and extra.fingerprint are redacted to the literal string
'requires login' in unauthenticated scans and are filtered rather than
mapped
- metadata.impact rates the severity of the consequence and is not HDF's
impact float; it is tagged as semgrep_impact so it cannot shadow it
- findings suppressed with a nosemgrep comment are omitted from the output
entirely rather than flagged, so no skipped status is derivable
- extra.fix is replacement text for the matched span, not a standalone
instruction, and is labelled accordingly
Scan errors become their own control with status error, present only when
the scan produced any, so a file that failed to parse is visible rather
than buried in passthrough.
The fingerprint keys on semgrep-specific paths (paths.scanned,
engine_requested, skipped_rules) rather than the generic results/errors/
version triple, which matched bare arrays of HDF controls belonging to
other converters.
Also normalizes quoting on the adjacent CHECKOV fingerprint line to satisfy
the repository prettier configuration.
Signed-off-by: clem-field <kc8yhe@me.com>1 parent 2e4a8be commit db13078
13 files changed
Lines changed: 1943 additions & 8 deletions
File tree
- apps/frontend/src/store
- libs/hdf-converters
- sample_jsons/semgrep_mapper
- sample_input_report
- src
- utils
- test/mappers/forward
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
246 | 247 | | |
247 | 248 | | |
248 | 249 | | |
| 250 | + | |
| 251 | + | |
249 | 252 | | |
250 | 253 | | |
251 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
Lines changed: 83 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
0 commit comments