scriptanalysis

package
v2.0.0-...-00053fb Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package scriptanalysis runs prepared script analysis without discovering documents.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidBatch = errors.New("execution: invalid prepared batch")

Functions

func ScriptInputAction

func ScriptInputAction(action *definition.ExecAction) (string, bool)

ScriptInputAction removes the ref and lowercases the owner and repository. It preserves the case of any action subpath.

Types

type ActionInput

type ActionInput struct {
	Site  checkinputs.ScriptInput
	Value *definition.ActionArgument
}

ActionInput is a typed, mapped action argument, never a shell run command.

type Batch

type Batch struct {
	CallGraph invocation.Graph
	Scopes    []*Scope
	Scripts   []Unit
	// Collected reports complete script collection. A scopes-only batch has none.
	Collected bool
}

Batch binds execution inputs to a published graph. NewBatch validates it; its zero value is unprepared. Tools receive the batch ForTool returns and may select subsets of its scripts and scopes.

func NewBatch

func NewBatch(graph invocation.Graph, collection Collection) (Batch, error)

NewBatch validates complete script collection or an explicit scopes-only batch.

func (Batch) Fact

func (batch Batch) Fact(index int, includeExecution bool) (checkinputs.Script, bool)

Fact projects a validated script; false means the batch or index is unavailable. With includeExecution, a run script always has a Runtime; it is empty when the analysis did not resolve execution.

func (Batch) ForTool

func (batch Batch) ForTool(name string) (Batch, error)

ForTool returns a batch with independent configuration and environment values for the named tool.

func (Batch) Valid

func (batch Batch) Valid() bool

type BatchAnalyzer

type BatchAnalyzer interface {
	AnalyzeScripts(context.Context, Batch) ([]*finding.Finding, error)
}

type Collection

type Collection struct {
	Declarations *parsing.SourceSnapshots
	Scopes       []*Scope
	Scripts      []ScriptRequest
	Collected    bool
}

type Deployment

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

Deployment binds an action's display path and runtime placement to its source. Its zero value belongs to a workflow entry.

func NewDeployment

func NewDeployment(snapshots *parsing.SourceSnapshots, snapshot parsing.SourceSnapshot, address, displayPath string, mapped bool) (Deployment, error)

NewDeployment requires snapshot to be admitted by snapshots and address to resolve to its captured revision.

func (Deployment) ActionPath

func (d Deployment) ActionPath() string

func (Deployment) Address

func (d Deployment) Address() string

func (Deployment) SourcePath

func (d Deployment) SourcePath() string

type FactAnalyzer

type FactAnalyzer struct {
	Analyzer         results.Analyzer
	Options          json.RawMessage
	IncludeExecution bool
}

func (FactAnalyzer) AnalyzeScripts

func (adapter FactAnalyzer) AnalyzeScripts(ctx context.Context, batch Batch) ([]*finding.Finding, error)

type Scope

type Scope struct {
	Bindings *rulebinding.Scope
	Paths    execution.Paths
	Reader   *files.Reader // records the filesystem reads tools make in this scope
	// Config is a host-owned prepared value. Internal consumers treat it as read-only;
	// ForTool detaches selected settings before a tool reads them.
	Config           *configuration.Config
	ConfigProvenance configuration.Provenance
	Deployment       Deployment
	Composite        bool
	Context          invocation.Context
}

Scope identifies a workflow or composite invocation independently of whether it contains scripts, so configuration failures are still observable.

type ScriptRequest

type ScriptRequest struct {
	Occurrence   invocation.ID
	DefaultShell *string
	Input        *checkinputs.ScriptInput
	Execution    *scripts.Execution
	Environment  []scripts.EnvironmentNames
	Interpreters *commands.Registry
}

ScriptRequest contains invocation policy; declarations come from the source registry.

type Service

type Service struct{ Analyzers []BatchAnalyzer }

Service owns scheduling and joining every script analyzer in a prepared batch.

func (Service) Run

func (s Service) Run(ctx context.Context, batch Batch) ([]*finding.Finding, error)

type Unit

type Unit struct {
	Revision    sourcetext.Revision
	Coordinates sourcetext.Coordinates
	Occurrence  invocation.ID
	Reference   sourcetext.Reference
	Run         *definition.ExecRun
	Input       *ActionInput
	Shell       *string
	Path        string
	Content     []byte
	Origin      *workflows.IgnoreOrigin
	Owner       *finding.Owner
	Scope       *Scope
	// Execution is nil when the analysis did not resolve the run's shell and
	// working directory.
	Execution    *scripts.Execution
	Environment  []scripts.EnvironmentNames
	Interpreters *commands.Registry
}

Unit snapshots invocation context before analyzers run.

func (Unit) Config

func (u Unit) Config() *configuration.Config

Config is the configuration of the script's scope.

func (Unit) Key

func (u Unit) Key() *sourcetext.Position

Key is the position of the input name or the run key.

func (Unit) RuntimeShell

func (u Unit) RuntimeShell() scripts.Shell

RuntimeShell returns the resolved shell. Unresolved execution returns the zero shell.

func (Unit) Source

func (u Unit) Source() *definition.ScriptSource

Source maps Text back to its declaring YAML scalar.

func (Unit) Text

func (u Unit) Text() string

Text returns the script text: the action input value or the run body.

func (Unit) Value

func (u Unit) Value() *sourcetext.Position

Value is the position of the script value.

func (Unit) WorkingDirectory

func (u Unit) WorkingDirectory() (string, bool)

WorkingDirectory returns the directory a tool runs the script in and whether it is known. Unresolved execution keeps the tool's own working directory, so it reports an empty, known directory.

Directories

Path Synopsis
Package backends adapts the shared snippet protocol to registered script tools.
Package backends adapts the shared snippet protocol to registered script tools.
Package contract defines script-tool registration independently of tool names and transports.
Package contract defines script-tool registration independently of tool names and transports.
Package managed runs a tool provider through a managed document analyzer: a component that speaks the integration contract the provider's manifest names negotiates each configuration and checks the scripts it accepts; the provider's own transport checks the rest.
Package managed runs a tool provider through a managed document analyzer: a component that speaks the integration contract the provider's manifest names negotiates each configuration and checks the scripts it accepts; the provider's own transport checks the rest.
Package registry registers the tool providers bundled with actionlint.
Package registry registers the tool providers bundled with actionlint.

Jump to

Keyboard shortcuts

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