Commit graph

209 commits

Author SHA1 Message Date
Jeremie Fraeys
7efe8bbfbf
native: security hardening, research trustworthiness, and CVE mitigations
Security Fixes:
- CVE-2024-45339: Add O_EXCL flag to temp file creation in storage_write_entries()
  Prevents symlink attacks on predictable .tmp file paths
- CVE-2025-47290: Use openat_nofollow() in storage_open()
  Closes TOCTOU race condition via path_sanitizer infrastructure
- CVE-2025-0838: Add MAX_BATCH_SIZE=10000 to add_tasks()
  Prevents integer overflow in batch operations

Research Trustworthiness (dataset_hash):
- Deterministic file ordering: std::sort after collect_files()
- Recursive directory traversal: depth-limited with cycle detection
- Documented exclusions: hidden files and special files noted in API

Bug Fixes:
- R1: storage_init path validation for non-existent directories
- R2: safe_strncpy return value check before strcat
- R3: parallel_hash 256-file cap replaced with std::vector
- R4: wire qi_compact_index/qi_rebuild_index stubs
- R5: CompletionLatch race condition fix (hold mutex during decrement)
- R6: ARMv8 SHA256 transform fix (save abcd_pre before vsha256hq_u32)
- R7: fuzz_index_storage header format fix
- R8: enforce null termination in add_tasks/update_tasks
- R9: use 64 bytes (not 65) in combined hash to exclude null terminator
- R10: status field persistence in save()

New Tests:
- test_recursive_dataset.cpp: Verify deterministic recursive hashing
- test_storage_symlink_resistance.cpp: Verify CVE-2024-45339 fix
- test_queue_index_batch_limit.cpp: Verify CVE-2025-0838 fix
- test_sha256_arm_kat.cpp: ARMv8 known-answer tests
- test_storage_init_new_dir.cpp: F1 verification
- test_parallel_hash_large_dir.cpp: F3 verification
- test_queue_index_compact.cpp: F4 verification

