Documentation
¶
Overview ¶
Package profile holds profile related files
Package profile holds profile related files ¶
Package profile holds profile related files ¶
Package profile holds profile related files ¶
Package profile holds profile related files ¶
Package profile holds profile related files ¶
Package profile holds profile related files
Index ¶
- Constants
- Variables
- func LoadProtoFromFile(filepath string) (*adprotov1.SecurityProfile, error)
- type ActivityDumpHeader
- type EventTypeState
- type Opts
- func WithDNSMatchMaxDepth(dnsMatchMaxDepth int) Opts
- func WithDifferentiateArgs(differentiateArgs bool) Opts
- func WithEventTypes(eventTypes []model.EventType) Opts
- func WithPathsReducer(pathsReducer *activity_tree.PathsReducer) Opts
- func WithWorkloadSelector(selector cgroupModel.WorkloadSelector) Opts
- type Profile
- func (p *Profile) AddSnapshotAncestors(ancestors []*model.ProcessCacheEntry, resolvers *resolvers.EBPFResolvers, ...)
- func (p *Profile) AddTags(tags []string)
- func (p *Profile) AddVersionContext(version string, ctx *VersionContext)
- func (p *Profile) ComputeInMemorySize() int64
- func (p *Profile) ComputeSyscallsList() []uint32
- func (p *Profile) Contains(event *model.Event, insertMissingProcesses bool, imageTag string, ...) (bool, error)
- func (p *Profile) Decode(inputFile string) error
- func (p *Profile) DecodeFromReader(reader io.Reader, format config.StorageFormat) error
- func (p *Profile) DecodeJSON(reader io.Reader) error
- func (p *Profile) DecodeSecDumpProtobuf(reader io.Reader) error
- func (p *Profile) DecodeSecurityProfileProtobuf(reader io.Reader) error
- func (p *Profile) Encode(format config.StorageFormat) (*bytes.Buffer, error)
- func (p *Profile) EncodeDOT() (*bytes.Buffer, error)
- func (p *Profile) EncodeJSON(indent string) (*bytes.Buffer, error)
- func (p *Profile) EncodeSecDumpProtobuf() (*bytes.Buffer, error)
- func (p *Profile) EncodeSecurityProfileProtobuf() (*bytes.Buffer, error)
- func (p *Profile) FakeOverweight()
- func (p *Profile) GenerateSyscallsFilters() [64]byte
- func (p *Profile) GetEventTypes() []model.EventType
- func (p *Profile) GetGlobalEventTypeState(et model.EventType) model.EventFilteringProfileState
- func (p *Profile) GetImageNameTag() (string, string)
- func (p *Profile) GetProfileCookie() uint64
- func (p *Profile) GetSelectorStr() string
- func (p *Profile) GetTagValue(tagName string) string
- func (p *Profile) GetTags() []string
- func (p *Profile) GetVersionContext(imageTag string) (*VersionContext, bool)
- func (p *Profile) GetVersionContextIndex(index int) *VersionContext
- func (p *Profile) GetVersions() []string
- func (p *Profile) GetWorkloadSelector() *cgroupModel.WorkloadSelector
- func (p *Profile) HasAlreadyBeenSent() bool
- func (p *Profile) HasTag(tag string) bool
- func (p *Profile) Insert(event *model.Event, insertMissingProcesses bool, imageTag string, ...) (bool, error)
- func (p *Profile) InsertAndGetSize(event *model.Event, insertMissingProcesses bool, imageTag string, ...) (bool, int64, error)
- func (p *Profile) IsEmpty() bool
- func (p *Profile) IsEventTypeValid(evtType model.EventType) bool
- func (p *Profile) ListAllVersionStates()
- func (p *Profile) LoadFromNewProfile(newProfile *Profile)
- func (p *Profile) MatchesSelector(entry *model.ProcessCacheEntry) bool
- func (p *Profile) NewProcessNodeCallback(_ *activity_tree.ProcessNode)
- func (p *Profile) PrepareNewVersion(newImageTag string, tags []string, maxImageTags int, nowTimestamp uint64) []string
- func (p *Profile) Reset()
- func (p *Profile) ScrubProcessArgsEnvs(resolver *process.EBPFResolver)
- func (p *Profile) SendStats(statsdClient statsd.ClientInterface) error
- func (p *Profile) SetHasAlreadyBeenSent()
- func (p *Profile) SetTreeType(validator activity_tree.Owner, treeType string)
- func (p *Profile) SetVersionState(imageTag string, state model.EventFilteringProfileState, ...) error
- func (p *Profile) Snapshot(newEvent func() *model.Event)
- func (p *Profile) ToGraph() utils.Graph
- func (p *Profile) ToSecurityActivityDumpMessage(timeout time.Duration, ...) *api.ActivityDumpMessage
- func (p *Profile) ToSecurityProfileMessage(timeResolver *ktime.Resolver) *api.SecurityProfileMessage
- type VersionContext
Constants ¶
const (
// ProtobufVersion defines the protobuf version in use
ProtobufVersion = "v1"
)
Variables ¶
var ActivityDumpGraphTemplate = `` /* 1328-byte string literal not displayed */
ActivityDumpGraphTemplate is the template used to generate graphs
Functions ¶
func LoadProtoFromFile ¶
func LoadProtoFromFile(filepath string) (*adprotov1.SecurityProfile, error)
LoadProtoFromFile loads proto profile from file
Types ¶
type ActivityDumpHeader ¶
type ActivityDumpHeader struct {
// standard attributes used by the intake
Host string `json:"host,omitempty"`
Service string `json:"service,omitempty"`
Source string `json:"ddsource,omitempty"`
DDTags string `json:"ddtags,omitempty"`
// Used to store the global list of DNS names contained in this dump
// this is a hack used to provide this global list to the backend in the JSON header
// instead of in the protobuf payload.
DNSNames *utils.StringKeys `json:"dns_names"`
}
ActivityDumpHeader holds the header of an activity dump
type EventTypeState ¶
type EventTypeState struct {
LastAnomalyNano uint64
State model.EventFilteringProfileState
}
EventTypeState defines an event type state
type Opts ¶
type Opts func(*Profile)
Opts defines the options to create a new profile
func WithDNSMatchMaxDepth ¶
WithDNSMatchMaxDepth sets the maximum depth used to compare domain names in the new profile
func WithDifferentiateArgs ¶
WithDifferentiateArgs sets whether arguments should be used to differentiate processes in the new profile
func WithEventTypes ¶
WithEventTypes sets the event types of a new profile
func WithPathsReducer ¶
func WithPathsReducer(pathsReducer *activity_tree.PathsReducer) Opts
WithPathsReducer sets the path reducer of a new profile
func WithWorkloadSelector ¶
func WithWorkloadSelector(selector cgroupModel.WorkloadSelector) Opts
WithWorkloadSelector sets the workload selector of a new profile
type Profile ¶
type Profile struct {
// common to ActivityDump and SecurityProfile
sync.Mutex
ActivityTree *activity_tree.ActivityTree
Header ActivityDumpHeader
Metadata mtdt.Metadata
LoadedInKernel *atomic.Bool
LoadedNano *atomic.Uint64
// Instances is the list of workload instances to witch the profile should apply
InstancesLock sync.Mutex
Instances []*tags.Workload
// contains filtered or unexported fields
}
Profile represents a security profile
func NewProfileFromActivityDumpMessage ¶
func NewProfileFromActivityDumpMessage(msg *api.ActivityDumpMessage) (*Profile, map[config.StorageFormat][]config.StorageRequest, error)
NewProfileFromActivityDumpMessage returns a new Profile from a ActivityDumpMessage.
func (*Profile) AddSnapshotAncestors ¶
func (p *Profile) AddSnapshotAncestors(ancestors []*model.ProcessCacheEntry, resolvers *resolvers.EBPFResolvers, callback func(*model.ProcessCacheEntry))
AddSnapshotAncestors adds the given process branch to the profile, calling the callback for each process cache entry which resulted in a new node insertion
func (*Profile) AddVersionContext ¶
func (p *Profile) AddVersionContext(version string, ctx *VersionContext)
AddVersionContext adds a new version context to the profile
func (*Profile) ComputeInMemorySize ¶
ComputeInMemorySize returns the size of a dump in memory
func (*Profile) ComputeSyscallsList ¶
ComputeSyscallsList computes the top level list of syscalls
func (*Profile) Contains ¶
func (p *Profile) Contains(event *model.Event, insertMissingProcesses bool, imageTag string, generationType activity_tree.NodeGenerationType, resolvers *resolvers.EBPFResolvers) (bool, error)
Contains checks if the profile contains the given event
func (*Profile) DecodeFromReader ¶
DecodeFromReader decodes an activity dump from a reader with the provided format
func (*Profile) DecodeJSON ¶
DecodeJSON decodes JSON to an activity dump
func (*Profile) DecodeSecDumpProtobuf ¶
DecodeSecDumpProtobuf decodes a SecDump binary representation
func (*Profile) DecodeSecurityProfileProtobuf ¶
DecodeSecurityProfileProtobuf decodes a SecurityProfile binary representation
func (*Profile) EncodeJSON ¶
EncodeJSON encodes an activity dump in the ProtoJSON format
func (*Profile) EncodeSecDumpProtobuf ¶
EncodeSecDumpProtobuf encodes a Profile to its SecDump protobuf binary representation
func (*Profile) EncodeSecurityProfileProtobuf ¶
EncodeSecurityProfileProtobuf encodes a Profile to its SecurityProfile protobuf binary representation
func (*Profile) FakeOverweight ¶
func (p *Profile) FakeOverweight()
FakeOverweight fakes an overweight profile
func (*Profile) GenerateSyscallsFilters ¶
GenerateSyscallsFilters generates the syscall filters for the profile
func (*Profile) GetEventTypes ¶
GetEventTypes returns the event types of the profile
func (*Profile) GetGlobalEventTypeState ¶
func (p *Profile) GetGlobalEventTypeState(et model.EventType) model.EventFilteringProfileState
GetGlobalEventTypeState returns the global state of a profile for a given event type: AutoLearning, StableEventType or UnstableEventType
func (*Profile) GetImageNameTag ¶
GetImageNameTag returns the image name and tag for the profiled container
func (*Profile) GetProfileCookie ¶
GetProfileCookie returns the profile cookie
func (*Profile) GetSelectorStr ¶
GetSelectorStr returns the string representation of the profile selector
func (*Profile) GetTagValue ¶
GetTagValue returns the value of the given tag name
func (*Profile) GetVersionContext ¶
func (p *Profile) GetVersionContext(imageTag string) (*VersionContext, bool)
GetVersionContext returns the context of the given version if any
func (*Profile) GetVersionContextIndex ¶
func (p *Profile) GetVersionContextIndex(index int) *VersionContext
GetVersionContextIndex returns the context of the given version if any
func (*Profile) GetVersions ¶
GetVersions returns the number of versions stored in the profile (debug purpose only)
func (*Profile) GetWorkloadSelector ¶
func (p *Profile) GetWorkloadSelector() *cgroupModel.WorkloadSelector
GetWorkloadSelector returns the workload selector
func (*Profile) HasAlreadyBeenSent ¶
HasAlreadyBeenSent returns true if the profile has already been sent
func (*Profile) Insert ¶
func (p *Profile) Insert(event *model.Event, insertMissingProcesses bool, imageTag string, generationType activity_tree.NodeGenerationType, resolvers *resolvers.EBPFResolvers) (bool, error)
Insert inserts an event in the profile
func (*Profile) InsertAndGetSize ¶
func (p *Profile) InsertAndGetSize(event *model.Event, insertMissingProcesses bool, imageTag string, generationType activity_tree.NodeGenerationType, resolvers *resolvers.EBPFResolvers) (bool, int64, error)
InsertAndGetSize inserts an event in the profile and returns the new size of the profile if the event was inserted
func (*Profile) IsEventTypeValid ¶
IsEventTypeValid returns true if the event type is valid for the profile
func (*Profile) ListAllVersionStates ¶
func (p *Profile) ListAllVersionStates()
ListAllVersionStates prints the state of all versions of the profile
func (*Profile) LoadFromNewProfile ¶
LoadFromNewProfile loads a new profile into the current profile
func (*Profile) MatchesSelector ¶
func (p *Profile) MatchesSelector(entry *model.ProcessCacheEntry) bool
MatchesSelector is used to control how an event should be added to a profile
func (*Profile) NewProcessNodeCallback ¶
func (p *Profile) NewProcessNodeCallback(_ *activity_tree.ProcessNode)
NewProcessNodeCallback is called when a new process node is created
func (*Profile) PrepareNewVersion ¶
func (p *Profile) PrepareNewVersion(newImageTag string, tags []string, maxImageTags int, nowTimestamp uint64) []string
PrepareNewVersion prepares a new version of the profile
func (*Profile) Reset ¶
func (p *Profile) Reset()
Reset empties all internal fields so that this profile can be used again in the future
func (*Profile) ScrubProcessArgsEnvs ¶
func (p *Profile) ScrubProcessArgsEnvs(resolver *process.EBPFResolver)
ScrubProcessArgsEnvs scrubs the process arguments and environment variables
func (*Profile) SendStats ¶
func (p *Profile) SendStats(statsdClient statsd.ClientInterface) error
SendStats sends stats for this profile's activity tree
func (*Profile) SetHasAlreadyBeenSent ¶
func (p *Profile) SetHasAlreadyBeenSent()
SetHasAlreadyBeenSent sets the hasAlreadyBeenSent flag to true
func (*Profile) SetTreeType ¶
func (p *Profile) SetTreeType(validator activity_tree.Owner, treeType string)
SetTreeType updates the type and owner of the ActivityTree of this profile
func (*Profile) SetVersionState ¶
func (p *Profile) SetVersionState(imageTag string, state model.EventFilteringProfileState, lastAnomalyNano uint64) error
SetVersionState force a state for a given version (debug purpose only)
func (*Profile) ToSecurityActivityDumpMessage ¶
func (p *Profile) ToSecurityActivityDumpMessage(timeout time.Duration, storageRequests map[config.StorageFormat][]config.StorageRequest) *api.ActivityDumpMessage
ToSecurityActivityDumpMessage returns a pointer to a SecurityActivityDumpMessage
func (*Profile) ToSecurityProfileMessage ¶
func (p *Profile) ToSecurityProfileMessage(timeResolver *ktime.Resolver) *api.SecurityProfileMessage
ToSecurityProfileMessage returns a SecurityProfileMessage filled with the content of the current Security Profile
type VersionContext ¶
type VersionContext struct {
FirstSeenNano uint64
LastSeenNano uint64
EventTypeState map[model.EventType]*EventTypeState
// Syscalls is the syscalls profile
Syscalls []uint32
// Tags defines the tags used to compute this profile, for each present profile versions
Tags []string
}
VersionContext holds the context of one version (defined by its image tag)