v1alpha1

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package v1alpha1 contains the meles.io/v1alpha1 API: MalwareReport, the result of scanning the image of one workload container.

+kubebuilder:object:generate=true +groupName=meles.io

Index

Constants

View Source
const (
	LabelManagedBy      = "app.kubernetes.io/managed-by"
	ManagedByServer     = "meles-server"
	AnnotationCreatedBy = "meles.io/created-by"
)

Ignore objects the meles server creates from its UI carry the label LabelManagedBy=ManagedByServer and the creator in AnnotationCreatedBy. The server deletes only objects with that label; all others belong to whoever applied them (kubectl, Helm, a GitOps tool).

View Source
const (
	StatusClean      = "Clean"
	StatusInfected   = "Infected"
	StatusIncomplete = "Incomplete"
	// StatusError means the image was not scanned (pull or engine error). It
	// must never be read as clean.
	StatusError = "Error"
)

Report statuses. Infected wins over Incomplete: a finding is a finding, even if other files could not be scanned.

View Source
const (
	LabelWorkloadKind = "meles.io/workload-kind"
	LabelWorkloadName = "meles.io/workload-name"
	LabelContainer    = "meles.io/container"
	// LabelDigest holds the first 40 hex characters of the image digest, to
	// find reports of the same image. The full digest is in the report.
	LabelDigest = "meles.io/digest"
)

Labels set on every MalwareReport.

View Source
const (
	SchedulingGateScan = "meles.io/scan"
	LabelGate          = "meles.io/gate"
	LabelGateSkip      = "meles.io/gate-skip"
	AnnotationGate     = "meles.io/gate"
	AnnotationGateMode = "meles.io/gate-mode"
	GateSkipAllowed    = "allowed"
	// GateEnforce holds pods unless every image is Clean.
	GateEnforce = "enforce"
	// GateAudit holds only pods with an Infected image.
	GateAudit = "audit"
	GateSkip  = "skip"
)

Scan gate. With the gate turned on, a mutating webhook adds the scheduling gate SchedulingGateScan to new pods in namespaces labelled LabelGate (GateEnforce or GateAudit) and records the mode in AnnotationGateMode. The operator removes the gate once the pod's images are scanned, pinning them to the scanned digests. A workload opts out with AnnotationGate: GateSkip on its pod template; with the chart's gate protection only in namespaces with LabelGateSkip: GateSkipAllowed.

View Source
const (
	// ErrorSourceEngine is a failure of meles' own infrastructure (clamd
	// unreachable, timeout); the scan gate may release pods despite it.
	ErrorSourceEngine = "Engine"
	// ErrorSourceImage is a failure of the image or its registry.
	ErrorSourceImage = "Image"
)

Sources of an Error.

View Source
const AnnotationRescan = "meles.io/rescan"

AnnotationRescan on a MalwareReport makes the operator rescan its image right away, ignoring cached and copied results. The operator removes it.

Variables

View Source
var (
	// GroupVersion is the API group and version of these types.
	GroupVersion = schema.GroupVersion{Group: "meles.io", Version: "v1alpha1"}

	// SchemeBuilder registers the types with a scheme.
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types of this group version to a scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

This section is empty.

Types

type ClusterMalwareIgnore

type ClusterMalwareIgnore struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   IgnoreSpec   `json:"spec"`
	Status IgnoreStatus `json:"status,omitempty"`
}

ClusterMalwareIgnore holds ignore rules for the MalwareReports of all namespaces, for the cluster's administrators.

+kubebuilder:object:root=true +kubebuilder:subresource:status +kubebuilder:resource:scope=Cluster,shortName=cmwi,categories=meles +kubebuilder:printcolumn:name="Rules",type=integer,JSONPath=`.status.rules` +kubebuilder:printcolumn:name="Problems",type=string,JSONPath=`.status.problems[0]` +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

func (*ClusterMalwareIgnore) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterMalwareIgnore.

func (*ClusterMalwareIgnore) DeepCopyInto

