validation

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package validation provides shared pipeline configuration validation utilities that are used by both the workflow engine (at startup) and the wfctl CLI tool (as static analysis). This avoids duplicating logic between the two consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSQLColumns

func ExtractSQLColumns(query string) []string

ExtractSQLColumns parses a SQL SELECT statement and returns the column names (or aliases) from the SELECT clause.

func GenerateChallenge added in v0.10.1

func GenerateChallenge(adminSecret, rejectionHash string, t time.Time) string

GenerateChallenge generates a 3-word HMAC challenge token for the given rejection hash using the admin secret, anchored to the 1-hour bucket of t. Pass time.Now() for normal use; pass a fixed time in tests for determinism.

adminSecret should come from an environment variable (e.g. WFCTL_ADMIN_SECRET).

func ParseAPIHeaderOverride added in v0.10.1

func ParseAPIHeaderOverride(r *http.Request) (string, bool)

ParseAPIHeaderOverride extracts an override token from the X-Workflow-Override HTTP request header. Returns (token, true) if present, ("", false) otherwise.

func ParsePRCommentOverride added in v0.10.1

func ParsePRCommentOverride(comment string) (string, bool)

ParsePRCommentOverride extracts an override token from a GitHub PR comment. The expected format is "/wfctl-override <token>". Returns (token, true) if found, ("", false) otherwise.

func ParseWorkflowDispatchOverride added in v0.10.1

func ParseWorkflowDispatchOverride(inputs map[string]string) (string, bool)

ParseWorkflowDispatchOverride extracts an override token from GitHub Actions workflow_dispatch inputs. Looks for the key "override_token" in the inputs map. Returns (token, true) if present, ("", false) otherwise.

func TokenFromParts added in v0.10.1

func TokenFromParts(words []string) string

TokenFromParts joins three BIP-39 words with hyphens (inverse of parsing).

func VerifyChallenge added in v0.10.1

func VerifyChallenge(adminSecret, rejectionHash, token string, t time.Time) bool

VerifyChallenge returns true if token matches the expected challenge for the given rejection hash at time t. It checks both the current and previous 1-hour buckets to provide a grace period across bucket boundaries. Comparison is constant-time to prevent timing side-channel attacks.

Types

type RefValidationResult

type RefValidationResult struct {
	Warnings []string
	Errors   []string
}

RefValidationResult holds the outcome of pipeline template reference validation. Warnings are suspicious but non-fatal references; Errors are definitively wrong.

func ValidatePipelineTemplateRefs

func ValidatePipelineTemplateRefs(pipelines map[string]any, reg ...*schema.StepSchemaRegistry) *RefValidationResult

ValidatePipelineTemplateRefs validates all pipeline step template expressions in the given pipelines map for dangling step references and output field mismatches. It performs the same checks as `wfctl template validate` at the pipeline template level.

The pipelines parameter is expected to be a map[string]any where each value is a pipeline config map containing a "steps" field (as parsed from YAML).

An optional *schema.StepSchemaRegistry may be provided to supply plugin-registered step schemas. When absent, a default built-in registry is created once and reused across all pipelines.

func (*RefValidationResult) HasIssues

func (r *RefValidationResult) HasIssues() bool

HasIssues returns true when there are any warnings or errors.

Jump to

Keyboard shortcuts

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