security

package
v0.0.0-...-0a7bcea Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QueryValidator

type QueryValidator struct {
	// contains filtered or unexported fields
}

QueryValidator validates SQL queries using a deterministic 4-stage state machine

func NewQueryValidator

func NewQueryValidator() *QueryValidator

NewQueryValidator creates a new query validator

func (*QueryValidator) InspectQuery

func (qv *QueryValidator) InspectQuery(rawQuery string) ValidationResult

InspectQuery runs the explicit validation state machine and returns a structured ValidationResult

func (*QueryValidator) ValidateQuery

func (qv *QueryValidator) ValidateQuery(query string) error

ValidateQuery checks if the query passes all stages of the validation state machine

type ValidationResult

type ValidationResult struct {
	IsValid              bool            `json:"is_valid"`
	Stage                ValidationStage `json:"stage"`
	NormalizedSQL        string          `json:"normalized_sql,omitempty"`
	StatementType        string          `json:"statement_type,omitempty"`
	ErrorReason          string          `json:"error_reason,omitempty"`
	AgentRemediationHint string          `json:"agent_remediation_hint,omitempty"`
}

ValidationResult provides rich diagnostics for Users (UX), Developers (DX), and AI Agents (AX)

type ValidationStage

type ValidationStage string

ValidationStage represents the explicit state of the SQL validation pipeline

const (
	StageSanitize        ValidationStage = "SANITIZE_NORMALIZE"
	StageRestrictedCheck ValidationStage = "RESTRICTED_IDENTIFIER_CHECK"
	StageASTVerify       ValidationStage = "AST_READONLY_VERIFY"
	StageValidated       ValidationStage = "VALIDATED"
	StageRejected        ValidationStage = "REJECTED"
)

Jump to

Keyboard shortcuts

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