func (in *ClusterMalwareIgnore) DeepCopyInto(out *ClusterMalwareIgnore)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterMalwareIgnore) DeepCopyObject

func (in *ClusterMalwareIgnore) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type ClusterMalwareIgnoreList

type ClusterMalwareIgnoreList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []ClusterMalwareIgnore `json:"items"`
}

ClusterMalwareIgnoreList is a list of ClusterMalwareIgnores.

+kubebuilder:object:root=true

func (*ClusterMalwareIgnoreList) DeepCopy

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterMalwareIgnoreList.

func (*ClusterMalwareIgnoreList) DeepCopyInto

func (in *ClusterMalwareIgnoreList) DeepCopyInto(out *ClusterMalwareIgnoreList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*ClusterMalwareIgnoreList) DeepCopyObject

func (in *ClusterMalwareIgnoreList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type Finding

type Finding struct {
	Platform string `json:"platform"`
	// Layer is the 1-based layer index.
	Layer     int    `json:"layer"`
	DiffID    string `json:"diffID"`
	Path      string `json:"path"`
	Signature string `json:"signature"`
	// Status: present (visible in the final filesystem), deleted (removed by
	// a later layer, but still shipped) or overwritten.
	// +kubebuilder:validation:Enum=present;deleted;overwritten
	Status string `json:"status"`
	// +optional
	HiddenByLayer int `json:"hiddenByLayer,omitempty"`
	// +optional
	CreatedBy string `json:"createdBy,omitempty"`
	// SHA256 of the file content.
	// +optional
	SHA256 string `json:"sha256,omitempty"`
	// Rule describes the YARA rule behind the signature if it is one of
	// meles' default rules. Its author must be named with every match
	// (Detection Rule License).
	// +optional
	Rule *YaraRule `json:"rule,omitempty"`
	// Ignored is set if an ignore rule matched.
	// +optional
	Ignored *IgnoreMatch `json:"ignored,omitempty"`
}

Finding is a file the engine flagged.

func (*Finding) DeepCopy

func (in *Finding) DeepCopy() *Finding

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Finding.

func (*Finding) DeepCopyInto

func (in *Finding) DeepCopyInto(out *Finding)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IgnoreMatch

type IgnoreMatch struct {
	// Rule is "<namespace>/<MalwareIgnore>#<n>" or "<ClusterMalwareIgnore>#<n>",
	// or the rule's name.
	Rule    string `json:"rule"`
	Reason  string `json:"reason"`
	Expires string `json:"expires"`
	// Expired: the rule matched but its date has passed; the entry counts.
	// +optional
	Expired bool `json:"expired,omitempty"`
}

IgnoreMatch tells which ignore rule matched an entry.

func (*IgnoreMatch) DeepCopy

func (in *IgnoreMatch) DeepCopy() *IgnoreMatch

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IgnoreMatch.

func (*IgnoreMatch) DeepCopyInto

func (in *IgnoreMatch) DeepCopyInto(out *IgnoreMatch)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IgnoreRule

type IgnoreRule struct {
	// Name of the rule in reports; empty: "<object>#<position>".
	// +optional
	Name string `json:"name,omitempty"`
	// Path of the file in the image, a glob: * and ? within a path segment,
	// ** across segments.
	// +optional
	Path string `json:"path,omitempty"`
	// Signature of the finding or skipped file, a glob, e.g.
	// "Heuristics.Limits.Exceeded.MaxRecursion".
	// +optional
	Signature string `json:"signature,omitempty"`
	// Image: a repository glob such as "docker.io/library/nextcloud", or an
	// image digest "sha256:…". Empty: every image.
	// +optional
	Image string `json:"image,omitempty"`
	// SHA256 of the file content: the rule names exactly this file.
	// +optional
	SHA256 string `json:"sha256,omitempty"`
	// Reason why the entry is harmless.
	// +kubebuilder:validation:MinLength=1
	Reason string `json:"reason"`
	// Expires is the last day the rule applies, at most a year ahead.
	// +kubebuilder:validation:Pattern=`^[0-9]{4}-[0-9]{2}-[0-9]{2}$`
	Expires string `json:"expires"`
}

IgnoreRule ignores the findings and skipped files that match all of its set fields; at least one of path, signature and sha256 is required. Ignored entries stay in the MalwareReport, marked with the rule; they only no longer count for its status.

func (*IgnoreRule) DeepCopy

func (in *IgnoreRule) DeepCopy() *IgnoreRule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IgnoreRule.

func (*IgnoreRule) DeepCopyInto

func (in *IgnoreRule) DeepCopyInto(out *IgnoreRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IgnoreSpec

type IgnoreSpec struct {
	// +kubebuilder:validation:MaxItems=200
	Rules []IgnoreRule `json:"rules"`
}

IgnoreSpec holds ignore rules.

func (*IgnoreSpec) DeepCopy

func (in *IgnoreSpec) DeepCopy() *IgnoreSpec

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IgnoreSpec.

func (*IgnoreSpec) DeepCopyInto

func (in *IgnoreSpec) DeepCopyInto(out *IgnoreSpec)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type IgnoreStatus

type IgnoreStatus struct {
	// Rules is the number of valid rules in effect.
	// +optional
	Rules int `json:"rules"`
	// Problems lists rules that are not in effect and why.
	// +optional
	Problems []string `json:"problems,omitempty"`
}

IgnoreStatus is written by the meles operator.

func (*IgnoreStatus) DeepCopy

func (in *IgnoreStatus) DeepCopy() *IgnoreStatus

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IgnoreStatus.

func (*IgnoreStatus) DeepCopyInto

func (in *IgnoreStatus) DeepCopyInto(out *IgnoreStatus)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Image

type Image struct {
	// Repository, e.g. "docker.io/library/nginx".
	Repository string `json:"repository"`
	// Tag or reference from the pod spec, e.g. "nginx:1.29".
	// +optional
	Reference string `json:"reference,omitempty"`
	// Digest that was running and scanned, e.g. "sha256:3f1a…". For a
	// multi-arch image this is the digest of the index.
	Digest string `json:"digest"`
}

Image is the scanned image.

func (*Image) DeepCopy

func (in *Image) DeepCopy() *Image

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Image.

func (*Image) DeepCopyInto

func (in *Image) DeepCopyInto(out *Image)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type MalwareIgnore

type MalwareIgnore struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   IgnoreSpec   `json:"spec"`
	Status IgnoreStatus `json:"status,omitempty"`
}

MalwareIgnore holds ignore rules for the MalwareReports in its namespace, for the teams that own the workloads there.

+kubebuilder:object:root=true +kubebuilder:subresource:status +kubebuilder:resource:shortName=mwi,categories=meles +kubebuilder:printcolumn:name="Rules",type=integer,JSONPath=`.status.rules` +kubebuilder:printcolumn:name="Problems",type=string,JSONPath=`.status.problems[0]` +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

func (*MalwareIgnore) DeepCopy

func (in *MalwareIgnore) DeepCopy() *MalwareIgnore

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MalwareIgnore.

func (*MalwareIgnore) DeepCopyInto

func (in *MalwareIgnore) DeepCopyInto(out *MalwareIgnore)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MalwareIgnore) DeepCopyObject

