sqlprotect

package
v1.167.0 Latest Latest
Warning

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

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

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package sqlprotect checks a statement a transform's covered caller sends against the columns the transform protects (#2634): a protected column may be selected as it is, and used nowhere else. An expression, a function argument, a filter, a join condition, a grouping, an ordering (by name or by position), a window, DISTINCT, a set operation other than UNION ALL, a rename, a column list on an alias, and a write all let a caller learn or copy the value the transform hides, so each is refused naming the column and the handler. A statement the parser cannot read is refused when it names a protected column at all.

Names are followed through aliases, derived tables and CTEs by name: a column named like a protected one, anywhere a protected table is in scope, is treated as the protected column, which refuses a statement that merely shares the name rather than ever admitting one that hides it. A view is followed through its definition, which ViewReader supplies.

The grammar is PostgreSQL's (github.com/multigres/multigres), which reads the statements a Trino connection and an application database are sent alike; Trino's own extensions it cannot read (try_cast, table functions) are refused for a covered caller only.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(ctx context.Context, sql string, protected map[string]string, views ViewReader) error

Check refuses sql when it uses a column protected maps ("catalog.schema.table.column", lowercase, to its handler) other than by selecting it as it is. views reads a view's definition; nil follows none.

func ViewUse

func ViewUse(ctx context.Context, def string, protected map[string]string) error

ViewUse refuses a view's definition that uses a protected column other than by selecting it as it is: such a view would hand a covered caller what it computed from the value.

Types

type RefusalError

type RefusalError struct {
	Column  string
	Handler string
	Why     string
}

RefusalError is a statement refused for a protected column.

func (*RefusalError) Error

func (e *RefusalError) Error() string

type ViewReader

type ViewReader func(ctx context.Context, catalog, schema, name string) string

ViewReader returns the SQL a view is defined by, "" for a relation that is not a view. Its name is as the statement wrote it.

Jump to

Keyboard shortcuts

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