feat: Implement DefaultCryptoHmac for compliance-aware HMAC operations
- Added DefaultCryptoHmac class implementing ICryptoHmac interface. - Introduced purpose-based HMAC computation methods. - Implemented verification methods for HMACs with constant-time comparison. - Created HmacAlgorithms and HmacPurpose classes for well-known identifiers. - Added compliance profile support for HMAC algorithms. - Included asynchronous methods for HMAC computation from streams.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Risk Profiles (draft outline)
|
||||
# Risk Profiles
|
||||
|
||||
> Draft scaffold pending PLLG0104 risk profile schema approval. Do not publish externally until schemas and sample payloads arrive. Mirrors existing `docs/risk/risk-profiles.md`; this file will supersede it once populated.
|
||||
> Contract source: `CONTRACT-RISK-SCORING-002` (published 2025-12-05). This file supersedes `docs/risk/risk-profiles.md` once fixtures are added.
|
||||
|
||||
## Purpose
|
||||
- Define how profiles group factors, weights, thresholds, and severity bands.
|
||||
@@ -10,10 +10,42 @@
|
||||
- Audience: policy authors, risk engineers, platform SREs.
|
||||
- Coverage: profile schema, lifecycle, governance, promotion paths, rollback, and observability hooks.
|
||||
|
||||
## Schema (placeholder)
|
||||
- Profile schema reference: `<pending PLLG0104>`
|
||||
- Required fields: id, versioning, factors list, weights, thresholds, severity mapping, metadata, provenance.
|
||||
- Optional fields: tenant overrides, imposed rules, time-to-live.
|
||||
## Schema (from CONTRACT-RISK-SCORING-002)
|
||||
- Required: `id`, `version`, `description`, `signals[]`, `weights`, `metadata`.
|
||||
- `signals[]` fields: `name`, `source`, `type` (`numeric|boolean|categorical`), `path`, optional `transform`, optional `unit`.
|
||||
- Overrides: `overrides.severity[] { when, set }`, `overrides.decisions[] { when, action, reason }`.
|
||||
- Optional: `extends`, rollout flags, tenant overrides, `valid_from`/`valid_until`.
|
||||
- Storage rules: immutable once promoted; each change creates a new version with DSSE envelope and SHA256 manifest entry (`docs/risk/samples/profiles/SHA256SUMS`).
|
||||
|
||||
### Example Profile (contract snippet)
|
||||
```json
|
||||
{
|
||||
"id": "default-profile",
|
||||
"version": "1.0.0",
|
||||
"description": "Default risk profile for vulnerability prioritization",
|
||||
"extends": "base-profile",
|
||||
"signals": [
|
||||
{ "name": "cvss", "source": "nvd", "type": "numeric", "path": "/cvss/base_score", "transform": "normalize_10", "unit": "score" },
|
||||
{ "name": "kev", "source": "cisa", "type": "boolean", "path": "/kev/in_catalog" },
|
||||
{ "name": "reachability", "source": "scanner", "type": "numeric", "path": "/reachability/score" }
|
||||
],
|
||||
"weights": { "cvss": 0.4, "kev": 0.3, "reachability": 0.3 },
|
||||
"overrides": {
|
||||
"severity": [{ "when": { "kev": true }, "set": "critical" }],
|
||||
"decisions": [{ "when": { "kev": true, "reachability": { "$gt": 0.8 } }, "action": "deny", "reason": "KEV with high reachability" }]
|
||||
},
|
||||
"metadata": {}
|
||||
}
|
||||
```
|
||||
|
||||
### Severity Levels
|
||||
| Level | Value | Priority |
|
||||
| --- | --- | --- |
|
||||
| Critical | `critical` | 1 |
|
||||
| High | `high` | 2 |
|
||||
| Medium | `medium` | 3 |
|
||||
| Low | `low` | 4 |
|
||||
| Informational | `informational` | 5 |
|
||||
|
||||
## Lifecycle (outline)
|
||||
1. Authoring in Policy Studio (draft state)
|
||||
@@ -23,19 +55,20 @@
|
||||
5. Rollback hooks and audit trail
|
||||
|
||||
## Governance & Determinism
|
||||
- Profiles stored with DSSE/signatures; record SHA256 for fixtures.
|
||||
- Same evaluation codepath for simulation and production; note required feature flags.
|
||||
- Offline posture: include profiles and fixtures inside mirror bundles.
|
||||
- Profiles stored with DSSE/signatures; fixtures recorded in `docs/risk/samples/profiles/SHA256SUMS`.
|
||||
- Simulation and production share the same evaluation codepath; feature flags must be documented in `metadata.flags`.
|
||||
- Offline posture: include profiles, fixtures, and explainability bundles inside mirror packages with manifest hashes.
|
||||
|
||||
## Explainability & Observability
|
||||
- Per-factor contribution outputs (JSON) with stable ordering.
|
||||
- Metrics to log: evaluation latency, cache hit ratio, factor coverage.
|
||||
- Dashboards/alerts to enumerate once telemetry payloads are supplied.
|
||||
- Per-factor contribution outputs (JSON) with stable ordering (factor type → source).
|
||||
- Metrics: evaluation latency (p50/p95), cache hit ratio, factor coverage %, profile hit rate, failed provenance validations.
|
||||
- Dashboards/alerts: to be filled when telemetry payloads arrive; reserve panels for gating violations and override usage.
|
||||
|
||||
## Open Items
|
||||
- PLLG0104 schema approval and sample JSON payloads
|
||||
- Feature-flag list for registry alignment
|
||||
- Telemetry field list for dashboards/alerts
|
||||
- Add signed fixtures (profiles + hashes) under `docs/risk/samples/profiles/` once payloads arrive.
|
||||
- Capture feature-flag list for registry alignment.
|
||||
- Telemetry field list for dashboards/alerts.
|
||||
- Finalize migration note when legacy `docs/risk/risk-profiles.md` is archived.
|
||||
|
||||
## References
|
||||
- `docs/risk/overview.md`
|
||||
|
||||
Reference in New Issue
Block a user