testimage

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package testimage builds images with EICAR test files at runtime and serves them from an in-memory registry. It backs the tests and `meles selftest`, which checks the whole chain (registry pull, layer extraction, engine) without an EICAR image in any real registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(layers []Layer) (v1.Image, error)

Build creates a linux/amd64 image from layers.

func BuildPlatform

func BuildPlatform(layers []Layer, p v1.Platform) (v1.Image, error)

BuildPlatform creates an image for platform p from layers.

func EICAR

func EICAR() string

EICAR returns the EICAR test string. It is assembled at runtime so that source files and binaries do not trigger virus scanners themselves.

Types

type Case

type Case struct {
	Name   string
	Layers []Layer
	// Want lists the expected findings as "path status", e.g.
	// "/opt/eicar.com present". Empty means clean.
	Want []string
}

Case is a test image and the result meles must report for it.

func Cases

func Cases() []Case

Cases returns the standard test images.

func YaraCases

func YaraCases() []Case

YaraCases returns test images for the default YARA rules (charts/meles/rules); clamd must have loaded them. The file is a harmless XMRig configuration that SIGNATURE_BASE_XMRIG_Monero_Miner_Config matches.

type Layer

type Layer struct {
	CreatedBy string
	Files     map[string]string
}

Layer is one layer of a test image.

type Registry

type Registry struct {
	Host string
	// contains filtered or unexported fields
}

Registry is an in-memory registry with the test images.

func Serve

func Serve(cases []Case) (*Registry, error)

Serve starts an in-memory registry and pushes the given cases to it. References must be parsed with name.Insecure (plain HTTP).

func (*Registry) Close

func (r *Registry) Close()

Close stops the registry.

func (*Registry) Push

func (r *Registry) Push(name string, img remote.Taggable) error

Push stores an image or index under the given name.

func (*Registry) Ref

func (r *Registry) Ref(name string) string

Ref returns the reference of a test image in the registry.

func (*Registry) RequireAuth

func (r *Registry) RequireAuth(user, password string)

RequireAuth makes the registry refuse requests without these basic auth credentials, like a private registry. Push before calling it.

Jump to

Keyboard shortcuts

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