adversarial

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func A1_Branch

func A1_Branch(ctx context.Context, pool Pool, isBonus bool) error

A1: Branch — conditional write to critical table inside branch without strong isolation.

func A2_Reassignment

func A2_Reassignment(ctx context.Context, pool Pool) error

A2: Reassignment — query variable reassigned to critical table update.

func A3_Alias

func A3_Alias(ctx context.Context, pool Pool) error

A3: Alias — aliased query string targeting critical table.

func A5_NestedFunction

func A5_NestedFunction(ctx context.Context, pool Pool) error

A5: Nested Function — closure modifying critical table.

func A7_HelperNoIso

func A7_HelperNoIso(ctx context.Context, pool Pool, h Helper) error

A7: Interface / Helper — dynamic WithTx helper invocation without isolation level.

func A8_NonDBWithTxHelper_MustBeSafe added in v1.2.0

func A8_NonDBWithTxHelper_MustBeSafe(ctx context.Context, svc OrderService) error

func A9_WorkerPoolBegin_MustBeSafe added in v1.2.0

func A9_WorkerPoolBegin_MustBeSafe(wp WorkerPool) error

func A10_FakeDBProxy_MustBeSafe added in v1.2.0

func A10_FakeDBProxy_MustBeSafe(ctx context.Context, fp FakePool) error

func A11_FakeSearchProxy_MustBeSafe added in v1.2.0

func A11_FakeSearchProxy_MustBeSafe(ctx context.Context, sp FakeSearchPool) error

func A12_FakeTxSpoofing_MustBeSafe added in v1.2.0

func A12_FakeTxSpoofing_MustBeSafe(ctx context.Context, fp FakeTxPool) error

Types

type FakeDBProxy added in v1.2.0

type FakeDBProxy struct{}

A10: Fake DB Proxy — single-method Exec proxy without Query or lifecycle capability must NOT trigger false positive.

func (FakeDBProxy) Exec added in v1.2.0

func (FakeDBProxy) Exec(ctx context.Context, sql string, args ...any) error

type FakePool added in v1.2.0

type FakePool struct{}

func (FakePool) Begin added in v1.2.0

func (FakePool) Begin(ctx context.Context) (FakeDBProxy, error)

type FakeSearchPool added in v1.2.0

type FakeSearchPool struct{}

func (FakeSearchPool) Begin added in v1.2.0

type FakeSearchProxy added in v1.2.0

type FakeSearchProxy struct{}

A11: Fake Search Proxy — single-method Query proxy without Exec or lifecycle capability must NOT trigger false positive.

func (FakeSearchProxy) Query added in v1.2.0

func (FakeSearchProxy) Query(ctx context.Context, sql string, args ...any) error

type FakeTx added in v1.2.0

type FakeTx interface {
	Exec(string) error
	Commit() error
	Rollback() error
}

A12: Fake Tx Spoofing — custom non-DB interface resembling transaction must NOT trigger violation.

type FakeTxPool added in v1.2.0

type FakeTxPool interface {
	Begin(ctx context.Context) (FakeTx, error)
}

type Helper

type Helper struct{}

func (Helper) WithTx

func (Helper) WithTx(ctx context.Context, pool Pool, fn func(*sql.Tx) error, opts ...TxOptions) error

type OrderService added in v1.2.0

type OrderService struct{}

A8: Non-DB WithTx Helper — orderService.WithTx is a non-DB helper and must NOT trigger false positive.

func (OrderService) WithTx added in v1.2.0

func (OrderService) WithTx(ctx context.Context, fn func() error) error

type Pool

type Pool interface {
	Begin(ctx context.Context) (*sql.Tx, error)
	BeginTx(ctx context.Context, opts TxOptions) (*sql.Tx, error)
}

type TxOptions

type TxOptions struct {
	IsoLevel string
}

type TxService

type TxService[T any] struct {
	// contains filtered or unexported fields
}

A6: Generic — generic transaction service modifying critical table without isolation options.

func (*TxService[T]) Run

func (s *TxService[T]) Run(ctx context.Context) error

type WalletRepo

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

A4: Wrapper — repository struct method with default Begin on critical table.

func (*WalletRepo) Deduct

func (w *WalletRepo) Deduct(ctx context.Context) error

type WorkerPool added in v1.2.0

type WorkerPool struct {
	Workers []int
}

A9: Non-DB WorkerPool — workerPool.Begin is not a database transaction and must NOT trigger false positive.

func (WorkerPool) Begin added in v1.2.0

func (WorkerPool) Begin() error

Jump to

Keyboard shortcuts

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