auditmeta

package
v0.511.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

README

Application Audit Metadata Preparation Module

Shared preparation helpers for metadata-aware audit requests before they enter the core DeltaScope audit service.

Files

File Responsibility
errors.go Defines typed metadata-preparation errors, including MySQL/TiDB alias conflicts and PostgreSQL schema/database validation, for adapter-level classification
prepare.go Opens metadata clients, detects dialect, binds MySQL/TiDB catalog aliases through connresolve, validates PostgreSQL database/schema selection, resolves schema, and returns prepared audit context
targets.go Infers Mutation Targets via MutationTargetTables() from every successfully parsed statement even when another bounded statement has a parser error; fails only when no statement can be parsed
client.go Bridges MySQL-compatible infrastructure providers into the shared preparation client contract
prepare_test.go Verifies shared metadata-aware preparation behavior, including schema inference from valid statements around one parser error

Exports

  • Client
  • ConnectionConfig — includes ConnectTimeout for metadata connection timeout
  • Request
  • PreparedAudit
  • Prepare(ctx, request)
  • Error / ErrorKind — typed preparation failures, including ErrorMySQLDatabaseSchemaConflict and ErrorPostgreSQLDatabaseRequired

Dependencies

  • Upstream: internal/interfaces/cli, internal/interfaces/http, internal/interfaces/mcp
  • Downstream: internal/application/audit, internal/application/connresolve, internal/domain/spec, internal/infrastructure/metadata/mysql

Update Rule

  • If members/interfaces/dependencies change, update this file in same change.

Documentation

Overview

Package auditmeta prepares metadata-aware audit requests for multiple adapters. input: MySQL-compatible metadata connections and provider methods from infrastructure adapters output: shared client wrapper implementing the metadata preparation client contract pos: infrastructure-backed client bridge for shared metadata-aware audit preparation note: if this file changes, update this header and module README.md.

Package auditmeta prepares metadata-aware audit requests for multiple adapters. input: metadata-preparation failures encountered while opening connections, validating dialects, and resolving schemas output: typed shared errors, including MySQL/TiDB alias conflicts and PostgreSQL schema/database validation, that let adapters classify metadata-prep failures without brittle string matching pos: shared error taxonomy for CLI and MCP metadata-aware preparation flows note: if this file changes, update this header and module README.md.

Package auditmeta prepares metadata-aware audit requests for multiple adapters. input: audit SQL text, requested dialect/schema preferences, metadata connection configs, and metadata clients output: prepared metadata-aware audit context with opened client, connresolve MySQL/TiDB catalog aliases, or bounded MySQL/TiDB and PostgreSQL connection validation errors pos: shared application helper between transport adapters and the core audit service note: if this file changes, update this header and module README.md.

Package auditmeta prepares metadata-aware audit requests for multiple adapters. input: parsed and partially parsed SQL statements plus normalized statement specs from the audit application layer output: Mutation Target facts from valid statements used for schema inference before metadata-aware audit execution pos: shared SQL target inference helper for metadata-aware adapters note: if this file changes, update this header and module README.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	appaudit.MetadataProvider
	DetectDialect(ctx context.Context) (spec.Dialect, error)
	FindSchemasForTable(ctx context.Context, table string) ([]string, error)
	Close() error
}

Client describes the metadata-aware capabilities required before audit execution.

func OpenClient added in v0.18.0

func OpenClient(config ConnectionConfig) (Client, error)

OpenClient opens a shared metadata client for the requested dialect.

type ConnectionConfig

type ConnectionConfig struct {
	Host           string
	Port           int
	Socket         string
	User           string
	Password       string
	Database       string
	Dialect        spec.Dialect
	ConnectTimeout time.Duration
	TLSMode        string         // "disabled" (default) or "enabled"
	CACert         *x509.CertPool // pre-parsed CA pool; only used when tls_mode=enabled
}

ConnectionConfig describes one metadata-aware connection opening request.

type Error

type Error struct {
	Kind    ErrorKind
	Message string
	Err     error
}

Error is a typed metadata-preparation failure.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorKind

type ErrorKind string

ErrorKind classifies one metadata-preparation failure.

const (
	ErrorInvalidSQL                  ErrorKind = "invalid_sql"
	ErrorDialectMismatch             ErrorKind = "dialect_mismatch"
	ErrorSchemaHintRequired          ErrorKind = "schema_hint_required"
	ErrorSchemaLookupFailed          ErrorKind = "schema_lookup_failed"
	ErrorConnectionOpen              ErrorKind = "connection_open_failed"
	ErrorDialectDetect               ErrorKind = "dialect_detect_failed"
	ErrorPostgreSQLDatabaseRequired  ErrorKind = "postgresql_database_required"
	ErrorMySQLDatabaseSchemaConflict ErrorKind = "mysql_database_schema_conflict"
)

type PreparedAudit

type PreparedAudit struct {
	Client        Client
	Dialect       spec.Dialect
	Schema        string
	DialectSource string
	SchemaSource  string
}

PreparedAudit captures the shared metadata-aware audit context needed by adapters.

func Prepare

func Prepare(ctx context.Context, request Request) (*PreparedAudit, error)

Prepare opens a metadata client, resolves dialect and schema, and returns prepared audit context.

type Request

type Request struct {
	SQL                  string
	Connection           ConnectionConfig
	RequestedDialect     spec.Dialect
	ExplicitDialect      bool
	ExplicitSchema       string
	ExplicitSchemaSource string
	SchemaHint           string
	OpenClient           func(ConnectionConfig) (Client, error)
}

Request describes one shared metadata-aware audit preparation request.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL