Watch
1
0
Fork
You've already forked RedFlag
0
Commit graph

479 commits

Author SHA1 Message Date
Fimeg
58b82d2cc1 fix: handle additional failure result types in log reporting
feat: add migration 032 for commands updated_at column
2026-05-21 11:23:44 -04:00
Fimeg
aca25bab33 docs: remove stale doc links from README 2026-05-21 11:07:37 -04:00
Fimeg
dd93551eb1 chore: remove internal docs, tools, and config from public branch 2026-05-21 09:19:42 -04:00
Fimeg
2665ee36be docs: update README for v0.2.0 release
- Version bump to 0.2.0, changelog with all new features
- Fix Quick Start ports (3000→31336)
- Fix architecture diagram ports (3000/8080→31336/31337)
- Add new features to list: key rotation, replay protection,
  maintenance windows, supply chain checks
- Update Known Issues to be honest about gaps
- Update competitive position section
2026-05-21 08:53:03 -04:00
Fimeg
0591b110ee chore: bump version to 0.2.0 and clean up gitignore
- Version set to 0.2.0 (major feature release)
- Add stale WIP files from Dec 2025 to gitignore
2026-05-21 08:40:09 -04:00
Fimeg
bce2474f6a feat: supply chain vulnerability badge in update list and detail view 2026-05-21 08:31:13 -04:00
Fimeg
bd97fe46e8 feat: OSV.dev supply chain check for npm/PyPI packages at approval time
- New supply_chain service queries api.osv.dev/v1/query for known
  vulnerabilities on npm and PyPI packages before approval
- Vulnerability results stored in metadata and returned as warnings
  in the API response (approval never blocked — sovereignty principle)
- ApproveUpdateWithVulns stores supply chain data in metadata JSONB
2026-05-21 08:02:19 -04:00
Fimeg
053fae8537 feat: maintenance windows + install URL fixes + migration 025 cleanup
- Maintenance windows: new DB table, CRUD API, settings UI, gate checks
  in InstallUpdate() and ConfirmDependencies() so installs are blocked
  outside configured windows (scan operations unaffected)
- Fix install command URLs: backend registration_tokens.go now uses
  REDFLAG_PUBLIC_URL when set; frontend hardcoded :8080 → :31337
- Add REDFLAG_PUBLIC_URL to setup wizard template output
- Remove conflicting PG trigger from migration 025 (handler already
  creates subsystems during registration — trigger caused duplicate
  key errors on fresh installs)
- Fix bare RAISE NOTICE in 025 migration (needs DO block)
2026-05-21 07:43:55 -04:00
Casey Tunturi
7e5c7e4887 feat: agent-server-web integration updates
- Agent: subsystem handlers, loop, client, registration, new scanner detect
- Server: main, agents handlers, subsystems queries, scheduler
- Web: App, AgentHealth, Setup/Welcome checkers, API lib, Setup page
2026-05-07 02:18:46 -04:00
Casey Tunturi
6e26bd7218 docs: rewrite cleanup-instructions in a calmer voice
The pre-v0.1.20 upgrade note had vented frustration in it. Same substance
(uninstall + reinstall is the supported path; reach out for large fleets),
without the curt phrasing.
2026-04-30 11:02:36 -04:00
Casey Tunturi
133131d846 Restore install.sh + THIRD_PARTY_LICENSES.md from legacy
The orphan security rewrite removed the bash systemd installer; bringing it
back so an unattended bootstrap path exists. THIRD_PARTY_LICENSES.md is
restored for legal completeness (will need a refresh as deps evolve).
.gitignore updated to allow THIRD_PARTY_LICENSES.md.
2026-04-30 10:49:59 -04:00
Casey Tunturi
38d8a5f913 Unify histories: legacy RedFlag + Culurien rewrite + reflections
Three previously-disconnected histories are joined here so the project carries
its full provenance forward in one repo.

  legacy lineage  (root 55b7d030, Nov 2025 -> Mar 2026)
      Original RedFlag GitHub project. Last tip 484a7f77 (2026-03-28).
      Preserved on branch "legacy-archive" and reachable through this
      merge commit.

  Culurien rewrite (orphan, root f97d484b)
      jpetree331 / Culurien did a one-day from-scratch security-first rebuild
      on 2026-03-29: Ed25519 key rotation, replay protection, transactional
      migrations, configurable timeouts, path traversal hardening, semver
      version comparison, and grew the test suite from ~3 to 170 tests across
      18 packages. Tagged v0.2.0.1 (2026-04-09) by Ani Tunturi.

  Reflections continuation (extends the Culurien branch)
      TD-001 main.go modular refactor, TD-002 panic recovery, TD-003 error
      transparency, ISSUE-001/002/004 fixes, VULN-001 dependency cleanup.
      Tip edadbd1 (2026-04-13).

