Visibility¶
Not every user of your application should see the whole audit log. A support agent may see who changed an invoice, but not its IBAN. A customer may see the history of their own invoices, but not which employee made each change, and nothing of another tenant.
A Visibility says what one caller may see. The library knows nothing about your users or roles: you map them to a Visibility once, and every read applies it.
A Visibility has two kinds of rules:
- Row rules decide which entries are shown: allowed object types, verbs and scopes, exclusions, and rules per object type. They become one SQL condition, so paging and counts only ever see the rows the caller may see.
- Field rules decide which values are hidden in the entries that are shown: fields of a change, and header fields such as the actor or the client's address. Hidden values are masked after the rows are read. Nothing is written back.
Visibility is a filter in the library, not in the database. See limitations.
A complete example¶
A FastAPI application with four roles: admins see everything, managers see their own tenant, support agents see their tenant without IBANs or client addresses, and customers see only invoices of their tenant, without IBANs, internal notes or who made each change. The full file is examples/visibility_fastapi.py; it is run by the test suite.
Your roles and users, as you already have them:
class UserRole(StrEnum):
ADMIN = "admin"
MANAGER = "manager"
SUPPORT = "support"
CUSTOMER = "customer"
@dataclass
class User:
id: int
email: str
role: UserRole
tenant_id: str
# Stand-in for your user table.
USERS = {
"ada": User(1, "ada@acme.test", UserRole.MANAGER, "acme"),
"bob": User(2, "bob@acme.test", UserRole.SUPPORT, "acme"),
"carol": User(3, "carol@acme.test", UserRole.CUSTOMER, "acme"),
"dan": User(4, "dan@globex.test", UserRole.MANAGER, "globex"),
"root": User(5, "root@example.test", UserRole.ADMIN, "example"),
}
The audited model. Field rules that belong to one model can live on it, per role (see rules on models):
class Base(DeclarativeBase):
pass
class Invoice(Base, Audited):
__tablename__ = "invoice"
id: Mapped[int] = mapped_column(primary_key=True)
number: Mapped[str]
total: Mapped[Decimal]
status: Mapped[str] = mapped_column(default="draft")
iban: Mapped[str | None]
internal_note: Mapped[str | None]
__audit__ = AuditOptions(
label=lambda invoice: invoice.number,
# Fields some roles may not see, read by by_actor_type(models=Base).
visibility={
UserRole.SUPPORT: TypeRule(hidden_fields={"iban"}),
UserRole.CUSTOMER: TypeRule(hidden_fields={"iban", "internal_note"}),
},
)
The default visibility, set once on AuditTrail. by_actor_type picks a Visibility by the caller's actor type, which here is the user's role. events=[] registers no domain events, since this app logs none:
visibility = by_actor_type(
{
UserRole.ADMIN: UNRESTRICTED,
UserRole.MANAGER: Visibility(),
UserRole.SUPPORT: Visibility(
hidden_header_fields={"remote_addr", "user_agent"},
),
UserRole.CUSTOMER: Visibility(
object_types={"Invoice"},
exclude_verbs={"entity.deleted"},
hidden_header_fields={
"actor_id",
"actor_label",
"remote_addr",
"user_agent",
},
mark_hidden=True,
),
},
same_scope=True,
unscoped={UserRole.ADMIN},
models=Base,
)
engine = create_async_engine(DATABASE_URL)
audit = AuditTrail(engine, events=[], visibility=visibility) # no domain events
SessionLocal = async_sessionmaker(
engine, sync_session_class=AppSession, expire_on_commit=False
)
audit.install(SessionLocal)
UNRESTRICTEDandVisibility()both show everything.same_scope=Truenarrows every role to the caller'sscope_id, here the tenant, admins included. Only the roles listed inunscopedare left alone: withunscoped={UserRole.ADMIN}, admins see every tenant and managers only their own. Without it,UNRESTRICTEDadmins would see only their own tenant too.- An entry's scope is the one it was written with:
AuditOptions(scope=...)on the model, or else the writer'sscope_id(see where an entry's scope comes from). - A role that is not in the mapping, and a request without a user (actor type
"anonymous"), see nothing.
After authentication, record the user with set_actor. The role becomes the actor type and the tenant the scope (see the FastAPI guide):
app = FastAPI(lifespan=lifespan)
app.add_middleware(AuditMiddleware)
get_session = session_dependency(SessionLocal)
def current_user(x_user: Annotated[str, Header()]) -> User:
# Stand-in for real authentication.
user = USERS.get(x_user)
if user is None:
raise HTTPException(status_code=401)
set_actor(
Actor(type=user.role, id=str(user.id), label=user.email),
auth_method="header",
scope_id=user.tenant_id,
)
return user
Reads need no visibility argument. Each read resolves the default for the current request. The async reads need an async driver: install the asyncpg extra (pip install "sqlalchemy-audit-trail[asyncpg]"), which also brings SQLAlchemy's asyncio extra and its greenlet. object_history takes the object id as it is stored, a string that object_id_for(Model, primary_key) builds (see a record's history):
def as_json(group: Group) -> dict[str, Any]:
header = group.transaction
return {
"actor_id": header.actor_id,
"actor_label": header.actor_label,
"hidden": sorted(header.masked),
"partial": group.partial,
"entries": [
{
"verb": activity["verb"],
"actor_id": activity["actor_id"],
"changes": activity["data"].get("changes", {}),
}
for activity in group.activities
],
}
@app.get("/invoices/{invoice_id}/history")
async def invoice_history(
invoice_id: int,
user: Annotated[User, Depends(current_user)],
session: Annotated[AsyncSession, Depends(get_session)],
) -> list[dict[str, Any]]:
# No visibility argument: the default applies, resolved for this user.
page = await audit.query.aobject_history(
session, "Invoice", object_id_for(Invoice, invoice_id)
)
return [as_json(group) for group in page.groups]
@app.get("/activity")
async def activity(
user: Annotated[User, Depends(current_user)],
session: Annotated[AsyncSession, Depends(get_session)],
updates_only: bool = False,
) -> list[dict[str, Any]]:
# A per-call visibility narrows the default: it can only hide more.
narrower = Visibility(verbs={"entity.updated"}) if updates_only else None
page = await audit.query.alist_groups(session, visibility=narrower)
return [as_json(group) for group in page.groups]
ada (manager) creates INV-1 with an IBAN, bob (support) adds an internal note, and ada sends the invoice. The oldest group of GET /invoices/1/history then looks like this to each user:
As ada (manager) or root (admin):
{"actor_id": "1", "actor_label": "ada@acme.test", "hidden": [], "partial": false,
"entries": [{"verb": "entity.created", "actor_id": "1",
"changes": {"id": [null, 1], "iban": [null, "DE89"], "total": [null, "120.00"],
"number": [null, "INV-1"], "status": [null, "draft"],
"internal_note": [null, null]}}]}
As bob (support), the IBAN is masked and the client's address and user agent are hidden:
{"actor_id": "1", "actor_label": "ada@acme.test", "hidden": ["remote_addr", "user_agent"], "partial": false,
"entries": [{"verb": "entity.created", "actor_id": "1",
"changes": {"id": [null, 1], "iban": [null, "[hidden]"], "total": [null, "120.00"],
"number": [null, "INV-1"], "status": [null, "draft"],
"internal_note": [null, null]}}]}
As carol (customer), the actor is hidden too. bob's update is still listed, with the note masked: {"internal_note": [null, "[hidden]"]}.
{"actor_id": null, "actor_label": null,
"hidden": ["actor_id", "actor_label", "remote_addr", "user_agent"], "partial": false,
"entries": [{"verb": "entity.created", "actor_id": "[hidden]",
"changes": {"id": [null, 1], "iban": [null, "[hidden]"], "total": [null, "120.00"],
"number": [null, "INV-1"], "status": [null, "draft"],
"internal_note": [null, null]}}]}
As dan, a manager of another tenant, the history is empty.
To check what a role gets, rules from the mapping and from the model merged, ask the trail (see checking the effective rules):
from audit_trail import AuditContext
print(audit.visibility_for(AuditContext(actor_type="support", scope_id="acme")))
# Visibility(scope_ids={'acme'}, hidden_header_fields={'remote_addr', 'user_agent'}, types={'Invoice': TypeRule(hidden_fields={'iban'})})
print(audit.visibility_for(AuditContext(actor_type="customer", scope_id="acme")))
# Visibility(object_types={'Invoice'}, scope_ids={'acme'}, exclude_verbs={'entity.deleted'}, hidden_header_fields={'actor_id', 'actor_label', 'remote_addr', 'user_agent'}, types={'Invoice': TypeRule(hidden_fields={'iban', 'internal_note'})}, mark_hidden=True)
print(audit.visibility_for(AuditContext(actor_type="admin")))
# UNRESTRICTED
print(audit.visibility_for(AuditContext(actor_type="customer"))) # no tenant
# Visibility.NOTHING
Outside FastAPI¶
The same rules work in a script, a worker or any sync application. The full file is examples/visibility_sync.py; it is run by the test suite.
- Install the sync driver:
pip install "sqlalchemy-audit-trail[psycopg]". - Create the tables with
create_audit_tablesand the current partitions withensure_partitions()before the first write, as in the quickstart. - Write and read as a user inside
audit.context(AuditContext(actor_type=..., scope_id=...))(see request context).by_actor_typereads the actor type andsame_scopethescope_idfrom it, as they read whatset_actorrecords in FastAPI.
The setup: a model with a scope, the resolver, and the tables:
class Role(StrEnum):
DOCTOR = "doctor"
RECEPTIONIST = "receptionist"
AUDITOR = "auditor"
class Base(DeclarativeBase):
pass
class Patient(Base, Audited):
__tablename__ = "patient"
id: Mapped[int] = mapped_column(primary_key=True)
clinic_id: Mapped[str]
name: Mapped[str]
diagnosis: Mapped[str | None]
__audit__ = AuditOptions(
# Entries are filed under the patient's clinic, whoever writes them.
scope=lambda patient: patient.clinic_id,
visibility={Role.RECEPTIONIST: TypeRule(hidden_fields={"diagnosis"})},
)
visibility = by_actor_type(
{
Role.DOCTOR: Visibility(),
Role.RECEPTIONIST: Visibility(),
Role.AUDITOR: UNRESTRICTED,
},
same_scope=True,
unscoped={Role.AUDITOR},
models=Base,
)
engine = create_engine(DATABASE_URL)
audit = AuditTrail(engine, events=[], visibility=visibility) # no domain events
SessionLocal = sessionmaker(engine, expire_on_commit=False)
audit.install(SessionLocal)
def create_tables() -> None:
# In an application, this belongs in a migration (see the partitions guide).
with engine.begin() as connection:
Base.metadata.create_all(connection)
create_audit_tables(connection, audit.tables, audit.severities)
# Monthly partitions: run this on a schedule too, not only at start-up.
audit.maintenance.ensure_partitions()
Your users, as the context each one acts with:
# Your users, as the context each one writes and reads with.
DOCTOR = AuditContext(actor_type=Role.DOCTOR, actor_id="1", scope_id="north")
RECEPTIONIST = AuditContext(
actor_type=Role.RECEPTIONIST, actor_id="2", scope_id="north"
)
AUDITOR = AuditContext(actor_type=Role.AUDITOR, actor_id="3", scope_id="hq")
Writing as a user:
def admit(name: str, diagnosis: str) -> int:
with audit.context(DOCTOR), SessionLocal() as session:
patient = Patient(clinic_id="north", name=name, diagnosis=diagnosis)
session.add(patient)
session.commit()
return patient.id
def correct_diagnosis(patient_id: int, diagnosis: str) -> None:
# The auditor's scope is "hq", but the entry goes to "north": the model's
# `scope` wins over the writer's context.
with audit.context(AUDITOR), SessionLocal() as session:
patient = session.get(Patient, patient_id)
assert patient is not None
patient.diagnosis = diagnosis
session.commit()
Reading as a user, with no visibility argument:
def history(user: AuditContext, patient_id: int) -> list[dict[str, Any]]:
with audit.context(user), SessionLocal() as session:
page = audit.query.object_history(
session, "Patient", object_id_for(Patient, patient_id)
)
return [
activity["data"]["changes"]
for group in page.groups
for activity in group.activities
]
After admit("Anna", "flu") and the auditor's correct_diagnosis(patient_id, "pneumonia"), the doctor and the receptionist of north see, newest first:
doctor [{'diagnosis': ['flu', 'pneumonia']}, {'id': [None, 1], 'name': [None, 'Anna'], 'clinic_id': [None, 'north'], 'diagnosis': [None, 'flu']}]
receptionist [{'diagnosis': ['[hidden]', '[hidden]']}, {'id': [None, 1], 'name': [None, 'Anna'], 'clinic_id': [None, 'north'], 'diagnosis': [None, '[hidden]']}]
A doctor of another clinic sees an empty history.
Choosing a visibility per caller¶
by_actor_type(mapping, *, default=Visibility.NOTHING, same_scope=False, unscoped=(), models=None) builds the resolver:
mappingmaps an actor type to itsVisibility.StrEnummembers match their value, soUserRole.SUPPORTand"support"are the same key.- An actor type that is not in
mappinggetsdefault, which shows nothing unless you give another one. A warning is logged onaudit_trail.visibilitythe first time each such actor type is seen. same_scope=Truenarrows eachVisibilitytoscope_ids={ctx.scope_id}. A context without ascope_idthen sees nothing. Actor types inunscopedare left as they are, for example admins who see every tenant.modelsadds the rules declared on your models (see rules on models).
Where an entry's scope comes from¶
same_scope and scope_ids match the scope_id stored on each entry. An entry takes it from AuditOptions(scope=...) on its model, or, when the model has no scope, from the context of whoever wrote it (see labels, scope and target). A scope that returns None stores no scope.
So without a model scope, the writer decides. An auditor whose context has scope_id="hq" and who edits a row of tenant acme files that entry under "hq": acme's users, narrowed to acme, never see it. For tenant data, give the model a scope:
class Invoice(Base, Audited):
...
tenant_id: Mapped[str]
__audit__ = AuditOptions(scope=lambda invoice: invoice.tenant_id)
The entry then belongs to the invoice's tenant, whoever writes it. The example outside FastAPI does this.
The actor type is what by_actor_type reads, and it is also stored on every entry the caller writes. If you would rather keep one actor type such as "user" for all users, write your own resolver. It is any function from AuditContext to Visibility:
from audit_trail import AuditContext, AuditTrail, Visibility
RULES = {
UserRole.MANAGER: Visibility(),
UserRole.SUPPORT: Visibility(hidden_fields={"iban"}),
}
def visibility(ctx: AuditContext) -> Visibility:
user = cached_user(ctx.actor_id) # your own lookup; keep it cheap
if user is None:
return Visibility.NOTHING
return RULES.get(user.role, Visibility.NOTHING).narrow(
Visibility(scope_ids={user.tenant_id})
)
audit = AuditTrail(engine, visibility=visibility)
The resolver is called once at the start of each read, with the context of the read's session: a context bound with audit.bind, else context_provider(), else the active audit.context(...) block or request context, else an anonymous AuditContext() (see request context). An async read calls it before it leaves your task, so context variables are seen. It must return a Visibility, or the read raises TypeError. If it raises, the read fails; it never falls back to showing everything.
Row rules¶
| Field | Shows entries |
|---|---|
object_types |
on these object types |
verbs |
with these verbs |
scope_ids |
in these scopes |
exclude_object_types |
not on these object types |
exclude_verbs |
without these verbs |
types |
that also pass the rule for their object type (see below) |
from audit_trail import Visibility
Visibility(
scope_ids={"acme"},
exclude_object_types={"ApiKey"},
exclude_verbs={"entity.deleted"},
)
object_types,verbsandscope_idsare allowlists.Nonemeans no restriction; an empty set allows nothing. ANULLcolumn never passes an allowlist that is set: withscope_ids={"acme"}, entries without a scope are hidden.- The exclusions hide rows whose column is one of their values. They never hide a row whose column is
NULL. - Pass sets, not a single string:
verbs="entity.created"raisesTypeError.
A hidden entry is hidden everywhere: list_groups does not list a transaction unless one of its entries is visible, a group shows only its visible entries, and get returns None for a hidden entry, the same as for a missing one.
Row rules select entries by object type, verb and scope only, never by which fields an update changed. An update of a hidden field is still shown, with the field's values as "[hidden]" (see field masking). The extra_predicate of list_groups does not change that: it chooses which transactions are listed, and a listed group still shows every entry the visibility allows. If a role must not learn that a field changed at all, keep the column out of the entity changes with info={"audit": "exclude"} (an update of only that column then writes no entry), record its changes with audit.log under a verb of their own (see domain events), and hide that verb with TypeRule(exclude_verbs=...).
Rules per object type¶
types maps an object type to a TypeRule(verbs=None, exclude_verbs=(), hidden_fields=()). It applies on top of the global rules and can only hide more:
from audit_trail import TypeRule, Visibility
Visibility(
types={
"Invoice": TypeRule(
verbs={"entity.created", "entity.updated", "billing.invoice_sent"},
hidden_fields={"iban"},
),
"User": TypeRule(exclude_verbs={"user.logged_in"}),
},
)
verbsis an allowlist for that type. A verb added later stays hidden until you allow it.Nonemeans no restriction; an empty set hides every entry of the type.exclude_verbshides these verbs of the type.hidden_fieldsmasks these fields in the type's changes and event payloads.
A type without a rule gets only the global rules.
Rules on models¶
Field and verb rules that belong to one model can live on the model, in AuditOptions(visibility={actor_type: TypeRule(...)}). by_actor_type(..., models=Base) adds them to that actor type's types for the model's object type (see also visibility rules in the models guide):
from audit_trail import Audited, AuditOptions, TypeRule, Visibility, by_actor_type
class Invoice(Base, Audited):
__tablename__ = "invoice"
id: Mapped[int] = mapped_column(primary_key=True)
iban: Mapped[str | None]
__audit__ = AuditOptions(
visibility={
UserRole.SUPPORT: TypeRule(hidden_fields={"iban"}),
UserRole.CUSTOMER: TypeRule(exclude_verbs={"entity.deleted"}),
},
)
visibility = by_actor_type(
{UserRole.SUPPORT: Visibility(), UserRole.CUSTOMER: Visibility()},
models=Base,
)
modelstakes a declarative base, a registry, or a sequence of them when your models live in several.- The object type is the one the model's entries are written with:
AuditOptions.object_type, or the class name. - A model's rules are those of every
__audit__up its class hierarchy, combined. A subclass with its own__audit__keeps its bases' rules. - Model rules only hide more. They also narrow an actor type mapped to
UNRESTRICTED. An actor type named only on a model is not in the mapping, so it still getsdefault. - The models are read on the first read, not when the resolver is built, so the order of imports does not matter. They are read again when a registry gains mappers.
- Every hidden field must be an audited column or a tracked collection relationship of the model. A field that is not, also in the mapping's
typesrules for a model's object type, makes reads raiseValueErrornaming the model, the actor type and the field.check_models()reports it asunknown-hidden-field, so a test catches it before a read does (see checking your models).
Field masking¶
hidden_fields masks fields of changes and event payloads, for every object type. hidden_header_fields hides fields of the transaction header and of each entry's context:
from audit_trail import Visibility
Visibility(
hidden_fields={"iban", "tax_id"},
hidden_header_fields={"actor_id", "actor_label", "remote_addr", "meta.ip_country"},
)
A hidden field of a change keeps its key, so changed_fields() still lists it and a UI can say "changed, hidden". Each non-null value becomes MASKED ("[hidden]"):
| Stored | Shown |
|---|---|
{"iban": [null, "DE89..."]} |
{"iban": [null, "[hidden]"]} |
{"iban": ["DE89...", "FR76..."]} |
{"iban": ["[hidden]", "[hidden]"]} |
{"iban": ["***", "***"]} (redacted) |
{"iban": ["[hidden]", "[hidden]"]} |
{"tags": {"added": ["3"], "removed": []}} |
{"tags": {"added": ["[hidden]"], "removed": []}} |
None stays None. A redacted, erased or hashed value is masked like any other, so a hidden field does not reveal whether it was erased. An update whose fields are all hidden is still shown: the caller sees that something changed.
hidden_header_fields takes the names of TransactionHeader fields: actor_type, actor_id, actor_label, remote_addr, user_agent, method, path, channel, auth_method, request_id, correlation_id, scope_id and meta, or meta.<key> for one key of meta. Any other name raises ValueError. A hidden header field:
- is
NoneonTransactionHeader, and listed inTransactionHeader.masked; - is left out of each entry's
data["context"]; - for
actor_idandscope_id, becomes"[hidden]"in the entry's column of that name (when notNone); forcorrelation_id, becomesNonethere.
meta hides all of meta; meta.<key> leaves the other keys. With actor_id hidden, access_summary returns a single count over all actors, with actor_id set to "[hidden]", so it does not reveal how many actors there were.
Masking runs after compaction, so compaction still works on the real values.
The default and per-call visibility¶
Every read takes a visibility argument: list_groups, list_operations, get, object_history, related, access_summary, LabelResolver.resolve and their async variants. With a default set on AuditTrail:
visibility= |
The read applies |
|---|---|
None (the default) |
the resolver's Visibility |
a Visibility |
the resolver's Visibility, narrowed by it |
UNRESTRICTED |
nothing: the default is skipped |
Without a default, visibility is applied as given, and None shows everything.
A per-call visibility can only hide more, with one exception: UNRESTRICTED skips the default and shows everything. It is the only per-call value that widens access. So never pass a visibility through from caller-controlled input, such as a request parameter or body; build it in server code.
Use a per-call visibility for a view that shows less than the caller may see:
from audit_trail import Visibility
page = audit.query.list_groups(session, visibility=Visibility(object_types={"Invoice"}))
a.narrow(b) is what both a and b show: allowlists intersect, globally and per type; exclusions and hidden fields add up; mark_hidden is set when either sets it. A type with a rule on one side only keeps that rule. A result whose object_types, verbs or scope_ids is empty allows no entry, so it is Visibility.NOTHING itself.
UNRESTRICTED and NOTHING¶
UNRESTRICTED restricts nothing. Passed to a read, it skips the default, for code that is not acting for a user, such as a scheduled job or an admin tool:
from audit_trail import UNRESTRICTED
page = audit.query.list_groups(session, since=since, visibility=UNRESTRICTED)
It is easy to search for, so every place that skips the default can be reviewed. Only UNRESTRICTED itself skips it: an equal Visibility() passed to a read narrows the default by nothing, so the default applies.
In a by_actor_type mapping, UNRESTRICTED and Visibility() behave the same: same_scope and model rules narrow both.
Visibility.NOTHING allows no entry. It is the default of by_actor_type for an actor type it does not know, and what same_scope gives a context without a scope_id.
Both print by name, so visibility_for shows when a role gets one of them: repr(UNRESTRICTED) is UNRESTRICTED and repr(Visibility.NOTHING) is Visibility.NOTHING.
Labels¶
LabelResolver labels the objects that ids in changes refer to (see labels). Build it with audit.label_resolver(Base) to get the trail's default visibility:
resolver = audit.label_resolver(Base)
labels = resolver.resolve(
session, [a for group in page.groups for a in group.activities]
)
The label of an object is taken from the entries the caller may see, so an object of a hidden type or scope gets #<id>. Fields the visibility hides for the entry's object type are not labelled.
Partial groups¶
A group shows only the entries the caller may see, so by itself it does not say that its transaction did more. With Visibility(mark_hidden=True), Group.partial is True on the groups of list_groups, object_history and related whose transaction has entries that the row rules hide (and Operation.partial on the operations of list_operations that have such entries):
It costs one more query per page. Entries that compaction merges away, or that object_history leaves out as not part of the record's history, do not count. Without mark_hidden, partial is always False.
Checking the effective rules¶
audit.visibility_for(ctx) returns the Visibility a read without a visibility argument would apply for a context, with a short repr that lists only the rules that are set:
from audit_trail import AuditContext
print(audit.visibility_for(AuditContext(actor_type="support", scope_id="acme")))
# Visibility(scope_ids={'acme'}, hidden_header_fields={'remote_addr', 'user_agent'}, types={'Invoice': TypeRule(hidden_fields={'iban'})})
UNRESTRICTED and Visibility.NOTHING print by name. Without ctx it uses the current context. It returns None when no default is set. Use it in tests, to pin what each role sees:
def test_support_never_sees_ibans() -> None:
visibility = audit.visibility_for(AuditContext(actor_type="support", scope_id="t1"))
assert "iban" in visibility.types["Invoice"].hidden_fields
Limitations¶
- The database is not restricted. Visibility is a read filter in the library. Your database role can still read every row, and so can any code that queries the audit tables without
audit.query. Row-level security in PostgreSQL is not part of this release. - Only
audit.queryandLabelResolverapply it. Exports, tamper-evidence verification, the evidence ledger,scruband thetestinghelpers read every row. To never store a value at all, use the write-time policiesredact,hashandexclude, orglobal_redact(see audited models). - Filters match hidden values. The
actor_id,scope_idsandcorrelation_idfilters oflist_groups, theactor_idandscope_idsfilters oflist_operations, and the correlation id ofrelated, match the stored values, also of header fields the visibility hides. A caller who chooses the filter value can find out which transactions match, even though the page shows the value masked. Do not take such a filter from a user who may not see that field. - A hidden
correlation_idstill groups operations.list_operationsgroups entries by the stored correlation id, also when the visibility hides it. The operation then showscorrelation_idasNone, but itstransaction_countandentry_countstill tell the caller that its transactions share one id, and how many there are. If that is itself sensitive, list such callers' entries withlist_groupsinstead. - A
LabelResolverbuilt by hand applies no default.LabelResolver(audit.tables, Base)does not know the trail's resolver. Useaudit.label_resolver(Base), or passvisibility=yourself. Pass it rows read with the same visibility: it does not mask the rows it is given. "[hidden]"is a marker. A stored value that is literally"[hidden]"looks the same as a masked one, and compaction treats it as a marker, as it does"***".