Documentation
¶
Overview ¶
Package fileval provides pre-parse file validation checks for tally.
These checks run before BuildKit parsing to fail fast on files that clearly aren't valid Dockerfiles: binary files, oversized files, and executable files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LooksUTF8 ¶
LooksUTF8 checks whether the file at path appears to contain valid UTF-8 text. It opens the file and delegates to LooksUTF8FromReader.
func LooksUTF8FromReader ¶
LooksUTF8FromReader checks whether r appears to contain valid UTF-8 text. It reads in 32 KB chunks, carrying up to 3 trailing bytes between reads to handle code points split across chunk boundaries. It stops after maxBytes (a heuristic "looks like UTF-8" threshold) and fails fast on the first definitely-invalid chunk. Pass maxBytes <= 0 to read until EOF.
func ValidateFile ¶
ValidateFile runs pre-parse validation checks on a file:
- Minimum size check (must be at least "FROM a")
- Maximum size check (when maxSize > 0)
- Executable-bit check (Unix only)
- UTF-8 smoke check
The file is opened once; all checks — including the UTF-8 read — operate on the same file handle to avoid TOCTOU races between os.Stat and a second open.
Types ¶
type ExecutableFileError ¶
type ExecutableFileError struct {
Path string
}
ExecutableFileError is returned when a Dockerfile has the executable bit set.
func (*ExecutableFileError) Error ¶
func (e *ExecutableFileError) Error() string
type FileTooLargeError ¶
FileTooLargeError is returned when a file exceeds the configured maximum size.
func (*FileTooLargeError) Error ¶
func (e *FileTooLargeError) Error() string
type FileTooSmallError ¶
FileTooSmallError is returned when a file is too small to be a valid Dockerfile.
func (*FileTooSmallError) Error ¶
func (e *FileTooSmallError) Error() string
type NotUTF8Error ¶
type NotUTF8Error struct {
Path string
}
NotUTF8Error is returned when a file does not appear to be valid UTF-8 text.
func (*NotUTF8Error) Error ¶
func (e *NotUTF8Error) Error() string