Some interim history was lost to a hard-drive failure during development;
this merge brings together everything still recoverable.

Thank you, Culurien.
2026-04-30 10:01:49 -04:00
Ani Tunturi
02bbc8d2c8 WIP: Vanguard uncommitted changes - aggregator loop, client, handlers, lifecycle 2026-04-13 17:51:48 -04:00
Ani Tunturi
24d8923ed7 TD-003: Complete Error Transparency implementation
- Add server endpoint POST /api/v1/agents/:id/events (100 event limit)
- Add ReportEvents client method to send buffered events
- Add reportBufferedEvents to agent loop (non-blocking)
- Add check-in lifecycle event logging
- Add BufferEvent public method for components

Closes TD-003
2026-04-11 12:48:12 -04:00
Ani Tunturi
e045d5270d TD-001: Refactor main.go God Function (1995 lines → modular architecture)
Refactored the 1,995 line main.go into modular components:

**New Files:**
- cmd/agent/cli.go: CLI parsing and flag handling (was inline in main)
- internal/agent/loop.go: Main agent polling loop (extracted from runAgent)
- internal/handlers/commands.go: Local command handlers (scan, status, list-updates)
- internal/registration/service.go: Agent registration logic

**Modified:**
- cmd/agent/main.go: Reduced from 1995 lines to ~200 lines (thin entry point)
- cmd/agent/subsystem_handlers.go: Updated to use handlers.ReportLogWithAck

**Architecture:**
main.go now only handles:
1. CLI parsing (delegated to cli.go)
2. Command routing (register, scan, status, agent mode)
3. Thin wrapper around agent.RunAgentLoop()

The 1,119 line runAgent() function is now split across:
- internal/agent/loop.go: Polling loop, circuit breaker management
- internal/handlers/commands.go: Local scan/status commands
- internal/registration/service.go: Registration flow

**Build:** Verified agent compiles successfully
**Breaking Changes:** None - all existing functionality preserved
2026-04-11 12:38:56 -04:00
Ani Tunturi
9d90f28def TD-002: Add panic recovery to Windows service agent loop
- Import internal/recovery package
- Add defer recovery.Recover() to runAgent() function
- Prevents Windows service crashes from unhandled panics
- Parity with Linux agent panic recovery (main.go:705)
2026-04-11 12:32:33 -04:00
Ani Tunturi
82c1685985 feat(TD-002): Implement Phase 0 - Panic Recovery
- Add internal/recovery/panic.go with panic recovery wrappers
- Add internal/startup/event.go for startup event logging
- Integrate recovery into agent main loop (runAgent)
- Add per-command panic recovery with server reporting
- Log panics with stack traces for debugging

Refs Phase 2 reliability improvements
2026-04-11 12:29:57 -04:00
Ani Tunturi
4cbf3f79df fix: Correct version.AgentVersion usage and circuit breaker stats
- Fix version.Version -> version.AgentVersion in main.go
- Fix len() usage on int in circuit breaker reporting