func (in *MalwareIgnore) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type MalwareIgnoreList

type MalwareIgnoreList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MalwareIgnore `json:"items"`
}

MalwareIgnoreList is a list of MalwareIgnores.

+kubebuilder:object:root=true

func (*MalwareIgnoreList) DeepCopy

func (in *MalwareIgnoreList) DeepCopy() *MalwareIgnoreList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MalwareIgnoreList.

func (*MalwareIgnoreList) DeepCopyInto

func (in *MalwareIgnoreList) DeepCopyInto(out *MalwareIgnoreList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MalwareIgnoreList) DeepCopyObject

func (in *MalwareIgnoreList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type MalwareReport

type MalwareReport struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	// Status is the result. It is a subresource, so that only the
	// operator, which may update malwarereports/status, can write it: the
	// scan gate trusts it, and the server's patch permission (rescan
	// annotation) or a manifest applied by GitOps cannot change it. Empty
	// until the first result is written.
	// +optional
	Status ReportData `json:"status,omitempty"`
}

MalwareReport is the malware scan result of the image of one container of a workload. The meles operator writes it; it is owned by the workload and deleted with it.

+kubebuilder:object:root=true +kubebuilder:resource:shortName=mwr,categories=meles +kubebuilder:subresource:status +kubebuilder:printcolumn:name="Workload",type=string,JSONPath=`.status.workload.kind` +kubebuilder:printcolumn:name="Name",type=string,JSONPath=`.status.workload.name`,priority=1 +kubebuilder:printcolumn:name="Container",type=string,JSONPath=`.status.workload.container` +kubebuilder:printcolumn:name="Image",type=string,JSONPath=`.status.image.repository` +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.summary.status` +kubebuilder:printcolumn:name="Findings",type=integer,JSONPath=`.status.summary.findings` +kubebuilder:printcolumn:name="Ignored",type=integer,JSONPath=`.status.summary.ignored`,priority=1 +kubebuilder:printcolumn:name="Age",type=date,JSONPath=`.metadata.creationTimestamp`

func (*MalwareReport) DeepCopy

func (in *MalwareReport) DeepCopy() *MalwareReport

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MalwareReport.

func (*MalwareReport) DeepCopyInto

func (in *MalwareReport) DeepCopyInto(out *MalwareReport)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MalwareReport) DeepCopyObject

func (in *MalwareReport) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

func (*MalwareReport) Pending added in v0.2.0

func (r *MalwareReport) Pending() bool

Pending reports whether the operator has not written a result yet: right after the report was created, or after an upgrade from a version that kept the result outside the status.

type MalwareReportList

type MalwareReportList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []MalwareReport `json:"items"`
}

MalwareReportList is a list of MalwareReports.

+kubebuilder:object:root=true

func (*MalwareReportList) DeepCopy

func (in *MalwareReportList) DeepCopy() *MalwareReportList

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MalwareReportList.

func (*MalwareReportList) DeepCopyInto

func (in *MalwareReportList) DeepCopyInto(out *MalwareReportList)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

func (*MalwareReportList) DeepCopyObject

func (in *MalwareReportList) DeepCopyObject() runtime.Object

DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.

type ReportData

type ReportData struct {
	Workload Workload `json:"workload"`
	Image    Image    `json:"image"`
	Scanner  Scanner  `json:"scanner"`
	// Platforms that were scanned, e.g. ["linux/amd64"].
	// +optional
	Platforms []string `json:"platforms,omitempty"`
	// PlatformFilter the image was scanned with: "all" or a list such as
	// "linux/amd64,linux/arm64" (the node architectures).
	// +optional
	PlatformFilter string  `json:"platformFilter,omitempty"`
	Summary        Summary `json:"summary"`
	// Findings, at most the first 100. Summary.Findings has the total.
	// +optional
	Findings []Finding `json:"findings,omitempty"`
	// Files that were not scanned, at most the first 100.
	// Summary.Skipped has the total.
	// +optional
	Skipped []Skipped `json:"skipped,omitempty"`
	// Error is set if Summary.Status is Error.
	// +optional
	Error string `json:"error,omitempty"`
	// ErrorSource is Engine or Image if Summary.Status is Error.
	// +optional
	ErrorSource string `json:"errorSource,omitempty"`
	// ScannedAt is when the scan finished (or failed).
	ScannedAt metav1.Time `json:"scannedAt"`
}

ReportData is the content of a MalwareReport.

func (*ReportData) DeepCopy

func (in *ReportData) DeepCopy() *ReportData

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReportData.

func (*ReportData) DeepCopyInto

func (in *ReportData) DeepCopyInto(out *ReportData)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Scanner

type Scanner struct {
	Version string `json:"version"`
	// Engine, e.g. "ClamAV 1.4.6".
	Engine string `json:"engine"`
	// Signatures is the version of the signature database.
	Signatures string `json:"signatures"`
}

Scanner identifies meles and the engine with its signature version.

func (*Scanner) DeepCopy

func (in *Scanner) DeepCopy() *Scanner

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Scanner.

func (*Scanner) DeepCopyInto

func (in *Scanner) DeepCopyInto(out *Scanner)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Skipped

type Skipped struct {
	Platform string `json:"platform"`
	Layer    int    `json:"layer"`
	Path     string `json:"path"`
	Size     int64  `json:"size"`
	Reason   string `json:"reason"`
	// Signature names the reason, e.g.
	// Heuristics.Limits.Exceeded.MaxRecursion or meles.Limits.MaxFileSize.
	// +optional
	Signature string `json:"signature,omitempty"`
	// SHA256 of the file content.
	// +optional
	SHA256 string `json:"sha256,omitempty"`
	// Ignored is set if an ignore rule matched.
	// +optional
	Ignored *IgnoreMatch `json:"ignored,omitempty"`
}

Skipped is a file that was not scanned.

func (*Skipped) DeepCopy

func (in *Skipped) DeepCopy() *Skipped

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Skipped.

func (*Skipped) DeepCopyInto

func (in *Skipped) DeepCopyInto(out *Skipped)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Summary

type Summary struct {
	// +kubebuilder:validation:Enum=Clean;Infected;Incomplete;Error
	Status   string `json:"status"`
	Findings int    `json:"findings"`
	Skipped  int    `json:"skipped"`
	Files    int    `json:"files"`
	// Ignored is the number of findings and skipped files ignore rules took
	// out of the verdict.
	// +optional
	Ignored int `json:"ignored,omitempty"`
	// IgnoredFindings and IgnoredSkipped split Ignored.
	// +optional
	IgnoredFindings int `json:"ignoredFindings,omitempty"`
	// +optional
	IgnoredSkipped int `json:"ignoredSkipped,omitempty"`
}

Summary counts the results. Findings and Skipped count only entries that no ignore rule ignores; Status follows from them.

func (*Summary) DeepCopy

func (in *Summary) DeepCopy() *Summary

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Summary.

func (*Summary) DeepCopyInto

func (in *Summary) DeepCopyInto(out *Summary)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type Workload

type Workload struct {
	// Kind of the workload: ReplicaSet, StatefulSet, DaemonSet, CronJob,
	// Job or Pod.
	Kind string `json:"kind"`
	Name string `json:"name"`
	// Parent is the Deployment of a ReplicaSet, derived from the names
	// (ReplicaSet = Deployment + "-" + pod-template-hash). It stays the same
	// across rollouts, while the ReplicaSet changes.
	// +optional
	Parent    string `json:"parent,omitempty"`
	Container string `json:"container"`
	// InitContainer is true for init containers.
	// +optional
	InitContainer bool `json:"initContainer,omitempty"`
}

Workload identifies the container the report is about.

func (*Workload) DeepCopy

func (in *Workload) DeepCopy() *Workload

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Workload.

func (*Workload) DeepCopyInto

func (in *Workload) DeepCopyInto(out *Workload)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

type YaraRule

type YaraRule struct {
	Name    string `json:"name"`
	Author  string `json:"author"`
	License string `json:"license"`
	// URL of the original rule.
	// +optional
	URL string `json:"url,omitempty"`
}

YaraRule names a YARA rule, its author and license.

func (*YaraRule) DeepCopy

func (in *YaraRule) DeepCopy() *YaraRule

DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new YaraRule.

func (*YaraRule) DeepCopyInto

func (in *YaraRule) DeepCopyInto(out *YaraRule)

DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.

Jump to

Keyboard shortcuts

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