Documentation
¶
Overview ¶
Package audit orchestrates audit use cases at the application layer. input: extracted domain statements and the registered rule engine output: aggregated report results with statement/global findings and preserved statement-level impact estimates pos: application evaluation step between extraction/metadata refinement and reporting note: if this file changes, update this header and module README.md.
Package audit enriches evaluated findings with shared explanation metadata. input: rule findings, shipped catalog entries, and optional statement metadata context output: additive per-finding explanation data without changing verdict semantics pos: application explanation enrichment between evaluation and report aggregation note: if this file changes, update this header and module README.md.
Package audit orchestrates audit use cases at the application layer. input: application-owned parsed SQL statements and parser-neutral extractors output: first-pass StatementSpec values plus attached shape-only impact facts for later rule evaluation pos: application extraction step between parsing and rule execution note: if this file changes, update this header and module README.md.
Package audit orchestrates audit use cases at the application layer. input: extracted statement-local DML shape facts plus optional metadata snapshots for refinement output: conservative DML impact estimates attached during extraction and upgraded after metadata enrichment pos: application impact estimation step between extraction, metadata enrichment, and rule evaluation note: if this file changes, update this header and module README.md.
Package audit orchestrates audit use cases at the application layer. input: optional metadata providers plus parsed statement targets for enrichment output: metadata-enriched statements for rules that can use live instance or schema facts pos: application-layer bridge between provider-backed metadata and domain statements note: if this file changes, update this header and module README.md.
Package audit provides application-layer parser mismatch hints.
Package audit orchestrates audit use cases at the application layer. input: SQL text, selected dialect, and infrastructure-backed parser adapters output: application-owned parsed statements for later extraction and rule evaluation pos: application parsing entrypoint between interfaces and parser infrastructure note: if this file changes, update this header and module README.md.
Package audit orchestrates audit use cases at the application layer. input: audit requests carrying SQL text, dialect, optional policy override paths, and optional metadata providers output: end-to-end audit results assembled from policy loading, parsing, extraction, metadata enrichment, post-enrichment impact refinement, and rule evaluation pos: application service entrypoint for the unified offline/metadata-aware SQL audit use case with preserved statement impact estimates note: if this file changes, update this header and module README.md.
Index ¶
- Variables
- func AuditSQL(ctx context.Context, request Request) (report.Result, error)
- func EvaluateStatements(ctx context.Context, registry *rule.Registry, statements []spec.Statement) (report.Result, error)
- func Extract(ctx context.Context, parsed ParsedSQL) ([]spec.Statement, error)
- type IndexOwnerResolver
- type MetadataProvider
- type MetadataRequest
- type ParsedSQL
- type ParsedStatement
- type PlanEstimator
- type PostgreSQLCapabilityBoundaryError
- type Request
- type Service
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptySQL indicates the request did not include auditable SQL text. ErrEmptySQL = errors.New("audit SQL must not be empty") // ErrUnknownDialect indicates the request did not specify a supported dialect. ErrUnknownDialect = errors.New("audit dialect must be mysql, tidb, or postgresql") // ErrUnsupportedStatement indicates at least one parsed statement is recognized but unsupported. ErrUnsupportedStatement = errors.New("audit includes unsupported statements") )
Functions ¶
Types ¶
type IndexOwnerResolver ¶ added in v0.18.0
type IndexOwnerResolver interface {
ResolveTableForIndex(ctx context.Context, dialect spec.Dialect, schema string, index string) (string, error)
}
IndexOwnerResolver optionally resolves standalone index statements back to owning tables.
type MetadataProvider ¶
type MetadataProvider interface {
LoadInstanceFacts(ctx context.Context, dialect spec.Dialect, schema string) (*spec.InstanceFacts, error)
LoadTableSnapshot(ctx context.Context, dialect spec.Dialect, schema string, table string) (*spec.TableSnapshot, error)
}
MetadataProvider supplies optional instance and schema facts for one audit run.
type MetadataRequest ¶
type MetadataRequest struct {
Schema string
Provider MetadataProvider
}
MetadataRequest describes one optional metadata-aware audit invocation.
type ParsedSQL ¶
type ParsedSQL struct {
Dialect spec.Dialect `json:"dialect"`
Statements []ParsedStatement `json:"statements"`
Warnings []string `json:"warnings,omitempty"`
}
ParsedSQL is the application-owned parsing result used by later extraction steps.
type ParsedStatement ¶
type ParsedStatement struct {
Kind spec.Kind `json:"kind"`
RawSQL string `json:"raw_sql"`
Line int `json:"line,omitempty"`
Column int `json:"col,omitempty"`
Extractor spec.StatementExtractor `json:"-"`
}
ParsedStatement keeps application-facing statement metadata while hiding parser nodes.
type PlanEstimator ¶ added in v0.18.0
type PlanEstimator interface {
LoadPlanEstimate(ctx context.Context, statement spec.Statement) (*spec.ImpactEstimate, error)
}
PlanEstimator optionally loads planner-backed DML impact estimates.
type PostgreSQLCapabilityBoundaryError ¶ added in v0.20.0
type PostgreSQLCapabilityBoundaryError struct {
Message string
}
PostgreSQLCapabilityBoundaryError reports that PostgreSQL parsing needs a PostgreSQL-capable build.
func (*PostgreSQLCapabilityBoundaryError) Error ¶ added in v0.20.0
func (e *PostgreSQLCapabilityBoundaryError) Error() string
type Request ¶
type Request struct {
SQL string
Dialect spec.Dialect
ConfigPath string
Schema string
MetadataProvider MetadataProvider
Metadata *MetadataRequest
}
Request describes one application-level audit invocation.