Both server and agent now build successfully.
2026-04-11 12:27:16 -04:00
Ani Tunturi
8740e1d603 fix(ISSUE-004): Add agent-side circuit breaker health reporting
- Report circuit breaker states during each check-in
- Include all 7 subsystems: APT, DNF, Windows Update, Winget, Storage, System, Docker
- Non-blocking goroutine to avoid impacting check-in latency
- Logs success/failure for debugging

Refs #14
2026-04-11 12:26:14 -04:00
Ani Tunturi
d79a85ebab fix(ISSUE-004): Add circuit breaker health reporting endpoint
- Add ReportCircuitBreakerStats client method
- Add /api/v1/agents/:id/circuit-breakers POST endpoint
- Add server handler with open breaker detection and logging
- Enables monitoring and alerting for circuit breaker states

Refs #14
2026-04-11 12:25:39 -04:00
Ani Tunturi
73da309560 fix(TD-002): Add panic recovery to prevent agent crashes 2026-04-11 12:22:27 -04:00
Ani Tunturi
47e9c74aac fix(VULN-001): Resolve dependency vulnerabilities
- Updated axios: ^1.6.2 -> ^1.15.0 (fixes CRITICAL DoS, SSRF, metadata exfiltration)
- Updated react-router-dom: ^6.20.1 -> ^6.31.0 (fixes HIGH XSS via Open Redirects)
- 0 vulnerabilities remaining in production dependencies
- windowsupdate is internal code (pkg/windowsupdate/), not external dependency

Fixes: Fimeg/Fimeg-Reflections#14
2026-04-11 12:20:48 -04:00
Ani Tunturi
96c8430190 fix(VULN-001): Resolve dependency vulnerabilities
- npm audit fix: Updated axios, react-router-dom, transitive deps
- 0 vulnerabilities remaining in npm audit
- go mod tidy: Cleaned up dependency ordering

Fixes: Fimeg/Fimeg-Reflections#14
2026-04-11 12:19:56 -04:00
Ani Tunturi
bacff0638c fix(ISSUE-002): Connect BuildOrchestrator to signing service
- Initialize BuildOrchestratorService with signingService and packageQueries
- Sign all pre-built agent binaries at server startup (linux-amd64, linux-arm64, windows-amd64, windows-arm64)
- Store signed packages in database for download with signature headers
- Add strings import for platform parsing

This ensures every binary distributed by the download handler is properly signed
before distribution, fixing the Ed25519 trust model compromise where binaries
were being served without signatures.
2026-04-11 12:17:08 -04:00
Ani Tunturi
579ab98b9d fix(ISSUE-002): Add binary signature verification to install scripts
- Linux: Added Ed25519 signature verification using Python3 before binary install
- Windows: Added Ed25519 signature verification using .NET 5+ or BouncyCastle
- Both scripts now verify the binary against the TOFU server public key
- Fail installation if signature verification fails (tamper detection)
- Saves signature and public key for agent-side verification

Security: Install scripts now verify binary signatures before installation,
preventing compromised binaries from being installed even on first use.
2026-04-11 12:16:11 -04:00
Ani Tunturi
020c3d35c0 fix(ISSUE-002): Connect signing service to build pipeline for install verification
- Added signature header (X-Content-Signature) to download responses
- Added server public key to install script template data
- Install script now saves signature and public key for TOFU verification
- Download handler now requires signingService for public key access
- Updated main.go to pass signingService to download handler

Fixes ISSUE-002: Ed25519 Build Orchestrator disconnected
Refs: gitea.wiuf.net/Fimeg/Fimeg-Reflections/issues/13
2026-04-11 12:09:16 -04:00
Ani Tunturi
d2bf6b8357 fix(ISSUE-001): Fix database transaction poisoning in migrations
- Changed "already exists" error handling from silent skip to explicit error
- Now detects inconsistent state when migration recorded but failed
- Added schema_migrations_backup table for recovery
- Added MigrationHealth() endpoint for consistency checks

