fix: per-asset alert index, webhook probe retries, SSRF check before probe, atomic recipient SADD - #428
Merged
Conversation
…probe, atomic recipient SADD - alerts.js: evaluateForAssetInner now looks up alerts via a per-asset Redis set index (alerts:asset:<ASSET>) instead of ZREVRANGE-ing and fetching every alert in the system on every price tick. Index is kept in sync by create()/remove(); a backfillAssetIndex() helper is exported for one-time backfill against existing deployments. Closes SmartDropLabs#310. - webhook.js: probeReachability retries a transient network failure (ECONNRESET/ETIMEDOUT/ECONNABORTED/ECONNREFUSED/ENETUNREACH/ EHOSTUNREACH/EAI_AGAIN) up to WEBHOOK_PROBE_RETRY_ATTEMPTS times per method before giving up; HTTP error responses are never retried since they're a real answer, not a transient failure. Closes SmartDropLabs#311. - routes/webhooks.js: POST /webhooks now runs the same assertPublicTarget SSRF guard used at delivery/test time *before* calling probeReachability, which previously made an outbound request to a completely unvalidated caller-supplied URL (webhookRepo.create()'s own URL validation only ran after the probe had already fired). Closes SmartDropLabs#313. - airdrops.js: addRecipients() queues its per-address SADD calls on a single MULTI/EXEC instead of Promise.all-ing N independent commands, so two concurrent addRecipients() calls for the same airdrop can no longer interleave and both observe "newly added" for the same address. Closes SmartDropLabs#312.
|
@Big-JoshCode Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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
evaluateForAssetInnernow looks up alerts via a per-asset Redis set index (alerts:asset:<ASSET>) instead ofZREVRANGE-ing and fetching every alert in the system on every price tick. The index is kept in sync bycreate()/remove(); abackfillAssetIndex()helper is exported for a one-time backfill against existing deployments (alerts created before this change won't be in the index until backfilled or re-created).probeReachabilitynow retries a transient network failure (ECONNRESET/ETIMEDOUT/ECONNABORTED/ECONNREFUSED/ENETUNREACH/EHOSTUNREACH/EAI_AGAIN) up toWEBHOOK_PROBE_RETRY_ATTEMPTS(default 2) times per method before giving up. HTTP error responses (4xx/5xx) are never retried — they're a real answer from the target, not a transient failure.POST /webhooksnow runs the sameassertPublicTargetSSRF guard already used at delivery/test time before callingprobeReachability. Previously the probe made an outbound HTTP request to a completely unvalidated caller-supplied URL —webhookRepo.create()'s own URL/SSRF validation only ran after the probe had already fired, making the probe itself usable as an SSRF oracle against internal/private targets.addRecipients()now queues its per-addressSADDcalls on a singleMULTI/EXECinstead ofPromise.all-ing N independent commands. The independent calls could interleave with another concurrentaddRecipients()call on the same airdrop, so two overlapping requests for the same address could each observe "newly added" and both append it to the recipients list.Closes #310,
Closes #311,
Closes #313,
Closes #312.
Test plan
evaluateForAsset('XLM', price)only touchesalerts:asset:XLMmembers, not the fullalerts:idssetprobeReachabilityagainst a target that resets the connection on the first attempt but succeeds on retryPOST /webhookswith a URL resolving to a private/internal address is rejected before any outbound probe request is madePOST /airdrops/:id/recipientscalls with an overlapping address set never both report the address as newly added