Repository navigation
Schedule background tasks before sending start event #391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -45,21 +45,20 @@ public void run() { | |
| ReportingApiHTTP api = new ReportingApiHTTP(getAikidoAPIEndpoint(token), API_TIMEOUT, EVENTS_API_TIMEOUT, token); | ||
| RealtimeAPI realtimeApi = new RealtimeAPI(token); | ||
|
|
||
| // make api calls on start | ||
| Optional<APIResponse> res = api.report(Started.get()); | ||
| res.ifPresent(ServiceConfigStore::updateFromAPIResponse); | ||
| // Fetch blocked lists using separate API call | ||
| Optional<ReportingApi.APIListsResponse> listsRes = api.fetchBlockedLists(); | ||
| listsRes.ifPresent(ServiceConfigStore::updateFromAPIListsResponse); | ||
|
|
||
|
|
||
| // Schedule tasks using ScheduledExecutorService | ||
| scheduler.scheduleAtFixedRate(new RealtimeTask(realtimeApi, api), POLLING_INTERVAL_SECONDS, POLLING_INTERVAL_SECONDS, TimeUnit.SECONDS); | ||
| scheduler.scheduleAtFixedRate(new AttackQueueConsumerTask(api), 0, 2, TimeUnit.SECONDS); | ||
|
|
||
| // Start heartbeats | ||
| scheduler.schedule(createHeartbeatTask(api, scheduler, true), FIRST_HEARTBEAT_INTERVAL_SECONDS, TimeUnit.SECONDS); | ||
|
|
||
| // make api calls on start, slow responses should not delay the tasks above | ||
| Optional<APIResponse> res = api.report(Started.get()); | ||
| res.ifPresent(ServiceConfigStore::updateFromAPIResponse); | ||
| // Fetch blocked lists using separate API call | ||
| Optional<ReportingApi.APIListsResponse> listsRes = api.fetchBlockedLists(); | ||
| listsRes.ifPresent(ServiceConfigStore::updateFromAPIListsResponse); | ||
|
Comment on lines
+56
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 High - Concurrent startup refreshes can overwrite newer blocking rules When the startup event or list request takes longer than the newly scheduled 30/60-second tasks, HeartbeatTask or RealtimeTask can fetch a newer configuration while the original startup responses are still in flight. The startup responses are then applied without version checks, and a late list response replaces the entire list set, so newly enabled IP/UA blocks or blocking mode can be reverted and matching requests or attacks can pass until a later refresh. Show fixKeep startup fetches serialized ahead of scheduled refreshes, or make configuration and list updates version-aware so an older response cannot replace a newer snapshot. Do not let the initial list response clear newer rules based solely on arrival order. More info - Reply on this comment to give feedback or ignore the issue. |
||
|
|
||
| if (token != null) { | ||
| if (FeatureFlags.AIKIDO_FEATURE_SSE.isEnabled() || ServiceConfigStore.isRealtimeUpdatesEnabled()) { | ||
| new RealtimeSSETask(new RealtimeSSEAPI(token), api).start(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment that blocked lists use a separate API call restates
api.fetchBlockedLists()without adding context.Details
✨ AI Reasoning
The comment repeats what the adjacent
api.fetchBlockedLists()call already shows and gives no reason for making it a separate call. The other added comment explains that slow responses should not delay scheduled tasks, so it provides rationale.Reply on this comment to give feedback or ignore the issue.
More info