feat(audit): add governed DSAR coverage
This commit is contained in:
@@ -3,14 +3,30 @@ from __future__ import annotations
|
||||
from pathlib import Path
|
||||
|
||||
from govoplan_audit.backend.db import models as audit_models # noqa: F401 - populate Audit ORM metadata
|
||||
from govoplan_audit.backend.dsar_provider import (
|
||||
AUDIT_DSAR_CAPABILITY,
|
||||
AuditDsarProvider,
|
||||
)
|
||||
from govoplan_core.core.access import (
|
||||
CAPABILITY_AUDIT_RECORDER,
|
||||
CAPABILITY_AUDIT_RETENTION,
|
||||
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
|
||||
CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
|
||||
)
|
||||
from govoplan_core.core.module_guards import drop_table_retirement_provider, persistent_table_uninstall_guard
|
||||
from govoplan_core.core.modules import DocumentationCondition, DocumentationTopic, FrontendModule, MigrationSpec, ModuleContext, ModuleManifest
|
||||
from govoplan_core.core.module_guards import (
|
||||
drop_table_retirement_provider,
|
||||
persistent_table_uninstall_guard,
|
||||
)
|
||||
from govoplan_core.core.modules import (
|
||||
CapabilityDocumentation,
|
||||
DocumentationCondition,
|
||||
DocumentationTopic,
|
||||
FrontendModule,
|
||||
MigrationSpec,
|
||||
ModuleContext,
|
||||
ModuleInterfaceProvider,
|
||||
ModuleManifest,
|
||||
)
|
||||
from govoplan_core.core.provider_governance import declared_module_architecture
|
||||
from govoplan_core.core.events import CAPABILITY_PLATFORM_EVENT_OUTBOX
|
||||
from govoplan_core.core.views import ViewSurface
|
||||
@@ -51,15 +67,71 @@ def _event_outbox(context: ModuleContext):
|
||||
)
|
||||
|
||||
|
||||
def _dsar_provider(_context: ModuleContext) -> AuditDsarProvider:
|
||||
return AuditDsarProvider()
|
||||
|
||||
|
||||
manifest = ModuleManifest(
|
||||
id="audit",
|
||||
name="Audit",
|
||||
version="0.1.18",
|
||||
permissions=AUDIT_PERMISSIONS,
|
||||
role_templates=AUDIT_ROLE_TEMPLATES,
|
||||
required_capabilities=(CAPABILITY_AUTH_PRINCIPAL_RESOLVER, CAPABILITY_AUTH_PERMISSION_EVALUATOR),
|
||||
required_capabilities=(
|
||||
CAPABILITY_AUTH_PRINCIPAL_RESOLVER,
|
||||
CAPABILITY_AUTH_PERMISSION_EVALUATOR,
|
||||
),
|
||||
provides_interfaces=(
|
||||
ModuleInterfaceProvider(name=AUDIT_DSAR_CAPABILITY, version="0.1.0"),
|
||||
),
|
||||
route_factory=_route_factory,
|
||||
documentation=(
|
||||
DocumentationTopic(
|
||||
id="audit.data-subject-requests",
|
||||
title="Audit data-subject requests",
|
||||
summary=(
|
||||
"Include minimized subject-linked accountability evidence in "
|
||||
"access packages while preserving immutable retention."
|
||||
),
|
||||
body=(
|
||||
"Audit correlates exact account, membership, identity, or user "
|
||||
"identifiers only within the active tenant. It contributes actor "
|
||||
"audit records, structured platform-event actor envelopes, manual "
|
||||
"replay attribution, and evidence-bundle request attribution. The "
|
||||
"projection preserves action, object, event, trace, source, policy, "
|
||||
"status, timing, and verification references needed to explain the "
|
||||
"subject's involvement. Arbitrary audit details, event payloads, "
|
||||
"institutional context, delivery keys and errors, replay reasons, "
|
||||
"request payloads, generated bundle payloads, and credentials are "
|
||||
"excluded. Optional exact record references narrow results but never "
|
||||
"replace actor corroboration. System and cross-tenant evidence is not "
|
||||
"included in tenant requests. All Audit erasure actions are retain-only "
|
||||
"and non-executable because the records are immutable accountability "
|
||||
"evidence governed by retention and legal hold."
|
||||
),
|
||||
layer="configured",
|
||||
documentation_types=("admin", "user"),
|
||||
audience=("data_subject", "auditor", "security_officer", "operator"),
|
||||
related_modules=("core", "access", "policy", "ops"),
|
||||
metadata={
|
||||
"help_contexts": [
|
||||
"audit.admin.tenant",
|
||||
"audit.event-details",
|
||||
"audit.evidence.export",
|
||||
"privacy.data-subject-requests",
|
||||
],
|
||||
"consequence_classes": {
|
||||
"export_actor_evidence": (
|
||||
"Returns minimized actor attribution and stable references, "
|
||||
"never arbitrary evidence payloads."
|
||||
),
|
||||
"retain_audit_evidence": (
|
||||
"Keeps immutable evidence under configured retention and "
|
||||
"legal-hold policy."
|
||||
),
|
||||
},
|
||||
},
|
||||
),
|
||||
DocumentationTopic(
|
||||
id="audit.read-authorized-evidence",
|
||||
title="Read authorized audit evidence",
|
||||
@@ -103,7 +175,9 @@ manifest = ModuleManifest(
|
||||
audience=("auditor", "security_officer", "operator"),
|
||||
conditions=(
|
||||
DocumentationCondition(required_scopes=("audit:evidence:export",)),
|
||||
DocumentationCondition(required_scopes=("audit:system_evidence:export",)),
|
||||
DocumentationCondition(
|
||||
required_scopes=("audit:system_evidence:export",)
|
||||
),
|
||||
),
|
||||
related_modules=("policy", "files"),
|
||||
metadata={
|
||||
@@ -125,16 +199,26 @@ manifest = ModuleManifest(
|
||||
module_id="audit",
|
||||
package_name="@govoplan/audit-webui",
|
||||
view_surfaces=(
|
||||
ViewSurface(id="audit.admin.system", module_id="audit", kind="section", label="System audit", order=90),
|
||||
ViewSurface(id="audit.admin.tenant", module_id="audit", kind="section", label="Tenant audit", order=100),
|
||||
ViewSurface(
|
||||
id="audit.admin.system",
|
||||
module_id="audit",
|
||||
kind="section",
|
||||
label="System audit",
|
||||
order=90,
|
||||
),
|
||||
ViewSurface(
|
||||
id="audit.admin.tenant",
|
||||
module_id="audit",
|
||||
kind="section",
|
||||
label="Tenant audit",
|
||||
order=100,
|
||||
),
|
||||
),
|
||||
),
|
||||
migration_spec=MigrationSpec(
|
||||
module_id="audit",
|
||||
metadata=Base.metadata,
|
||||
script_location=str(
|
||||
Path(__file__).with_name("migrations") / "versions"
|
||||
),
|
||||
script_location=str(Path(__file__).with_name("migrations") / "versions"),
|
||||
retirement_supported=True,
|
||||
retirement_provider=drop_table_retirement_provider(
|
||||
audit_models.AuditEvidenceBundle,
|
||||
@@ -158,6 +242,17 @@ manifest = ModuleManifest(
|
||||
CAPABILITY_AUDIT_RECORDER: _audit_recorder,
|
||||
CAPABILITY_AUDIT_RETENTION: _audit_retention,
|
||||
CAPABILITY_PLATFORM_EVENT_OUTBOX: _event_outbox,
|
||||
AUDIT_DSAR_CAPABILITY: _dsar_provider,
|
||||
},
|
||||
capability_documentation={
|
||||
AUDIT_DSAR_CAPABILITY: CapabilityDocumentation(
|
||||
label="Audit data-subject request provider",
|
||||
summary=(
|
||||
"Exports minimized tenant actor evidence with retain-only "
|
||||
"erasure outcomes."
|
||||
),
|
||||
contract_version="0.1.0",
|
||||
),
|
||||
},
|
||||
architecture=declared_module_architecture(
|
||||
layer="governance_accountability",
|
||||
@@ -165,8 +260,15 @@ manifest = ModuleManifest(
|
||||
maturity="vertical_slice",
|
||||
documentation_ref="docs/AUDIT_TRACE_CONTEXT.md",
|
||||
test_ref="tests/test_audit_module_contract.py",
|
||||
known_limits=("Cross-deployment long-term archive transfer remains deployment-specific.",),
|
||||
owned_concepts=("audit record", "audit retention", "audit evidence bundle", "transactional event outbox"),
|
||||
known_limits=(
|
||||
"Cross-deployment long-term archive transfer remains deployment-specific.",
|
||||
),
|
||||
owned_concepts=(
|
||||
"audit record",
|
||||
"audit retention",
|
||||
"audit evidence bundle",
|
||||
"transactional event outbox",
|
||||
),
|
||||
non_owned_concepts=("domain record", "policy decision", "external effect"),
|
||||
recovery_docs=("README.md",),
|
||||
security_docs=("docs/AUDIT_TRACE_CONTEXT.md", "docs/EVIDENCE_BUNDLES.md"),
|
||||
|
||||
Reference in New Issue
Block a user