Personal-data catalog spec, §6 (Phase 3c). inbuxa:DataInventory/get evaluates the catalog against the server's live settings and says what this server holds: for each source and each object that can hold personal data, its categories and whose data it is, whether it is collected here at all, what bounds its retention (the live value of the setting that does, or unbounded), whether it leaves the host and to which endpoints, and a summary. Every host that receives something is listed once as a candidate processor with what it receives. Inside a tenant it answers with the tenant's slice and none of the server's processors. Read-only, with sysComplianceGet. inbuxa:InventorySnapshot/get is the history: a dated copy of the evaluated inventory, recorded when it changes -- after a registry write to an object the inventory reads, after inbuxa's log, audit or AI settings change, and on the daily clean-up -- and kept as long as the audit log's records. ids: null lists every snapshot, newest first; the full inventory only when asked for. The catalog is embedded and parsed at start (new dependency: toml, MIT/Apache); the evaluation is a pure function of it and the live facts, so each configuration is tested without a server. Loopback endpoints stay on the host; any other configured endpoint leaves it. Tested: unit tests for the evaluation (a new install's defaults, an external blob store, a hosted AI endpoint, telemetry off, a tenant's slice, hosts from URLs, loopback), snapshots, and the fact gathering's store and duration rules; the compliance system test, extended (the officer reads the inventory, a plain user is refused, a tenant's officer sees its slice and no processors, a webhook to another host becomes a processor and a snapshot names x:WebHook, a retention change reads through); the system, audit, legal hold and account lock suites; fork checks. The system suite failed once of three runs with an email import's blob not found, in antispam.rs; the same happened once in purge.rs on the previous branch. Nothing here touches uploads; noted for a separate look.
166 lines
3.9 KiB
Rust
166 lines
3.9 KiB
Rust
/*
|
|
* SPDX-FileCopyrightText: 2026 Coffey Labs
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
//! `inbuxa:DataInventory/get` under `urn:inbuxa:jmap`: the personal-data
|
|
//! catalog evaluated against this server's live settings (personal-data
|
|
//! catalog spec, §6). A singleton, id `singleton`; read-only.
|
|
|
|
use crate::object::{AnyId, JmapObject, JmapObjectId};
|
|
use jmap_tools::{Element, Key, Property};
|
|
use std::{borrow::Cow, str::FromStr};
|
|
use types::id::Id;
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
pub struct DataInventory;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
pub enum DataInventoryProperty {
|
|
Id,
|
|
EvaluatedAt,
|
|
CatalogVersion,
|
|
Summary,
|
|
Items,
|
|
Processors,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
pub enum DataInventoryValue {
|
|
Id(Id),
|
|
}
|
|
|
|
impl Property for DataInventoryProperty {
|
|
fn try_parse(_: Option<&Key<'_, Self>>, value: &str) -> Option<Self> {
|
|
DataInventoryProperty::parse(value)
|
|
}
|
|
|
|
fn to_cow(&self) -> Cow<'static, str> {
|
|
match self {
|
|
DataInventoryProperty::Id => "id",
|
|
DataInventoryProperty::EvaluatedAt => "evaluatedAt",
|
|
DataInventoryProperty::CatalogVersion => "catalogVersion",
|
|
DataInventoryProperty::Summary => "summary",
|
|
DataInventoryProperty::Items => "items",
|
|
DataInventoryProperty::Processors => "processors",
|
|
}
|
|
.into()
|
|
}
|
|
}
|
|
|
|
impl DataInventoryProperty {
|
|
fn parse(value: &str) -> Option<Self> {
|
|
hashify::tiny_map!(value.as_bytes(),
|
|
b"id" => DataInventoryProperty::Id,
|
|
b"evaluatedAt" => DataInventoryProperty::EvaluatedAt,
|
|
b"catalogVersion" => DataInventoryProperty::CatalogVersion,
|
|
b"summary" => DataInventoryProperty::Summary,
|
|
b"items" => DataInventoryProperty::Items,
|
|
b"processors" => DataInventoryProperty::Processors,
|
|
)
|
|
}
|
|
}
|
|
|
|
impl FromStr for DataInventoryProperty {
|
|
type Err = ();
|
|
|
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
|
DataInventoryProperty::parse(s).ok_or(())
|
|
}
|
|
}
|
|
|
|
impl Element for DataInventoryValue {
|
|
type Property = DataInventoryProperty;
|
|
|
|
fn try_parse<P>(key: &Key<'_, Self::Property>, value: &str) -> Option<Self> {
|
|
match key {
|
|
Key::Property(DataInventoryProperty::Id) => {
|
|
Id::from_str(value).ok().map(DataInventoryValue::Id)
|
|
}
|
|
_ => None,
|
|
}
|
|
}
|
|
|
|
fn to_cow(&self) -> Cow<'static, str> {
|
|
match self {
|
|
DataInventoryValue::Id(id) => id.to_string().into(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl JmapObject for DataInventory {
|
|
type Property = DataInventoryProperty;
|
|
|
|
type Element = DataInventoryValue;
|
|
|
|
type Id = Id;
|
|
|
|
type Filter = ();
|
|
|
|
type Comparator = ();
|
|
|
|
type GetArguments = ();
|
|
|
|
type SetArguments<'de> = ();
|
|
|
|
type QueryArguments = ();
|
|
|
|
type CopyArguments = ();
|
|
|
|
type ParseArguments = ();
|
|
|
|
const ID_PROPERTY: Self::Property = DataInventoryProperty::Id;
|
|
}
|
|
|
|
impl From<Id> for DataInventoryValue {
|
|
fn from(id: Id) -> Self {
|
|
DataInventoryValue::Id(id)
|
|
}
|
|
}
|
|
|
|
impl JmapObjectId for DataInventoryValue {
|
|
fn as_id(&self) -> Option<Id> {
|
|
match self {
|
|
DataInventoryValue::Id(id) => Some(*id),
|
|
}
|
|
}
|
|
|
|
fn as_any_id(&self) -> Option<AnyId> {
|
|
match self {
|
|
DataInventoryValue::Id(id) => Some(AnyId::Id(*id)),
|
|
}
|
|
}
|
|
|
|
fn as_id_ref(&self) -> Option<&str> {
|
|
None
|
|
}
|
|
|
|
fn try_set_id(&mut self, new_id: AnyId) -> bool {
|
|
if let AnyId::Id(id) = new_id {
|
|
*self = DataInventoryValue::Id(id);
|
|
true
|
|
} else {
|
|
false
|
|
}
|
|
}
|
|
}
|
|
|
|
impl JmapObjectId for DataInventoryProperty {
|
|
fn as_id(&self) -> Option<Id> {
|
|
None
|
|
}
|
|
|
|
fn as_any_id(&self) -> Option<AnyId> {
|
|
None
|
|
}
|
|
|
|
fn as_id_ref(&self) -> Option<&str> {
|
|
None
|
|
}
|
|
|
|
fn try_set_id(&mut self, _: AnyId) -> bool {
|
|
false
|
|
}
|
|
}
|