Closed amitschendel closed 7 months ago
PR Description updated to latest commit (https://github.com/kubescape/node-agent/commit/27131ff27fa84f60b1a73469a14ca29db9477a84)
⏱️ Estimated effort to review [1-5] | 2, because the changes are focused on enhancing existing functionalities and removing unused code. The modifications are straightforward and localized to specific areas, making the review process relatively easy. |
🧪 Relevant tests | No |
🔍 Possible issues | Possible Bug: The use of `execEvent.ExePath` in conditions alongside `filepath.Base(execPath)` without clear documentation or comments might lead to confusion or bugs in the future. It's important to ensure that the logic for these conditions is correctly implemented and tested. |
Consistency Issue: The removal of comments regarding the significance of `/proc/self/fd/ | |
🔒 Security concerns | No |
Category | Suggestions |
Best practice |
Handle errors immediately after function calls that return them.___ **Consider handling the error returned bytracerexec.NewTracer immediately after its declaration to ensure that any errors are caught and handled properly before proceeding with the execution.** [pkg/containerwatcher/v1/exec.go [40-42]](https://github.com/kubescape/node-agent/pull/246/files#diff-95bba503637ab3f7e32434d1cb37b47e08ccd06907135350e6404febddf55f0eR40-R42) ```diff tracerExec, err := tracerexec.NewTracer(&tracerexec.Config{MountnsMap: execMountnsmap, GetPaths: true}, ch.containerCollection, ch.execEventCallback) if err != nil { + return fmt.Errorf("creating tracer: %w", err) +} ``` |
Enhancement |
Add more key-value pairs to the
___
**Ensure that the |
Add logging for detected executions from malicious sources.___ **Consider adding logging for each condition where execution from a malicious source isdetected. This can aid in debugging and provide more context in security investigations.** [pkg/ruleengine/v1/r1000_exec_from_malicious_source.go [78]](https://github.com/kubescape/node-agent/pull/246/files#diff-00351ce4b75a85e267a68663f357265bbcc7721c2e461fa6112363fdfb2150c5R78-R78) ```diff if strings.HasPrefix(execPath, maliciousExecPathPrefix) || strings.HasPrefix(execEvent.Cwd, maliciousExecPathPrefix) || strings.HasPrefix(execEvent.ExePath, maliciousExecPathPrefix) { + logger.L().Info("Detected execution from a malicious source", "execPath", execPath, "cwd", execEvent.Cwd, "exePath", execEvent.ExePath) ``` | |
Implement comprehensive checks for fileless execution detection.___ **To enhance the detection of fileless execution, consider implementing additional checksfor memory-mapped files or other advanced techniques beyond simple path prefixes.** [pkg/ruleengine/v1/r1005_fileless_execution.go [119]](https://github.com/kubescape/node-agent/pull/246/files#diff-ef0155bc510f47092b9799316b90b72f6eda3347ee96da897e27fe9961f06792R119-R119) ```diff -if strings.HasPrefix(execPath, "/proc/self/fd") || strings.HasPrefix(execEvent.Cwd, "/proc/self/fd") || strings.HasPrefix(execEvent.ExePath, "/proc/self/fd") { +if isFilelessExecution(execPath, execEvent) { + // Implement isFilelessExecution with comprehensive checks ``` | |
Maintainability |
Refactor condition checks into a separate function.___ **Refactor the condition to check for Kubernetes clients into a separate function for betterreadability and maintainability.** [pkg/ruleengine/v1/r0007_kubernetes_client_executed.go [135]](https://github.com/kubescape/node-agent/pull/246/files#diff-c7f3697d600957bfc81d25f2f4f3ad77f03a09775a62f1a878856621f88ad653R135-R135) ```diff -if slices.Contains(kubernetesClients, filepath.Base(execPath)) || slices.Contains(kubernetesClients, event.ExePath) { +if isKubernetesClient(execPath, event.ExePath) { ``` |
Summary:
User description
Overview
Type
enhancement, bug_fix
Description
hardlink
information in the alert structures.gen_rule_files.py
).Changes walkthrough
exec.go
Enhance Exec Tracing Configuration
pkg/containerwatcher/v1/exec.go
GetPaths: true
to thetracerexec.Config
to enhance exec tracingcapabilities.
clamav.go
Include Hardlink Information in Malware Detection Results
pkg/malwaremanager/v1/clamav/clamav.go
hardlink
information in theGenericMalwareResult
structure.r0001_unexpected_process_launched.go
Enhance Unexpected Process Launch Detection with Hardlink Info
pkg/ruleengine/v1/r0001_unexpected_process_launched.go
hardlink
information to theGenericRuleFailure
structure forunexpected process launch detection.
r0007_kubernetes_client_executed.go
Enhance Kubernetes Client Execution Detection
pkg/ruleengine/v1/r0007_kubernetes_client_executed.go
hardlink
information.
r1000_exec_from_malicious_source.go
Update and Enhance Malicious Source Execution Detection
pkg/ruleengine/v1/r1000_exec_from_malicious_source.go
hardlink
information.
r1004_exec_from_mount.go
Enhance Exec from Mount Detection
pkg/ruleengine/v1/r1004_exec_from_mount.go - Enhanced exec from mount detection with `hardlink` information.
r1005_fileless_execution.go
Enhance Fileless Execution Detection with Hardlink Info
pkg/ruleengine/v1/r1005_fileless_execution.go
/proc/self/fd
.hardlink
information.gen_rule_files.py
Remove Deprecated Rule Generation Script
pkg/ruleengine/v1/gen_rule_files.py - Removed the deprecated script used for generating rule files.