linter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SupportsAutoFix

func SupportsAutoFix(linterName string) bool

SupportsAutoFix returns true if the linter supports automatic fixing.

Types

type FormatLinter

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

FormatLinter checks for YAML formatting issues in workflow files.

func NewFormatLinter

func NewFormatLinter(settings *config.FormatSettings) *FormatLinter

NewFormatLinter creates a new FormatLinter instance.

func (*FormatLinter) FixWorkflow

func (l *FormatLinter) FixWorkflow(wf *workflow.Workflow) error

FixWorkflow automatically fixes formatting issues in a single workflow.

func (*FormatLinter) LintWorkflow

func (l *FormatLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for formatting issues.

type InjectionLinter

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

InjectionLinter checks for shell injection vulnerabilities in workflow files. It detects dangerous use of GitHub context expressions in run: commands that could allow attackers to inject arbitrary commands.

func NewInjectionLinter

func NewInjectionLinter() *InjectionLinter

NewInjectionLinter creates a new InjectionLinter instance.

func (InjectionLinter) FixWorkflow

func (InjectionLinter) FixWorkflow(_ *workflow.Workflow) error

FixWorkflow implements Linter.FixWorkflow as a no-op.

func (*InjectionLinter) LintWorkflow

func (l *InjectionLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for injection vulnerabilities.

type Issue

type Issue struct {
	File    string // Name of the workflow file with the issue
	Line    int    // Line number where the issue was found (0 if not applicable)
	Linter  string // Name of the linter that found this issue
	Message string // Description of the linting issue
}

Issue represents a linting problem found in a workflow file. It contains the file name, line number, linter name, and a descriptive message about the issue.

func (*Issue) Key

func (i *Issue) Key() string

Key returns a unique identifier for this issue.

func (*Issue) String

func (i *Issue) String() string

String implements fmt.Stringer for Issue.

type Linter

type Linter interface {
	// LintWorkflow checks a single workflow and returns issues found.
	LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

	// FixWorkflow attempts to fix issues in a single workflow.
	// For linters that don't support fixing, this should be a no-op (return nil).
	FixWorkflow(wf *workflow.Workflow) error
}

Linter is the interface that all individual linters must implement. Each linter operates on a single workflow; iteration is handled by the orchestrator.

type PermissionsLinter

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

PermissionsLinter checks for missing permissions configuration in workflows.

func NewPermissionsLinter

func NewPermissionsLinter() *PermissionsLinter

NewPermissionsLinter creates a new PermissionsLinter instance.

func (PermissionsLinter) FixWorkflow

func (PermissionsLinter) FixWorkflow(_ *workflow.Workflow) error

FixWorkflow implements Linter.FixWorkflow as a no-op.

func (*PermissionsLinter) LintWorkflow

func (l *PermissionsLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for missing permissions configuration.

type SecretsLinter

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

SecretsLinter checks for hardcoded secrets in workflow files.

func NewSecretsLinter

func NewSecretsLinter() *SecretsLinter

NewSecretsLinter creates a new SecretsLinter instance.

func (SecretsLinter) FixWorkflow

func (SecretsLinter) FixWorkflow(_ *workflow.Workflow) error

FixWorkflow implements Linter.FixWorkflow as a no-op.

func (*SecretsLinter) LintWorkflow

func (l *SecretsLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for hardcoded secrets.

type StyleLinter

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

StyleLinter checks for style and naming convention issues in workflow files.

func NewStyleLinter

func NewStyleLinter(settings *config.StyleSettings) *StyleLinter

NewStyleLinter creates a new StyleLinter instance.

func (StyleLinter) FixWorkflow

func (StyleLinter) FixWorkflow(_ *workflow.Workflow) error

FixWorkflow implements Linter.FixWorkflow as a no-op.

func (*StyleLinter) LintWorkflow

func (l *StyleLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for style issues.

type VersionsLinter

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

VersionsLinter checks for actions using version tags instead of commit hashes.

func NewVersionsLinter

func NewVersionsLinter(ctx context.Context) *VersionsLinter

NewVersionsLinter creates a new VersionsLinter instance with the provided context.

func NewVersionsLinterWithClient

func NewVersionsLinterWithClient(client actions.Resolver) *VersionsLinter

NewVersionsLinterWithClient creates a new VersionsLinter instance with a custom client. This is useful for testing with a mock client.

func (*VersionsLinter) FixWorkflow

func (l *VersionsLinter) FixWorkflow(wf *workflow.Workflow) error

FixWorkflow fixes issues in a single workflow by replacing version tags with commit hashes.

func (*VersionsLinter) GetCacheStats

func (l *VersionsLinter) GetCacheStats() actions.CacheStats

GetCacheStats returns cache statistics for GitHub API calls.

func (*VersionsLinter) LintWorkflow

func (l *VersionsLinter) LintWorkflow(wf *workflow.Workflow) ([]*Issue, error)

LintWorkflow checks a single workflow for actions using version tags instead of commit hashes.

type WorkflowLinter

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

WorkflowLinter orchestrates multiple individual linters based on configuration.

func New

func New(ctx context.Context, workflowsDir string) *WorkflowLinter

New creates a new WorkflowLinter instance for the specified workflows directory. The directory should contain .yml or .yaml workflow files.

func NewWithWorkflows

func NewWithWorkflows(ctx context.Context, workflows []*workflow.Workflow, configFile string) *WorkflowLinter

NewWithWorkflows creates a new WorkflowLinter instance with the provided workflows. This allows linting specific files or pre-loaded workflows. configFile specifies the path to the configuration file (empty string uses default).

func (*WorkflowLinter) Fix

func (l *WorkflowLinter) Fix() error

Fix runs the Fix method on all enabled linters for all workflows.

func (*WorkflowLinter) GetCacheStats

func (l *WorkflowLinter) GetCacheStats() actions.CacheStats

GetCacheStats returns cache statistics from the versions linter if it's enabled. Returns zero stats if the versions linter is not enabled or not available.

func (*WorkflowLinter) Lint

func (l *WorkflowLinter) Lint() ([]*Issue, error)

Lint runs all enabled linters on all workflows and collects their issues.

Jump to

Keyboard shortcuts

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