Documentation
¶
Overview ¶
Package db is the database-structure sensor (dimension "db"). Unlike the security sensor it does not walk source files: it resolves the configured database.schema_paths from disk (it is the filesystem-side caller, ADR 0014), asks the provider's SchemaParser for a neutral db.Schema, runs the core dbrules over it, and stamps baseline fingerprints. It is honest about NOT measuring: disabled, no schema_paths, or a provider without a schema parser return Measured=false with a note — never a false "clean, 0 findings".
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
Measured bool
Note string
Res findings.SensorResult
}
Result is the DB audit outcome, including whether the DB was measured at all. Measured=false with a Note is the honest "not audited" state (disabled, no schema_paths, provider without a schema parser) — distinct from "audited, 0 findings".
type Sensor ¶
type Sensor struct {
// contains filtered or unexported fields
}
Sensor audits the database structure, driven by a schema parser resolved by the caller from the input's shape (.prisma / .sql — ADR 0018). The rule logic lives in the core (dbrules); the sensor only reads/orders the schema files and stamps identity. It depends on exactly the capability it uses, providers.SchemaParser — not LanguageProvider — so the "no parser" case is a compile-time concern of the adapter, not a runtime branch here.
func New ¶
func New(p providers.SchemaParser) *Sensor
New builds a DB sensor backed by a schema parser.
func (*Sensor) Audit ¶
func (s *Sensor) Audit(ctx auditctx.AuditContext) (Result, error)
Audit resolves the schema, runs the core DB rules, and stamps fingerprints. It returns Measured=false + a Note (never an error) for the honest not-measured cases; a hard error only for a configured-but-missing schema file or a parse failure — silently skipping those would be the false "all good" codefit exists to catch.
func (*Sensor) OwnedCategories ¶
OwnedCategories are the baseline Item categories the DB sensor produces: its finding dimension ("db") plus its per-rule surface categories. They scope the unified baseline (ADR 0019) and must be disjoint from every other sensor's.
func (*Sensor) Run ¶
func (s *Sensor) Run(ctx auditctx.AuditContext) (findings.SensorResult, error)
Run adapts Audit to the sensors.Sensor interface (for future aggregate use in scan-all). The standalone tool calls Audit directly to get Measured/Note.