Skip to content

Commit

Permalink
Merge pull request #243 from kubescape/feature/rule-descriptions
Browse files Browse the repository at this point in the history
Fixing all rules descriptions
  • Loading branch information
David Wertenteil authored Apr 9, 2024
2 parents ca767ec + afd405a commit 76e78a8
Show file tree
Hide file tree
Showing 17 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0001_unexpected_process_launched.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func (rule *R0001UnexpectedProcessLaunched) ProcessEvent(eventType utils.EventTy
TriggerEvent: execEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("exec call \"%s\" is not whitelisted by application profile", execPath),
RuleDescription: fmt.Sprintf("Unexpected process launched: %s in: %s", execPath, execEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0002_unexpected_file_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ func (rule *R0002UnexpectedFileAccess) ProcessEvent(eventType utils.EventType, e
TriggerEvent: openEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Unexpected file access: %s with flags %v", openEvent.Path, openEvent.Flags),
RuleDescription: fmt.Sprintf("Unexpected file access: %s with flags %s in: %s", openEvent.Path, strings.Join(openEvent.Flags, ","), openEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0003_unexpected_system_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (rule *R0003UnexpectedSystemCall) ProcessEvent(eventType utils.EventType, e
TriggerEvent: syscallEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "Unexpected system call: " + syscallEvent.SyscallName,
RuleDescription: fmt.Sprintf("Unexpected system call: %s in: %s", syscallEvent.SyscallName, syscallEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0004_unexpected_capability_used.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (rule *R0004UnexpectedCapabilityUsed) ProcessEvent(eventType utils.EventTyp
TriggerEvent: capEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Unexpected capability used (capability %s used in syscall %s)", capEvent.CapName, capEvent.Syscall),
RuleDescription: fmt.Sprintf("Unexpected capability used (capability %s used in syscall %s) in: %s", capEvent.CapName, capEvent.Syscall, capEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0005_unexpected_domain_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (rule *R0005UnexpectedDomainRequest) ProcessEvent(eventType utils.EventType
TriggerEvent: domainEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Unexpected domain request (%s)", domainEvent.DNSName),
RuleDescription: fmt.Sprintf("Unexpected domain communication: %s from: %s", domainEvent.DNSName, domainEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (rule *R0006UnexpectedServiceAccountTokenAccess) ProcessEvent(eventType uti
TriggerEvent: openEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Unexpected access to service account token: %s", openEvent.Path),
RuleDescription: fmt.Sprintf("Unexpected access to service account token: %s with flags: %s in: %s", openEvent.Path, strings.Join(openEvent.Flags, ","), openEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r0007_kubernetes_client_executed.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (rule *R0007KubernetesClientExecuted) handleExecEvent(event *tracerexectype
TriggerEvent: event.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Kubernetes client executed: %s", event.Comm),
RuleDescription: fmt.Sprintf("Kubernetes client %s was executed in: %s", execPath, event.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r1000_exec_from_malicious_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func (rule *R1000ExecFromMaliciousSource) ProcessEvent(eventType utils.EventType
TriggerEvent: execEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("exec call \"%s\" is from a malicious source \"%s\"", execPath, maliciousExecPathPrefix),
RuleDescription: fmt.Sprintf("Execution from malicious source: %s in: %s", execPath, execEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r1001_exec_binary_not_in_base_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (rule *R1001ExecBinaryNotInBaseImage) ProcessEvent(eventType utils.EventTyp
TriggerEvent: execEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Process image \"%s\" binary is not from the container image \"%s\"", getExecPathFromEvent(execEvent), execEvent.GetContainerImageName()),
RuleDescription: fmt.Sprintf("Process (%s) was executed in: %s and is not part of the image", execEvent.Comm, execEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/ruleengine/v1/r1002_load_kernel_module.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ruleengine

import (
"fmt"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -81,7 +82,7 @@ func (rule *R1002LoadKernelModule) ProcessEvent(eventType utils.EventType, event
TriggerEvent: syscallEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "Kernel Module Load",
RuleDescription: fmt.Sprintf("Kernel module load syscall (init_module) was called in: %s", syscallEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
4 changes: 1 addition & 3 deletions pkg/ruleengine/v1/r1003_malicious_ssh_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ruleengine

import (
"fmt"
"log"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -164,7 +163,7 @@ func (rule *R1003MaliciousSSHConnection) ProcessEvent(eventType utils.EventType,
TriggerEvent: networkEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("ssh connection to port %d is not allowed", networkEvent.Port),
RuleDescription: fmt.Sprintf("SSH connection to disallowed port %d", networkEvent.Port),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand All @@ -185,7 +184,6 @@ func calculateTimestampDiffInSeconds(timestamp1 int64, timestamp2 int64) int64 {
func IsSSHConfigFile(path string) bool {
for _, sshFile := range SSHRelatedFiles {
if strings.Contains(path, sshFile) {
log.Printf("Found SSH related file: %s\n", path)
return true
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/ruleengine/v1/r1004_exec_from_mount.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ruleengine

import (
"fmt"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -88,7 +89,7 @@ func (rule *R1004ExecFromMount) ProcessEvent(eventType utils.EventType, event in
TriggerEvent: execEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "Exec from mount",
RuleDescription: fmt.Sprintf("Process (%s) was executed from a mounted path (%s) in: %s", p, mount, execEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r1005_fileless_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (rule *R1005FilelessExecution) handleSyscallEvent(syscallEvent *ruleenginet
TriggerEvent: syscallEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "memfd_create syscall detected",
RuleDescription: fmt.Sprintf("Fileless execution detected: syscall memfd_create executed in: %s", syscallEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/ruleengine/v1/r1006_unshare_system_call.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ruleengine

import (
"fmt"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -83,7 +84,7 @@ func (rule *R1006UnshareSyscall) ProcessEvent(eventType utils.EventType, event i
TriggerEvent: syscallEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "Unshare System Call usage",
RuleDescription: fmt.Sprintf("unshare system call executed in %s", syscallEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/ruleengine/v1/r1007_xmr_crypto_mining.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ruleengine

import (
"fmt"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -76,7 +77,7 @@ func (rule *R1007XMRCryptoMining) ProcessEvent(eventType utils.EventType, event
TriggerEvent: randomXEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "XMR Crypto Mining detected by randomx algorithm usage.",
RuleDescription: fmt.Sprintf("XMR Crypto Miner process: (%s) executed in: %s", randomXEvent.Comm, randomXEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/ruleengine/v1/r1008_crypto_mining_domain.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ruleengine

import (
"fmt"
"node-agent/pkg/objectcache"
"node-agent/pkg/ruleengine"
"node-agent/pkg/utils"
Expand Down Expand Up @@ -182,7 +183,7 @@ func (rule *R1008CryptoMiningDomainCommunication) ProcessEvent(eventType utils.E
TriggerEvent: dnsEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: "Crypto mining domain communication",
RuleDescription: fmt.Sprintf("Communication with a known crypto mining domain: %s in: %s", dnsEvent.DNSName, dnsEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ruleengine/v1/r1009_crypto_mining_port.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (rule *R1009CryptoMiningRelatedPort) ProcessEvent(eventType utils.EventType
TriggerEvent: networkEvent.Event,
RuleAlert: apitypes.RuleAlert{
RuleID: rule.ID(),
RuleDescription: fmt.Sprintf("Possible crypto mining communication on port %d", networkEvent.Port),
RuleDescription: fmt.Sprintf("Communication on a commonly used crypto mining port: %d in: %s", networkEvent.Port, networkEvent.GetContainer()),
},
RuntimeAlertK8sDetails: apitypes.RuntimeAlertK8sDetails{},
}
Expand Down

0 comments on commit 76e78a8

Please sign in to comment.