feat(scan): run a full threat-intel refresh before a manual scan#211
Merged
Conversation
A manual scan now freshens ALL threat intel before scanning, not just the bulk feeds. Previously runScan() only called indicatorUpdater.update() (missing the curated public-repo IOCs, SIGMA rules, and CVEs) and gated it on a 24h staleness check that effectively never fired given the 12h periodic worker — so manual scans ran on stale intel. Changes: - Extract the worker's refresh sequence into a shared @singleton IntelRefresher so the periodic IocUpdateWorker and the pre-scan path run identical logic (no drift). Pruning stays worker-only. - runScan() throttle: 24h -> PRE_SCAN_REFRESH_THROTTLE_MS (1h), anchored on indicatorDao.lastFetchTimeGlobal() instead of a single feed's timestamp (a single-feed failure no longer wedges the throttle on/off). - IntelRefresher.refreshAll() is single-flighted: a caller arriving while a refresh is in flight WAITS for it (so the scan gets fresh data) and then reuses it (skipIfRefreshedWithinMs) instead of re-downloading ~6-8 MB. - Dashboard shows "Updating threat intel…" during the pre-scan refresh so the scan doesn't look hung behind a non-advancing bar. Reviewed by two independent reviewers + a focused concurrency re-review. Verified on-device (SM-F916B, API 33): pre-scan full refresh runs first (450 public-repo IOCs + 24 SIGMA rules + 87 CVEs), scan completes after fresh intel lands, worker/pre-scan race no longer double-downloads, "Updating threat intel…" shows. Unit tests pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Summary
A manual scan now freshens all threat intel before scanning, fixing two latent bugs in the existing pre-scan update:
indicatorUpdater.update()— missing the curated public-repo IOCs, SIGMA rules, and CVEs.Changes
IntelRefresher(@Singleton): the periodicIocUpdateWorkerand the pre-scan path now run identical refresh logic — no drift. Pruning stays worker-only.runScan()now refreshes if intel is older thanPRE_SCAN_REFRESH_THROTTLE_MS(1h), anchored onIndicatorDao.lastFetchTimeGlobal()(a single feed failing no longer wedges the throttle).skipIfRefreshedWithinMs) instead of re-downloading ~6–8 MB. Fixes a worker/pre-scan double-download race.Per discussion: full refresh on any network, 1h throttle (no metered-network special-casing).
Review & verification
reusing, skipping refresh), and "Updating threat intel…" renders.:app:testDebugUnitTestpasses;compileDebugKotlinclean.🤖 Generated with Claude Code