Dev#28
Merged
Merged
Conversation
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.
| 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 |
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


No description provided.