All 8 native tests passing. Library ready for research lab deployment.
2026-02-21 13:33:45 -05:00
Jeremie Fraeys
201cb66f56
fix(cli): Standardize WebSocket client imports
- Change from deps.zig indirect imports to direct @import() calls
- Improves build compatibility and clarity
- Aligns with Zig idiomatic import style
2026-02-20 21:41:51 -05:00
Jeremie Fraeys
a3b957dcc0
refactor(cli): Update build system and core infrastructure
- Makefile: Update build targets for native library integration
- build.zig: Add SQLite linking and native hash library support
- scripts/build_rsync.sh: Update rsync embedded binary build process
- scripts/build_sqlite.sh: Add SQLite constants generation script
- src/assets/README.md: Document embedded asset structure
- src/utils/rsync_embedded_binary.zig: Update for new build layout
2026-02-20 21:39:51 -05:00
Jeremie Fraeys
04ac745b01
refactor(cli): Rename note to annotate and re-add experiment command
- Renamed note.zig to annotate.zig (preserves user's preferred naming)
- Updated all references from 'ml note' to 'ml annotate'
- Re-added experiment.zig with create/list/show subcommands
- Updated main.zig dispatch: 'a' for annotate, 'e' for experiment
- Updated printUsage and test block to reflect changes
2026-02-20 21:32:01 -05:00
Jeremie Fraeys
7c4a59012b
feat(tui): Add SQLite support for local mode
- store/store.go: New SQLite storage for TUI local mode
  - Open() with WAL mode and NORMAL synchronous
  - Schema initialization for ml_experiments, ml_runs, ml_metrics, ml_params, ml_tags
  - GetUnsyncedRuns(), GetRunsByExperiment(), MarkRunSynced()
  - GetRunMetrics(), GetRunParams() for run details
- config/config.go: Add local mode configuration fields
  - DBPath, ForceLocal, ProjectRoot fields
  - Experiment struct with Name and Entrypoint
  - IsLocalMode() and GetDBPath() helper methods
- go.mod: Add modernc.org/sqlite v1.36.0 dependency
2026-02-20 21:28:49 -05:00
Jeremie Fraeys
adf4c2a834
refactor(cli): Update main.zig and remove deprecated commands
- main.zig: Update command dispatch and usage text
  - Wire up new commands: note, logs, sync, cancel, watch
  - Remove deprecated command references
  - Updated usage reflects unified command structure
- Delete deprecated command files:
  - annotate.zig (replaced by note.zig)
  - experiment.zig (functionality in run/note/logs)
  - logs.zig (old version, replaced)
  - monitor.zig (unused)
  - narrative.zig (replaced by note --hypothesis/context)
  - outcome.zig (replaced by note --outcome)
  - privacy.zig (replaced by note --privacy)
  - requeue.zig (functionality merged into queue --rerun)
2026-02-20 21:28:42 -05:00
Jeremie Fraeys
d3461cd07f
feat(cli): Update server integration commands
- queue.zig: Add --rerun <run_id> flag to re-queue completed local runs
  - Requires server connection, rejects in offline mode with clear error
  - HandleRerun function sends rerun request via WebSocket
- sync.zig: Rewrite for WebSocket experiment sync protocol
  - Queries unsynced runs from SQLite ml_runs table
  - Builds sync JSON with metrics and params
  - Sends sync_run message, waits for sync_ack response
  - MarkRunSynced updates synced flag in database
- watch.zig: Add --sync flag for continuous experiment sync
  - Auto-sync runs to server every 30 seconds when online
  - Mode detection with offline error handling
2026-02-20 21:28:34 -05:00
Jeremie Fraeys
f5b68cca49
feat(cli): Add metadata commands and update cancel
- note.zig: New unified metadata annotation command
  - Supports --text, --hypothesis, --outcome, --confidence, --privacy, --author
  - Stores metadata as tags in SQLite ml_tags table
- log.zig: Simplified to unified logs command (fetch/stream only)
  - Removed metric/param/tag subcommands (now in run wrapper)
  - Supports --follow for live log streaming from server
- cancel.zig: Add local process termination support
  - Sends SIGTERM first, waits 5s, then SIGKILL if needed
  - Updates run status to CANCELLED in SQLite
  - Also supports server job cancellation via WebSocket
2026-02-20 21:28:23 -05:00
Jeremie Fraeys
d0c68772ea
feat(cli): Implement unified run wrapper command
- Fork child process and capture stdout/stderr via pipe
- Parse FETCHML_METRIC key=value [step=N] lines from output
- Write run_manifest.json with run metadata
- Insert/update ml_runs table in SQLite with PID tracking
- Stream output to output.log file
- Support entrypoint from config or explicit command after --
2026-02-20 21:28:16 -05:00
Jeremie Fraeys
551597b5df
feat(cli): Add core infrastructure for local mode support
- mode.zig: Automatic online/offline mode detection with API ping
- manifest.zig: Run manifest read/write/update operations
- core/: Common flags, output formatting, and context management
- local.zig + local/: Local mode experiment operations
- server.zig + server/: Server mode API client
- db.zig: Add pid column to ml_runs table for process tracking
- config.zig: Add force_local, [experiment] section with name/entrypoint
- utils/native_bridge.zig: Native library integration
2026-02-20 21:28:06 -05:00
Jeremie Fraeys
d43725b817
build(make): add check-cli and check-sqlite targets
- Add check-cli target to verify CLI build configuration
- Add check-sqlite target to verify SQLite asset availability
2026-02-20 15:51:36 -05:00
Jeremie Fraeys
96c4c376d8
ci(forgejo): add contract tests and docs deployment
- Add contract-test.yml workflow for API contract testing
- Add docs-deploy.yml for automated documentation deployment
2026-02-20 15:51:29 -05:00
Jeremie Fraeys
23e5f3d1dc
refactor(api): internal refactoring for TUI and worker modules
- Refactor internal/worker and internal/queue packages
- Update cmd/tui for monitoring interface
- Update test configurations
2026-02-20 15:51:23 -05:00
Jeremie Fraeys
7583932897
feat(cli): add progress UI and rsync assets
- Add progress.zig for sync progress display
- Add rsync placeholder and release binaries to assets/rsync/
2026-02-20 15:51:17 -05:00
Jeremie Fraeys
2258f60ade
feat(cli): add utility modules for local mode
- Add hash_cache.zig for efficient file hash caching
- Add ignore.zig for .gitignore-style pattern matching
- Add native_hash.zig for C dataset_hash library integration
2026-02-20 15:51:10 -05:00
Jeremie Fraeys
7ce0fd251e
feat(cli): unified commands and local mode support
- Update experiment.zig with unified commands (local + server modes)
- Add init.zig for local project initialization
- Update sync.zig for project synchronization
- Update main.zig to route new local mode commands (experiment, run, log)
- Support automatic mode detection from config (sqlite:// vs wss://)
2026-02-20 15:51:04 -05:00
Jeremie Fraeys
2c596038b5
refactor(cli): update build system and config for local mode
- Update Makefile with build-sqlite target matching rsync pattern
- Fix build.zig to handle SQLite assets and dataset_hash linking
- Add SQLite asset detection mirroring rsync binary detection
- Update CLI README with local mode documentation
- Restructure rsync assets into rsync/ subdirectory
- Remove obsolete files (fix_arraylist.sh, old rsync_placeholder.bin)
- Add build_rsync.sh script to fetch/build rsync from source
2026-02-20 15:50:52 -05:00
Jeremie Fraeys
ff542b533f
feat(cli): embed SQLite and unify commands for local mode
- Add SQLite amalgamation fetch script (make build-sqlite)
- Embed SQLite in release builds, link system lib in dev
- Create sqlite_embedded.zig utility module
- Unify experiment/run/log commands with auto mode detection
- Add Forgejo CI workflow for building with embedded SQLite
- Update READMEs for local mode and build instructions

SQLite follows rsync embedding pattern: assets/sqlite_release_<os>_<arch>/
Zero external dependencies for release builds.
2026-02-20 15:50:04 -05:00
Jeremie Fraeys
6028779239
feat: update CLI, TUI, and security documentation
- Add safety checks to Zig build
- Add TUI with job management and narrative views
- Add WebSocket support and export services
- Add smart configuration defaults
- Update API routes with security headers
- Update SECURITY.md with comprehensive policy
- Add Makefile security scanning targets
2026-02-19 15:35:05 -05:00
Jeremie Fraeys
02811c0ffe
fix: resolve TODOs and standardize tests
- Fix duplicate check in security_test.go lint warning
- Mark SHA256 tests as Legacy for backward compatibility
- Convert TODO comments to documentation (task, handlers, privacy)
- Update user_manager_test to use GenerateAPIKey pattern
2026-02-19 15:34:59 -05:00
Jeremie Fraeys
37aad7ae87
feat: add manifest signing and native hashing support
- Integrate RunManifest.Validate with existing Validator
- Add manifest Sign() and Verify() methods
- Add native C++ hashing libraries (dataset_hash, queue_index)
- Add native bridge for Go/C++ integration
- Add deduplication support in queue
2026-02-19 15:34:39 -05:00
Jeremie Fraeys
a3f9bf8731
feat: implement tamper-evident audit logging
- Add hash-chained audit log entries for tamper detection
- Add EventRecorder interface for structured event logging
- Add TaskEvent helper method for consistent event emission
2026-02-19 15:34:28 -05:00
Jeremie Fraeys
e4d286f2e5
feat: add security monitoring and validation framework
- Implement anomaly detection monitor (brute force, path traversal, etc.)
- Add input validation framework with safety rules
- Add environment-based secrets manager with redaction
- Add security test suite for path traversal and injection
- Add CI security scanning workflow
2026-02-19 15:34:25 -05:00
Jeremie Fraeys
34aaba8f17
feat: implement Argon2id hashing and Ed25519 manifest signing
- Add Argon2id-based API key hashing with salt support
- Implement Ed25519 manifest signing (key generation, sign, verify)
- Add gen-keys CLI tool for manifest signing keys
- Fix hash-key command to hash provided key (not generate new one)
- Complete isHex helper function
2026-02-19 15:34:20 -05:00
Jeremie Fraeys
f357624685
docs: Update CHANGELOG and add feature documentation
Update documentation for new features:
- Add CHANGELOG entries for research features and privacy enhancements
- Update README with new CLI commands and security features
- Add privacy-security.md documentation for PII detection
- Add research-features.md for narrative and outcome tracking
2026-02-18 21:28:25 -05:00
Jeremie Fraeys
27c8b08a16
test: Reorganize and add unit tests
Reorganize tests for better structure and coverage:
- Move container/security_test.go from internal/ to tests/unit/container/
- Move related tests to proper unit test locations
- Delete orphaned test files (startup_blacklist_test.go)
- Add privacy middleware unit tests
- Add worker config unit tests
- Update E2E tests for homelab and websocket scenarios
- Update test fixtures with utility functions
- Add CLI helper script for arraylist fixes
2026-02-18 21:28:13 -05:00
Jeremie Fraeys
4756348c48
feat: Worker sandboxing and security configuration
Add security hardening features for worker execution:
- Worker config with sandboxing options (network_mode, read_only, secrets)
- Execution setup with security context propagation
- Podman container runtime security enhancements
- Security configuration management in config package
- Add homelab-sandbox.yaml example configuration

Supports running jobs in isolated, restricted environments.
2026-02-18 21:27:59 -05:00
Jeremie Fraeys
cb826b74a3
feat: WebSocket API infrastructure improvements
Enhance WebSocket client and server components:
- Add new WebSocket opcodes (CompareRuns, FindRuns, ExportRun, SetRunOutcome)
- Improve WebSocket client with additional response handlers
- Add crypto utilities for secure WebSocket communications
- Add I/O utilities for WebSocket payload handling
- Enhance validation for WebSocket message payloads
- Update routes for new WebSocket endpoints
- Improve monitor and validate command WebSocket integrations
2026-02-18 21:27:48 -05:00
Jeremie Fraeys
b2eba75f09
feat: CLI shell completion for new commands
Update bash and zsh completion scripts to include:
- compare, find, export, outcome commands
- privacy command and subcommands
- All new narrative field flags (--hypothesis, --context, etc.)
- Sandboxing options (--network, --read-only, --secret)
2026-02-18 21:27:38 -05:00
Jeremie Fraeys
aaeef69bab
feat: Privacy and PII detection
Add privacy protection features to prevent accidental PII leakage:
- PII detection engine supporting emails, phone numbers, SSNs, credit cards
- CLI privacy command for scanning files and text
- Privacy middleware for API request/response filtering
- Suggestion utility for privacy-preserving alternatives

Integrates PII scanning into manifest validation for narrative fields.
2026-02-18 21:27:23 -05:00
Jeremie Fraeys
260e18499e
feat: Research features - narrative fields and outcome tracking
Add comprehensive research context tracking to jobs:
- Narrative fields: hypothesis, context, intent, expected_outcome
- Experiment groups and tags for organization
- Run comparison (compare command) for diff analysis
- Run search (find command) with criteria filtering
- Run export (export command) for data portability
- Outcome setting (outcome command) for experiment validation

Update queue and requeue commands to support narrative fields.
Add narrative validation to manifest validator.
Add WebSocket handlers for compare, find, export, and outcome operations.

Includes E2E tests for phase 2 features.
2026-02-18 21:27:05 -05:00
Jeremie Fraeys
94020e4ca4
chore: move detect_native.go and setup_monitoring.py to dev/ 2026-02-18 17:57:57 -05:00
Jeremie Fraeys
8b75f71a6a
refactor: reorganize scripts into categorized structure
Consolidate 26+ scattered scripts into maintainable hierarchy:

New Structure:
- ci/          CI/CD validation (checks.sh, test.sh, verify-paths.sh)
- dev/         Development workflow (smoke-test.sh, manage-artifacts.sh)
- release/     Release preparation (cleanup.sh, prepare.sh, sanitize.sh, verify.sh, verify-checksums.sh)
- testing/     Test infrastructure (unchanged)
- benchmarks/  Performance tools (track-performance.sh)
- maintenance/ System cleanup (unchanged)
- lib/         Shared functions (unchanged)

Key Changes:
- Unified 6 cleanup-*.sh scripts into release/cleanup.sh with targets
- Merged smoke-test-native.sh into dev/smoke-test.sh --native flag
- Renamed scripts to follow lowercase-hyphen convention
- Moved root-level scripts to appropriate categories
- Updated all Makefile references
- Updated scripts/README.md with new structure

Script count: 26 → 17 (35% reduction)

Breaking Changes:
- Old paths no longer exist, update any direct script calls
- Use make targets (e.g., make ci-checks) for stability
2026-02-18 17:56:59 -05:00
Jeremie Fraeys
5e8dc08643
chore: gitignore generated SSH test keys 2026-02-18 17:48:48 -05:00
Jeremie Fraeys
b4672a6c25
feat: add TUI SSH usability testing infrastructure
Add comprehensive testing for TUI usability over SSH in production-like environment:

Infrastructure:
- Caddy reverse proxy config for WebSocket and API routing
- Docker Compose with SSH test server container
- TUI test configuration for smoke testing

Test Harness:
- SSH server Go test fixture with container management
- TUI driver with PTY support for automated input/output testing
- 8 E2E tests covering SSH connectivity, TERM propagation,
  API/WebSocket connectivity, and TUI configuration

Scripts:
- SSH key generation for test environment
- Manual testing script with interactive TUI verification

The setup allows automated verification that the BubbleTea TUI works
correctly over SSH with proper terminal handling, alt-screen buffer,
and mouse support through Caddy reverse proxy.
2026-02-18 17:48:02 -05:00
Jeremie Fraeys
38b6c3323a
refactor: adopt PathRegistry in jupyter workspace_metadata.go
Update internal/jupyter/workspace_metadata.go to use centralized PathRegistry:

Changes:
- Add import for internal/config package
- Update saveMetadata() to use config.FromEnv() for directory creation
- Replace os.MkdirAll with paths.EnsureDir() for metadata directory

Benefits:
- Consistent directory creation via PathRegistry
- Centralized path management for workspace metadata
- Better error handling for directory creation
2026-02-18 16:58:36 -05:00
Jeremie Fraeys
d9ed8f4ffa
refactor: adopt PathRegistry in queue filesystem_queue.go
Update internal/queue/filesystem_queue.go to use centralized PathRegistry:

Changes:
- Add import for internal/config package
- Update NewFilesystemQueue to use config.FromEnv() for directory creation
- Replace os.MkdirAll with paths.EnsureDir() for all queue directories:
  - pending/entries
  - running
  - finished
  - failed

Benefits:
- Consistent directory creation via PathRegistry
- Centralized path management for queue storage
- Better error handling for directory creation
2026-02-18 16:57:45 -05:00
Jeremie Fraeys
f7afb36a7c
refactor: adopt PathRegistry in execution/setup.go
Update internal/worker/execution/setup.go to use centralized PathRegistry:

Changes:
- Add import for internal/config package
- Update SetupJobDirectories to use config.FromEnv() for directory creation
- Replace all os.MkdirAll calls with paths.EnsureDir()
  - pendingDir creation
  - jobDir creation
  - outputDir (running) creation

Benefits:
- Consistent directory creation via PathRegistry
- Centralized path management for job execution directories
- Better error handling for directory creation failures
2026-02-18 16:57:04 -05:00
Jeremie Fraeys
33b893a71a
refactor: adopt PathRegistry in worker snapshot_store.go
Update internal/worker/snapshot_store.go to use centralized PathRegistry:

Changes:
- Add import for internal/config package
- Update ResolveSnapshot to use config.FromEnv() for directory creation
- Replace os.MkdirAll with paths.EnsureDir() for tmpRoot
- Replace os.MkdirAll with paths.EnsureDir() for extractDir
- Replace os.MkdirAll with paths.EnsureDir() for cacheDir parent

Benefits:
- Consistent directory creation via PathRegistry
- Centralized path management for snapshot storage
- Better error handling for directory creation
2026-02-18 16:56:27 -05:00
Jeremie Fraeys
a5059c5231
refactor: adopt PathRegistry in worker config
Update internal/worker/config.go to use centralized PathRegistry:

Changes:
- Initialize PathRegistry with config.FromEnv() in LoadConfig
- Update BasePath default to use paths.ExperimentsDir()
- Update DataDir default to use paths.DataDir()
- Simplify DataDir logic by using PathRegistry directly

Benefits:
- Consistent directory locations via PathRegistry
- Centralized path management across worker and api-server
- Simpler configuration with fewer conditional branches
2026-02-18 16:55:18 -05:00
Jeremie Fraeys
4bee42493b
refactor: adopt PathRegistry in api server_config.go
Update internal/api/server_config.go to use centralized PathRegistry:

Changes:
- Update EnsureLogDirectory() to use config.FromEnv().LogDir() with EnsureDir()
- Update Validate() to use PathRegistry for default BasePath and DataDir
- Remove hardcoded /tmp/ml-experiments default
- Use paths.ExperimentsDir() and paths.DataDir() for consistent paths

Benefits:
- Consistent directory locations via PathRegistry
- Centralized directory creation with EnsureDir()
- Better error handling for directory creation
2026-02-18 16:54:24 -05:00
Jeremie Fraeys
2101e4a01c
refactor: adopt PathRegistry in experiment manager
Update internal/experiment/manager.go to use centralized PathRegistry:

Changes:
- Add import for internal/config package
- Add NewManagerFromPaths() constructor using PathRegistry
- Update Initialize() to use config.FromEnv().ExperimentsDir() with EnsureDir()
- Update archiveExperiment() to use PathRegistry pattern

Benefits:
- Consistent experiment directory location via PathRegistry
- Centralized directory creation with EnsureDir()
- Backward compatible: existing NewManager() still works
- New code can use NewManagerFromPaths() for PathRegistry integration
2026-02-18 16:53:41 -05:00
Jeremie Fraeys
3e744bf312
refactor: adopt PathRegistry in jupyter service_manager.go
Update internal/jupyter/service_manager.go to use centralized PathRegistry:

Changes:
- Import config package for PathRegistry access
- Update stateDir() to use config.FromEnv().JupyterStateDir()
- Update workspaceBaseDir() to use config.FromEnv().ActiveDataDir()
- Update trashBaseDir() to use config.FromEnv().JupyterStateDir()
- Update NewServiceManager() to use PathRegistry for workspace metadata file
- Update loadServices() to use PathRegistry for services file path
- Update saveServices() to use PathRegistry with EnsureDir()
- Rename parameter 'config' to 'svcConfig' to avoid shadowing import

Benefits:
- Consistent path management across codebase
- Centralized directory creation with EnsureDir()
- Environment variable override still supported (backward compatible)
- Proper error handling for directory creation failures
2026-02-18 16:52:03 -05:00
Jeremie Fraeys
e127f97442
chore: implement centralized path registry and file organization conventions
Add PathRegistry for centralized path management:
- Create internal/config/paths.go with PathRegistry type
- Binary paths: BinDir(), APIServerBinary(), WorkerBinary(), etc.
- Data paths: DataDir(), JupyterStateDir(), ExperimentsDir()
- Config paths: ConfigDir(), APIServerConfig()
- Helper methods: EnsureDir(), EnsureDirSecure(), FileExists()
- Auto-detect repo root by looking for go.mod

Update .gitignore for root protection:
- Add explicit /api-server, /worker, /tui, /data_manager rules
- Add /coverage.out and .DS_Store to root protection
- Prevents accidental commits of binaries to root

Add path verification script:
- Create scripts/verify-paths.sh
- Checks for binaries in root directory
- Checks for .DS_Store files
- Checks for coverage.out in root
- Verifies data/ is gitignored
- Returns exit code 1 on violations

Cleaned .DS_Store files from repository
2026-02-18 16:48:50 -05:00
Jeremie Fraeys
64e306bd72
chore: clean up root directory and remove build artifacts
Remove temporary and build files from repository root:
- Deleted .DS_Store (macOS system file)
- Deleted coverage.out (test coverage report)
- Deleted api-server binary (should not be in git)
- Deleted data_manager binary (should not be in git)
- Removed .local-artifacts/ directory (local test artifacts)

These files are either:
- Generated during build/test (should be in .gitignore)
- System files (should be ignored)
- Binary artifacts (should be built, not committed)

Repository root is now cleaner with only source code and configuration.
2026-02-18 16:43:44 -05:00
Jeremie Fraeys
7880ea8d79
refactor: reorganize podman directory structure
Organize podman/ directory into logical subdirectories:

New structure:
- docs/          - ML_TOOLS_GUIDE.md, jupyter_workflow.md
- configs/       - environment*.yml, security_policy.json
- containers/    - *.dockerfile, *.podfile
- scripts/       - *.sh, *.py (secure_runner, cli_integration, etc.)
- jupyter/       - jupyter_cookie_secret (flattened from jupyter_runtime/runtime/)
- workspace/     - Example projects (cleaned of temp files)

Cleaned workspace:
- Removed .DS_Store, mlflow.db, cache/
- Removed duplicate cli_integration.py

Removed unnecessary nesting:
- Flattened jupyter_runtime/runtime/ to just jupyter/

Improves maintainability by grouping files by purpose and eliminating root directory clutter.
2026-02-18 16:40:46 -05:00
Jeremie Fraeys
5644338ebd
security: implement Podman secrets for container credential management
Add comprehensive Podman secrets support to prevent credential exposure:

New types and methods (internal/container/podman.go):
- PodmanSecret struct for secret definitions
- CreateSecret() - Create Podman secrets from sensitive data
- DeleteSecret() - Clean up secrets after use
- BuildSecretArgs() - Generate podman run arguments for secrets
- SanitizeContainerEnv() - Extract sensitive env vars as secrets
- ContainerConfig.Secrets field for secret list

Enhanced container lifecycle:
- StartContainer() now creates secrets before starting container
- Secrets automatically mounted via --secret flag
- Cleanup on failure to prevent secret leakage
- Secrets logged as count only (not content)

Jupyter service integration (internal/jupyter/service_manager.go):
- prepareContainerConfig() uses SanitizeContainerEnv()
- JUPYTER_TOKEN and JUPYTER_PASSWORD now use secrets
- Maintains backward compatibility with env var mounting

Security benefits:
- Credentials no longer visible in 'podman inspect' output
- Secrets not exposed via /proc/*/environ inside container
- Automatic cleanup prevents secret accumulation
- Compatible with existing Jupyter authentication
2026-02-18 16:35:58 -05:00
Jeremie Fraeys
c9b6532dfb
fix: remove accidentally committed api-server binary 2026-02-18 16:31:40 -05:00
Jeremie Fraeys
412d7b82e9
security: implement comprehensive secrets protection
Critical fixes:
- Add SanitizeConnectionString() in storage/db_connect.go to remove passwords
- Add SecureEnvVar() in api/factory.go to clear env vars after reading (JWT_SECRET)
- Clear DB password from config after connection

Logging improvements:
- Enhance logging/sanitize.go with patterns for:
  - PostgreSQL connection strings
  - Generic connection string passwords
  - HTTP Authorization headers
  - Private keys

CLI security:
- Add --security-audit flag to api-server for security checks:
  - Config file permissions
  - Exposed environment variables
  - Running as root
  - API key file permissions
- Add warning when --api-key flag used (process list exposure)

Files changed:
- internal/storage/db_connect.go
- internal/api/factory.go
- internal/logging/sanitize.go
- internal/auth/flags.go
- cmd/api-server/main.go
2026-02-18 16:18:09 -05:00
Jeremie Fraeys
6446379a40
security: prevent Jupyter token exposure in logs
- Add stripTokenFromURL() helper function to remove tokens from URLs
- Use it when logging service start URLs
- Use it when logging connectivity test URLs
- Prevents sensitive tokens from being written to log files
2026-02-18 16:11:50 -05:00