Skip to content

Sensitive Tables

Some tables hold data that the features which browse or query arbitrary tables should leave alone, e.g. the users, the sessions, the logs and the queues. A module declares them, and the features ask one registry, so a module doesn't have to be added to the settings of each feature.

Declaring Them

A row declares its own table:

[SensitiveTable]
public sealed class ApiKeyRow : Row<ApiKeyRow.RowFields>, IIdRow

An assembly declares tables by pattern, e.g. the tables of a feature that have no rows, or a set of tables with a prefix:

[assembly: SensitiveTables("acc_*", "aud_*", "exc_*", "DataAuditLog")]

A pattern is a table name, with or without a schema, e.g. Users or dbo.Users, where * matches any text and ? one character. A pattern without a schema matches the table in the default schema (dbo, public) or in a database without schemas, like SQLite; the case is ignored.

The Pro extensions declare the acc_*, aud_*, cfg_*, exc_*, job_* and mail_* tables and DataAuditLog, Serenity.Extensions the loc_* tables, and the dashboards the dash_* and dsrc_* tables.

Using Them

ISensitiveTableRegistry, which services.AddEntities() registers, tells whether a table is sensitive:

if (sensitiveTables.IsSensitive(schema: "dbo", table: "aud_Events"))
    // leave it out

Patterns lists the patterns, e.g. to combine them with rules of another kind. The registry collects them once, from the assemblies of the type source; DefaultSensitiveTableRegistry.FromPatterns(...) makes one of a list, e.g. for a test.

Data Explorer doesn't list them, besides its own default exclusions, and the SQL data sources of the dashboards protect them, unless their settings turn the defaults off.