Fixes ISSUE-001: Database Transaction Poisoning
Refs: gitea.wiuf.net/Fimeg/Fimeg-Reflections/issues/12
2026-04-11 12:06:33 -04:00
Ani Tunturi
074316a55b chore: update scheduler and docker-compose config 2026-04-11 10:08:08 -04:00
Ani Tunturi
17e4c59e3e Add Vanguard skills for RedFlag development workflow
- working-on-redflag: Full 4-phase workflow with ETHOS enforcement
- vanguard-triage: Route incoming requests to correct handler
- Includes state machine pattern, branch ancestry checks
- Fork-based verification for RAF queries and code exploration

Vanguard (agent-f7ddc5ce-6c27-4799-bcc4-99fb688eb222)
2026-04-10 22:16:39 -04:00
Ani Tunturi
5727e53874 fix: BUG-012, BUG-014, BUG-015 - platform detection, strict signing, key paths
- BUG-012: Server public key path consistency via constants package
- BUG-014: Strict signing mode - reject unsigned commands (ETHOS #2)
- BUG-015: Platform detection for update scanners (apt/dnf/windows/winget)
- Add SecurityLogger.LogUnsignedCommandRejected() method
- Update RAF documentation
2026-04-10 10:16:48 -04:00
Ani Tunturi
e261154d17 fix(BUG-014/015): Strict signing + platform scanner support
- Subsystems handler: Strict mode signAndCreateCommand

- BUG-015: Document platform scanner support (apt, dnf, windows, winget)

- ETHOS #1: All logging uses [TAG] format

- ETHOS #2: Never store unsigned commands
2026-04-10 08:01:06 -04:00
Ani Tunturi
6ea23cc290 fix(BUG-014): Strict mode - reject unsigned commands
- ETHOS #2: Security is Non-Negotiable

- Fail fast if signing disabled, never store unsigned

- Proper [ERROR] logging with context
2026-04-10 07:58:07 -04:00
Ani Tunturi
70917f628a fix(installer): Create /etc/redflag/server directory for TOFU public key caching
The agent needs to cache the server's Ed25519 public key for command
verification, but the installer wasn't creating the directory or
setting permissions.

Fixes BUG-010, BUG-011 related issues:
- Creates /etc/redflag/server during install
- Sets ownership to redflag-agent user
- Adds to systemd ReadWritePaths

Also includes:
- command.go.full with RetryCount field (model fix)

These fixes ensure fresh installs work correctly without manual
intervention for public key caching.
2026-04-09 16:19:43 -04:00
Ani Tunturi
6191b7444a fix(install): Add SELinux context restoration after binary install
When agent binary is downloaded to /tmp and moved to /usr/local/bin,
it retains the user_tmp_t SELinux context which prevents systemd from
executing it on RHEL/Fedora/CentOS systems with SELinux enforcing.

Fix adds restorecon after chmod to ensure proper bin_t context.

Fixes agent service failing to start with 'Permission denied' on first install.
Related: BUG-009 (install script issues)
2026-04-09 09:56:32 -04:00
jpetree331
249091806b fix: Docker deployment blockers
- Fix CRLF line endings in docker-entrypoint.sh (exec failed)
- Fix migration 030 value_type 'integer' -> 'number' (chk_value_type constraint)
- Fix web Dockerfile: npm ci -> npm install (platform-specific lockfile)
- Remove @rollup/rollup-win32-x64-msvc from package.json (Windows-only)
2026-03-29 19:28:18 -04:00
jpetree331
726557a2b4 docs: Vision vs Reality comprehensive deviation report
Complete comparison of Fimeg's original vision against
current codebase state after culurien branch work.

- 9 sections covering architecture, features, backlog
- 10 deviations documented (VD-001 through VD-010)
- 27 backlog items tracked with current status
- Honest roadmap with prioritized next steps
- Executive summary for quick reference

Core: 9/10. Features: 5/10. Homelab ready: 7/10.
2026-03-29 19:04:49 -04:00
jpetree331
9ea45ad0fa docs: add config/.env.example for quick start
Covers all required and optional environment variables
with sensible defaults and inline setup instructions.
2026-03-29 18:53:40 -04:00
jpetree331
f5a63df486 verify: integration verification pass
Fixed seam issues found during cross-series verification:
- Add path traversal guard to DownloadAgent signed-package path
- Replace fmt.Printf DEBUG/Warning in updates.go with log.Printf
- Replace 11 emoji in subsystem_handlers.go daemon logs with ETHOS format

All series verified to work together correctly.
170 tests pass. Full ETHOS compliance confirmed.
3 cross-platform builds pass (linux-amd64, linux-arm64, windows-amd64).
2026-03-29 18:43:00 -04:00
jpetree331
2d32d4b4ce feat(upgrade): agent upgrade system fixes
- Fix /api/v1/info returning hardcoded v0.1.21 (U-1)
- Fix semver comparison (lexicographic -> octet-based) (U-2)
- Fix bulk upgrade platform hardcoded to linux-amd64 (U-3)
- Fix bulk upgrade missing nonce generation (U-4)
- Add error check for sc stop in Windows restart (U-7)
- Add timeout + size limit to binary download (U-8)
- Fix ExtractConfigVersionFromAgent last-char bug (U-10)

End-to-end upgrade pipeline now fully wired.
170 tests pass (110 server + 60 agent). No regressions.
2026-03-29 18:27:21 -04:00
jpetree331
0ef784b52f feat(installer): arch detection + checksum verification
- Fix Windows config path in template (carry-over from Fix 1)
- Add runtime arch detection in Linux installer (uname -m)
- Add runtime arch detection in Windows installer
- Add ?arch= query param to install endpoint
- Serve X-Content-SHA256 header with binary downloads
- Verify checksum in Linux and Windows installers
- Warn (not fail) if server does not provide checksum

166 tests pass (106 server + 60 agent). No regressions.
2026-03-29 18:07:21 -04:00
jpetree331
2ca6e5bc6b fix(installer): installer bug fixes and cleanup
- Fix Windows $AgentBinary undefined (F-1)
- Add Windows admin/UAC check (F-2)
- Fix dashboard saves .ps1 not .bat (F-5)
- Fix Windows config path inconsistency (F-6)
- Fix Linux duplicate variable declarations (F-9)
- Fix Linux duplicate step numbering (F-10)
- Document emoji exemption for installer UX output

163 tests pass. No regressions.
2026-03-29 17:55:51 -04:00
jpetree331
c4671a1a2f verify: E-1c configurable timeouts and path sanitization verified
All 6 timeout values configurable via DB settings.
Fallback to defaults confirmed for fresh installs.
Path traversal defense verified (403 + logging).
Fixed hardcoded duration references in timeout.go log output.
163 tests pass, no regressions.
2026-03-29 17:19:12 -04:00
jpetree331
7565cfde1e feat(config): E-1b/E-1c TypeScript strict compliance, configurable timeouts, path sanitization
E-1b: Fix 217 TypeScript strict errors to zero (tsc --noEmit clean).
  - Remove unused vars/imports, fix type mismatches, widen interfaces
  - TanStack Query v5 isLoading->isPending for mutations
  - No @ts-ignore or as any introduced

E-1ab verification fixes:
  - Fix audit table name mismatch (security_setting_audit -> security_settings_audit)
  - Fix DockerContainer TS type (image_name->image, image_tag->tag) to match server
  - Add 501 for empty binary_path in downloads
  - Fix ETHOS log format in downloads error path

E-1c: Configurable timeouts + path sanitization
  - Seed 6 operational timeout settings in DB (migration 030)
  - Wire server to read timeout values from DB at startup
  - Fallback to hardcoded defaults if DB settings missing
  - Fix binary_path traversal risk in downloads handler
  - Add BinaryStoragePath config (REDFLAG_BINARY_STORAGE_PATH)
  - Log resolved timeout values at startup

163 tests pass (103 server + 60 agent). No regressions.
Vite build passes. TypeScript: 0 errors.
2026-03-29 17:09:12 -04:00
jpetree331
417e8ad7c2 feat(ui): E-1a complete stubbed features
- Wire Install button to POST /updates/:id/install (F-E1-4)
  Loading state, toast notifications, list refresh on success
- Wire Logs button to GET update logs endpoint (F-E1-5)
  Expandable log panel with formatted output
- Wire downloads.go signed package lookup to DB (F-E1-1)
  Queries GetSignedPackage when version parameter provided
- Implement GetSecurityAuditTrail with real DB query (F-E1-7)
  Queries security_settings_audit table via service layer
- Resolve GetSecurityOverview placeholder (F-E1-8)
  Raw pass-through confirmed correct design (dashboard uses
  separate SecurityHandler.SecurityOverview endpoint)

All tests pass. No regressions from A/B/C/D series.
2026-03-29 11:12:38 -04:00
jpetree331
f75d7e85e4 docs: E-1 incomplete features audit
Audit of stubbed and incomplete features: signed package downloads,
configurable timeouts, install/logs UI, security audit trail.

Key findings:
- Signed package download: 80% complete (agent-side missing)
- Configurable timeouts: 40% (6 hardcoded values, infrastructure partial)
- Install/Logs UI: 85% (backend exists, frontend needs wiring)
- Security audit trail: 70% (table exists, query not written)
- TypeScript: 217 strict errors (app runs via Vite, not blocking)

Feature completeness matrix and prioritization in report.
See docs/E1_Incomplete_Features_Audit.md for full analysis.
2026-03-29 10:59:07 -04:00
jpetree331
78fe66f9da verify: D-2 ETHOS compliance sweep verified
Zero emoji in non-exempt log statements.
Zero fmt.Printf used for background logging.
All [TAG] [system] [component] formats confirmed.
Exempt files untouched. All tests pass.
2026-03-29 10:49:24 -04:00
jpetree331
b385623164 fix(ethos): D-2 ETHOS compliance sweep
- Remove emoji from log statements across server and agent
- Replace fmt.Printf with log.Printf in queries and handlers
- Apply [TAG] [system] [component] format throughout
- Exempt: display/terminal.go, setup.go, main.go CLI sections

Total violations fixed: ~45 (emoji + fmt.Printf)
All tests pass. Zero regressions.
2026-03-29 10:43:16 -04:00
jpetree331
8cccb7ed81 test(ethos): D-2 pre-fix tests for ETHOS compliance violations
Pre-fix tests documenting emoji in log statements and fmt.Printf
used as logging across server and agent codebases.

Tests added:
- Server emoji: machine_binding.go, agents.go, update handlers (6 tests)
- Server fmt.Printf: queries, handlers, services (6 tests)
- Agent emoji: main.go log paths, migration executor (4 tests)
- Exemptions: display/terminal.go, setup.go (2 tests, always pass)

Current state: 8 FAIL, 8 PASS, 2 ALWAYS-PASS.
All prior tests pass. No regressions.
2026-03-29 10:14:01 -04:00
jpetree331
bfe0514fd2 docs: D-2 ETHOS compliance audit — pre-existing violations
Full scan of emoji, fmt.Printf, log format, and banned word
violations that predate the A/B/C/D-1 fix series.

Findings:
- ~61 emoji violations in log statements (server+agent)
- ~23 emoji instances in UI/CLI (intentional, lower priority)
- ~12 fmt.Printf used as logging (should be log.Printf)
- 0 banned words (all cleaned in prior series)
- 0 silenced errors

Estimated effort: MEDIUM. Priority: fmt.Printf fixes first,
then emoji in log statements, CLI emojis last.

See docs/D2_ETHOS_Compliance_Audit.md for complete listing.
2026-03-29 10:04:04 -04:00
jpetree331
5cf98ac577 verify: D-1 machine ID fixes verified
All 5 D-1 fixes verified. Registration 'unknown-' fallback removed,
clean abort on failure. Rebind endpoint operational with admin auth
and input validation. Dead code deleted. Windows retry removed.
106 tests pass. No regressions from A/B/C series.
2026-03-29 09:59:29 -04:00