(target_id: str, finding: dict[str, Any])
| 488 | |
| 489 | |
| 490 | def _fingerprint(target_id: str, finding: dict[str, Any]) -> str: |
| 491 | identity = _require_dict(finding, "identity", "finding") |
| 492 | anchor = _require_str(identity, "anchor", "finding.identity") |
| 493 | if not SLUG_RE.fullmatch(anchor): |
| 494 | raise ContractError("finding.identity.anchor: expected a stable lowercase semantic slug") |
| 495 | instance = identity.get("instance", "") |
| 496 | if not isinstance(instance, str): |
| 497 | raise ContractError("finding.identity.instance: expected a string") |
| 498 | if instance and not SLUG_RE.fullmatch(instance): |
| 499 | raise ContractError("finding.identity.instance: expected a stable lowercase semantic slug") |
| 500 | rule_id = _require_str(finding, "ruleId", "finding") |
| 501 | if not SLUG_RE.fullmatch(rule_id): |
| 502 | raise ContractError("finding.ruleId: expected a stable lowercase rule slug") |
| 503 | material = "\0".join((FINGERPRINT_ALGORITHM, target_id, rule_id, anchor, instance)) |
| 504 | return f"{FINGERPRINT_ALGORITHM}:sha256:{_sha256_text(material)}" |
| 505 | |
| 506 | |
| 507 | def _stable_id(prefix: str, *parts: str) -> str: |
no test coverage detected