selftest

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package selftest checks the whole scan chain: it serves images with EICAR test files from an in-memory registry and compares what the scanner finds with what it must find. The CLI runs it on request, the server regularly.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	Name string
	Got  []string
	Want []string
}

Check is the result of one test image.

func (Check) Pass

func (c Check) Pass() bool

Pass reports whether the scanner found exactly what it must find.

func (Check) String

func (c Check) String() string

String describes the check for logs and the UI.

type Result

type Result struct {
	// Engine is the raw version of the engine.
	Engine string
	Checks []Check
}

Result is the outcome of a selftest.

func Run

func Run(ctx context.Context, s *scan.Scanner, yara bool) (*Result, error)

Run scans the test images with s; yara adds the images for the default YARA rules, which the engine must have loaded then. After an error the result holds the checks done so far.

It works on a copy of s without the layer cache, which would answer from the last run without asking the engine, and without the restrictions for registries: the test images come from a plain HTTP registry on loopback.

func (*Result) Failed

func (r *Result) Failed() []Check

Failed returns the checks that did not pass.

Jump to

Keyboard shortcuts

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