Documentation
¶
Overview ¶
Package server is the meles web UI and JSON API: configured scans with schedules, scan runs with their results, reports, and the MalwareReports of the meles operator.
Index ¶
- type ClusterIgnores
- type ClusterReports
- type Config
- type EngineStatus
- type IgnoreObject
- type KubeIgnores
- func (i *KubeIgnores) ClusterRules(ctx context.Context) (*ignore.Rules, error)
- func (i *KubeIgnores) Create(ctx context.Context, namespace string, rule v1alpha1.IgnoreRule, ...) (string, error)
- func (i *KubeIgnores) Delete(ctx context.Context, namespace, name string) error
- func (i *KubeIgnores) List(ctx context.Context) ([]IgnoreObject, error)
- type KubeReports
- func (k *KubeReports) Get(ctx context.Context, namespace, name string) (*v1alpha1.MalwareReport, error)
- func (k *KubeReports) Ignores() *KubeIgnores
- func (k *KubeReports) List(ctx context.Context) ([]v1alpha1.MalwareReport, error)
- func (k *KubeReports) OnChange(ctx context.Context, fn func(rep *v1alpha1.MalwareReport, deleted bool)) error
- func (k *KubeReports) RequestRescan(ctx context.Context, namespace, name string) error
- func (k *KubeReports) Start(ctx context.Context) error
- func (k *KubeReports) WaitSynced(ctx context.Context) bool
- type OperatorStatus
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClusterIgnores ¶
type ClusterIgnores interface {
// List returns all ignore objects, ClusterMalwareIgnores first.
List(ctx context.Context) ([]IgnoreObject, error)
// Create creates a ClusterMalwareIgnore (empty namespace) or a
// MalwareIgnore with one rule and returns its name.
Create(ctx context.Context, namespace string, rule v1alpha1.IgnoreRule, createdBy string) (string, error)
// Delete deletes an object the server created: store.ErrNotFound
// (wrapped) for a missing one, errNotManaged for any other.
Delete(ctx context.Context, namespace, name string) error
}
ClusterIgnores manages MalwareIgnores and ClusterMalwareIgnores from the UI. Every rule created there is an object of its own, labelled as the server's; only those can be deleted from the UI.
type ClusterReports ¶
type ClusterReports interface {
List(ctx context.Context) ([]v1alpha1.MalwareReport, error)
// Get returns store.ErrNotFound (wrapped) for a missing report.
Get(ctx context.Context, namespace, name string) (*v1alpha1.MalwareReport, error)
// RequestRescan sets the meles.io/rescan annotation.
RequestRescan(ctx context.Context, namespace, name string) error
}
ClusterReports gives the server the MalwareReports the operator writes.
type Config ¶
type Config struct {
Store *store.Store
Runner *runner.Runner
Scheduler *schedule.Scheduler
Engine engine.Engine
Cache *scan.Cache
Location *time.Location
Logger *slog.Logger
Version string
// Cluster, if set, shows the operator's MalwareReports.
Cluster ClusterReports
// ClusterRescan allows requesting a rescan from the UI.
ClusterRescan bool
// Ignores, if set, allows creating ignore rules from the UI.
Ignores ClusterIgnores
// ClusterName tags the history of the cluster's reports, for several
// clusters later; empty for one.
ClusterName string
// Operator, if set, shows what the operator does on the Cluster page.
Operator OperatorStatus
}
Config configures a Server.
type EngineStatus ¶
EngineStatus is the last result of the engine health check.
type IgnoreObject ¶
type IgnoreObject struct {
Namespace string
Name string
Labels map[string]string
Annotations map[string]string
Created time.Time
Spec v1alpha1.IgnoreSpec
Status v1alpha1.IgnoreStatus
}
IgnoreObject is a MalwareIgnore (Namespace set) or ClusterMalwareIgnore.
func (IgnoreObject) CreatedBy ¶
func (o IgnoreObject) CreatedBy() string
CreatedBy is the user who created the object in the UI.
func (IgnoreObject) Managed ¶
func (o IgnoreObject) Managed() bool
Managed reports whether the server created the object.
func (IgnoreObject) Origin ¶
func (o IgnoreObject) Origin() string
Origin tells where an object comes from, as far as its metadata shows: "UI", or the tool that applied it. Objects applied with kubectl carry no mark, so "kubectl or Git" is a guess.
func (IgnoreObject) Source ¶
func (o IgnoreObject) Source() string
Source is the name rules of the object carry in reports.
type KubeIgnores ¶
type KubeIgnores struct {
// contains filtered or unexported fields
}
KubeIgnores implements ClusterIgnores on the cache of KubeReports.
func (*KubeIgnores) ClusterRules ¶
ClusterRules returns the valid rules of all ClusterMalwareIgnores, for the server's own runs: they belong to no namespace.
func (*KubeIgnores) Create ¶
func (i *KubeIgnores) Create(ctx context.Context, namespace string, rule v1alpha1.IgnoreRule, createdBy string) (string, error)
func (*KubeIgnores) Delete ¶
func (i *KubeIgnores) Delete(ctx context.Context, namespace, name string) error
func (*KubeIgnores) List ¶
func (i *KubeIgnores) List(ctx context.Context) ([]IgnoreObject, error)
type KubeReports ¶
type KubeReports struct {
// contains filtered or unexported fields
}
KubeReports reads MalwareReports from the Kubernetes API through an informer cache.
func NewKubeReports ¶
func NewKubeReports(cfg *rest.Config, ignores bool) (*KubeReports, error)
NewKubeReports creates the cache; Start fills it. With ignores it also caches MalwareIgnores and ClusterMalwareIgnores for Ignores.
func (*KubeReports) Get ¶
func (k *KubeReports) Get(ctx context.Context, namespace, name string) (*v1alpha1.MalwareReport, error)
func (*KubeReports) Ignores ¶
func (k *KubeReports) Ignores() *KubeIgnores
Ignores returns the ignore objects, nil unless created with ignores.
func (*KubeReports) List ¶
func (k *KubeReports) List(ctx context.Context) ([]v1alpha1.MalwareReport, error)
func (*KubeReports) OnChange ¶
func (k *KubeReports) OnChange(ctx context.Context, fn func(rep *v1alpha1.MalwareReport, deleted bool)) error
OnChange calls fn for every report added, changed or deleted, including all existing reports once the cache starts.
func (*KubeReports) RequestRescan ¶
func (k *KubeReports) RequestRescan(ctx context.Context, namespace, name string) error
func (*KubeReports) Start ¶
func (k *KubeReports) Start(ctx context.Context) error
Start runs the cache until ctx is canceled.
func (*KubeReports) WaitSynced ¶
func (k *KubeReports) WaitSynced(ctx context.Context) bool
WaitSynced blocks until the reports were read once, or ctx is canceled.
type OperatorStatus ¶
OperatorStatus fetches the status of the meles operator; *opstatus.Client implements it.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server serves the UI and API.
func (*Server) Engine ¶
func (s *Server) Engine() EngineStatus
Engine returns the last engine health check.
func (*Server) RunClusterHistory ¶
RunClusterHistory records every change of the cluster's reports in the database until ctx is canceled: new results and deletions, including those missed while the server was down. Events older than keep are deleted daily, except the last one of each report.