|
6 | 6 | # one severity on a package shares an alert type (``criticalCVE``, ``cve`` and |
7 | 7 | # so on), so these are what tell two of them apart. |
8 | 8 | # |
9 | | -# Socket's CVE alerts carry ``ghsaId`` and ``cveId``. The other names are not |
10 | | -# in any current alert schema; they are checked so this lookup matches |
11 | | -# ``ADVISORY_ID_PROPS`` / ``Issue.advisory_id()`` in socket-python-cli |
| 9 | +# Socket's CVE alerts carry ``ghsaId`` and ``cveId``. The other names are in no |
| 10 | +# current alert schema; they mirror ``Issue.advisory_id()`` in socket-python-cli |
12 | 11 | # (socketsecurity/core/classes.py), which reads alerts from this SDK. Keep the |
13 | 12 | # two lists in step. |
14 | 13 | ADVISORY_ID_PROPS = ("ghsaId", "ghsa_id", "cveId", "cve_id", "cve") |
15 | 14 |
|
16 | 15 | # Policy actions from least to most severe. An unknown or missing action ranks |
17 | | -# below "ignore": it yields to any known action, "ignore" included, and never |
18 | | -# replaces one. So an unexpected value can't downgrade a known "error", and |
19 | | -# the result doesn't depend on which release is listed first. |
| 16 | +# below "ignore", so it never replaces a known action and the merged result |
| 17 | +# doesn't depend on which release is listed first. |
20 | 18 | ACTION_RANK = {"ignore": 0, "monitor": 1, "warn": 2, "error": 3} |
21 | 19 |
|
22 | 20 |
|
@@ -95,12 +93,10 @@ def consolidate_and_merge_alerts(package_group: List[Dict[str, Any]]) -> Dict[st |
95 | 93 | merged = alert_map[identity] |
96 | 94 | if release not in merged["releases"]: |
97 | 95 | merged["releases"].append(release) |
98 | | - # Keep the most severe action seen for this alert, so a |
99 | | - # release that blocks is never hidden behind one that doesn't. |
100 | | - # Only the action moves: key, props and the rest stay as the |
101 | | - # first sighting had them, so in a purl.post() result the |
102 | | - # merged key can belong to a release whose own action was |
103 | | - # less severe than the one shown. |
| 96 | + # Keep the most severe action seen, so a release that blocks |
| 97 | + # is never hidden behind one that doesn't. Only the action |
| 98 | + # moves: key and props stay with the first sighting, so the |
| 99 | + # key can belong to a release with a less severe action. |
104 | 100 | if Dedupe.action_rank(alert.get("action")) > Dedupe.action_rank(merged.get("action")): |
105 | 101 | merged["action"] = alert.get("action") |
106 | 102 |
|
|
0 commit comments