Enhance Linux sandbox security features with Landlock, seccomp, and eBPF monitoring

This commit is contained in:
JY Tan
2025-12-25 17:33:55 -08:00
parent a8158a39b3
commit 08ed28f88f
20 changed files with 2820 additions and 64 deletions

View File

@@ -0,0 +1,46 @@
//go:build !linux
// Package sandbox provides sandboxing functionality for macOS and Linux.
package sandbox
import "time"
// EBPFMonitor is a stub for non-Linux platforms.
type EBPFMonitor struct{}
// NewEBPFMonitor creates a stub monitor.
func NewEBPFMonitor(pid int, debug bool) *EBPFMonitor {
return &EBPFMonitor{}
}
// Start is a no-op on non-Linux platforms.
func (m *EBPFMonitor) Start() error { return nil }
// Stop is a no-op on non-Linux platforms.
func (m *EBPFMonitor) Stop() {}
// IsEBPFAvailable returns false on non-Linux platforms.
func IsEBPFAvailable() bool { return false }
// RequiredCapabilities returns empty on non-Linux platforms.
func RequiredCapabilities() []string { return nil }
// CheckBpftraceAvailable returns false on non-Linux platforms.
func CheckBpftraceAvailable() bool { return false }
// ViolationEvent is a stub for non-Linux platforms.
type ViolationEvent struct {
Timestamp time.Time
Type string
Operation string
Path string
PID int
Comm string
Errno int
}
// FormatViolation returns empty on non-Linux platforms.
func (v *ViolationEvent) FormatViolation() string { return "" }
// EnsureTracingSetup returns nil on non-Linux platforms.
func EnsureTracingSetup() error { return nil }