fetch_ml/internal/worker
Jeremie Fraeys 92aab06d76
feat(security): implement comprehensive security hardening phases 1-5,7
Implements defense-in-depth security for HIPAA and multi-tenant requirements:

**Phase 1 - File Ingestion Security:**
- SecurePathValidator with symlink resolution and path boundary enforcement
  in internal/fileutil/secure.go
- Magic bytes validation for ML artifacts (safetensors, GGUF, HDF5, numpy)
  in internal/fileutil/filetype.go
- Dangerous extension blocking (.pt, .pkl, .exe, .sh, .zip)
- Upload limits (10GB size, 100MB/s rate, 10 uploads/min)

**Phase 2 - Sandbox Hardening:**
- ApplySecurityDefaults() with secure-by-default principle
  - network_mode: none, read_only_root: true, no_new_privileges: true
  - drop_all_caps: true, user_ns: true, run_as_uid/gid: 1000
- PodmanSecurityConfig and BuildSecurityArgs() in internal/container/podman.go
- BuildPodmanCommand now accepts full security configuration
- Container executor passes SandboxConfig to Podman command builder
- configs/seccomp/default-hardened.json blocks dangerous syscalls
  (ptrace, mount, reboot, kexec_load, open_by_handle_at)

**Phase 3 - Secrets Management:**
- expandSecrets() for environment variable expansion using ${VAR} syntax
- validateNoPlaintextSecrets() with entropy-based detection
- Pattern matching for AWS, GitHub, GitLab, OpenAI, Stripe tokens
- Shannon entropy calculation (>4 bits/char triggers detection)
- Secrets expanded during LoadConfig() before validation

**Phase 5 - HIPAA Audit Logging:**
- Tamper-evident chain hashing with SHA-256 in internal/audit/audit.go
- Event struct extended with PrevHash, EventHash, SequenceNum
- File access event types: EventFileRead, EventFileWrite, EventFileDelete
- LogFileAccess() helper for HIPAA compliance
- VerifyChain() function for tamper detection

**Supporting Changes:**
- Add DeleteJob() and DeleteJobsByPrefix() to storage package
- Integrate SecurePathValidator in artifact scanning
2026-02-23 18:00:33 -05:00
..
errors refactor(api): internal refactoring for TUI and worker modules 2026-02-20 15:51:23 -05:00
execution feat: Worker sandboxing and security configuration 2026-02-18 21:27:59 -05:00
executor feat(security): implement comprehensive security hardening phases 1-5,7 2026-02-23 18:00:33 -05:00
integrity feat: add manifest signing and native hashing support 2026-02-19 15:34:39 -05:00
interfaces refactor: Phase 1 - Extract worker interfaces 2026-02-17 14:10:03 -05:00
lifecycle refactor(api): internal refactoring for TUI and worker modules 2026-02-20 15:51:23 -05:00
artifacts.go feat(security): implement comprehensive security hardening phases 1-5,7 2026-02-23 18:00:33 -05:00
config.go feat(security): implement comprehensive security hardening phases 1-5,7 2026-02-23 18:00:33 -05:00
factory.go feat: GPU detection transparency and artifact scanner improvements 2026-02-23 12:29:34 -05:00
gpu_detector.go feat: GPU detection transparency and artifact scanner improvements 2026-02-23 12:29:34 -05:00
gpu_macos.go feat: GPU detection transparency and artifact scanner improvements 2026-02-23 12:29:34 -05:00
gpu_macos_stub.go feat: native GPU detection and NVML bridge for macOS and Linux 2026-02-21 17:59:59 -05:00
gpu_nvml_native.go feat: native GPU detection and NVML bridge for macOS and Linux 2026-02-21 17:59:59 -05:00
gpu_nvml_stub.go feat: native GPU detection and NVML bridge for macOS and Linux 2026-02-21 17:59:59 -05:00
native_bridge.go feat: native GPU detection and NVML bridge for macOS and Linux 2026-02-21 17:59:59 -05:00
native_bridge_libs.go feat: GPU detection transparency and artifact scanner improvements 2026-02-23 12:29:34 -05:00
native_bridge_nocgo.go feat: native GPU detection and NVML bridge for macOS and Linux 2026-02-21 17:59:59 -05:00
snapshot_store.go fix: resolve benchmark and build tag conflicts 2026-02-21 14:26:48 -05:00
testutil.go refactor: Phase 7 - TUI cleanup - reorganize model package 2026-02-17 20:22:04 -05:00
worker.go feat: GPU detection transparency and artifact scanner improvements 2026-02-23 12:29:34 -05:00