Skip to content

Dev#28

Merged
Warhammer4000 merged 4 commits into
mainfrom
dev
Jun 15, 2026
Merged

Dev#28
Warhammer4000 merged 4 commits into
mainfrom
dev

Conversation

@Warhammer4000

Copy link
Copy Markdown
Contributor

No description provided.

Centralize and harden authentication recovery: remove the old enhanced_auth implementation and introduce a single Service that handles Refresh/Recover with single-flight guards and a circuit breaker (moved to a new resilience package). Add DoWithAuthRetry, Healthy, NeedsReprovision and Status APIs so callers can recover on 401 and pause when credentials are unrecoverable.

Integrations: expose a lightweight authRetrier interface and wire the auth service into LoggingIntegration/Uploader so uploads defer when auth is degraded and use a recover-and-retry wrapper on 401s. Scheduler tasks now use Recover/DoWithAuthRetry and skip work while auth is degraded. Add httperr helpers for classifying 401 vs 403 and implement agent-login and related tests. Update main integration startup to reuse valid stored tokens and wire auth into services.
Make software collectors report which source categories were actually scanned and propagate that info through the sync pipeline. GetSoftwareList and platformSoftware now return (items, scannedSources) and each platform/collector reports success via (items, ok). SyncBatch now accepts scannedSources and only demotes rows for sources that were successfully scanned, preventing a failed collector from demoting its entire catalog. Added appendExtensions to centralize extension collection and added a Windows UserAssist last-opened enrichment (best-effort) with tests. Updated scheduler, CLI, task handlers, store, and many unit tests to reflect the new signatures and behavior.
Introduce an emergencylog package that records rare, terminal/transition failures to durable daily plain-text files (retain 3 days) and always echoes events to the standard log. Init is idempotent and non-fatal; Record is concurrency-safe and safe to call before Init. Integrate emergencylog into startup (initialize before config validation) and emit startup warnings when init/validation/scheduler startup fail.

Enhance scheduler: add atomic consecutiveFailures and alerted counters on Task, a taskFailureThreshold (3), and observeTaskResult to emit a single emergency on sustained failures and a single recovery line on first success. Hook observation into initial and periodic task runs.

Update auth service to record emergencies when token persistence fails or agent-login rejects stored credentials, and when agent-login succeeds but tokens fail to persist.

Add tests for emergencylog (format, sanitization, concurrency, pruning, init failure) and for scheduler observeTaskResult behavior.
@Warhammer4000 Warhammer4000 enabled auto-merge June 15, 2026 18:31
line := fmt.Sprintf("%s EMERGENCY [%s] %s\n", now.Format(time.RFC3339), category, msg)
path := filepath.Join(dir, "emergency-"+day+".log")

f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) //nolint:gosec // diagnostics file, readable by operators; carries no secrets
line := fmt.Sprintf("%s EMERGENCY [%s] %s\n", now.Format(time.RFC3339), category, msg)
path := filepath.Join(dir, "emergency-"+day+".log")

f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) //nolint:gosec // diagnostics file, readable by operators; carries no secrets
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
65.4% Coverage on New Code (required ≥ 70%)

See analysis details on SonarQube Cloud

@Warhammer4000 Warhammer4000 merged commit b544d49 into main Jun 15, 2026
21 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants