dockerfile

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package dockerfile implements static analysis and linting of Dockerfiles. It is the first capability module (CAPABILITY_SPEC domain 3). The parser is intentionally small: it splits a Dockerfile into logical instructions, honoring comments and backslash line-continuations, and records line spans so findings can point at exact locations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dockerfile

type Dockerfile struct {
	Instructions []Instruction
	Lines        []string
}

Dockerfile is a parsed Dockerfile.

func Parse

func Parse(content string) *Dockerfile

Parse turns Dockerfile text into a Dockerfile. It never errors; malformed input simply yields whatever instructions could be recognized.

func (*Dockerfile) From

func (d *Dockerfile) From() []Instruction

From returns all FROM instructions.

func (*Dockerfile) Has

func (d *Dockerfile) Has(cmd string) bool

Has reports whether any instruction with the given command exists.

type Instruction

type Instruction struct {
	Cmd       string // upper-cased command, e.g. "FROM", "RUN"
	Args      string // everything after the command, continuations joined
	StartLine int    // 1-based first physical line
	EndLine   int    // 1-based last physical line
	Raw       string // normalized "CMD args" text
}

Instruction is one logical Dockerfile instruction (a command plus its arguments), possibly spanning multiple physical lines.

type Module

type Module struct{}

Module is the Dockerfile static-analysis capability.

func New

func New() *Module

New returns a Dockerfile module.

func (*Module) Analyze

func (m *Module) Analyze(_ context.Context, t *engine.Target) ([]engine.Finding, error)

Analyze parses the Dockerfile and runs every rule against it.

func (*Module) Description

func (m *Module) Description() string

func (*Module) Domains

func (m *Module) Domains() []string

func (*Module) Name

func (m *Module) Name() string

func (*Module) Supports

func (m *Module) Supports(t engine.TargetType) bool

Jump to

Keyboard shortcuts

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