mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(sqs): find ChangeMessageVisibility queues by the account in their URL (#9103)
ChangeMessageVisibility and ChangeMessageVisibilityBatch looked the queue up in the caller's account, so a consumer in another account than the queue's owner got NonExistentQueue, although it could receive and delete with the same URL. They now find the queue by the account in its URL, as receiveMessage and deleteMessage do, which also lets a Lambda SQS mapping in another account return a failed message to the queue. Closes #9102
This commit is contained in:
1 parent
f3c21892a6
commit
5b24eeda35
3 files changed
+135
-6
No files matched your search
@@ -1732,9 +1732,7 @@ public class SqsService implements Resettable, ResourceProvider {
|
||||
private boolean changeMessageVisibility(String queueUrl, String receiptHandle, Instant expectedVisibleAt,
|
||||
int visibilityTimeout, String region, boolean inBatch) {
|
||||
String storageKey = regionKey(region, queueUrl);
|
||||
Queue queue = queueStore.get(storageKey)
|
||||
.orElseThrow(() -> new AwsException("AWS.SimpleQueueService.NonExistentQueue",
|
||||
"The specified queue does not exist.", 400));
|
||||
Queue queue = getQueueByUrl(storageKey, queueUrl).orElseThrow(SqsService::nonExistentQueue);
|
||||
ReceiptHandle handle = checkReceiptHandle(storageKey, receiptHandle, inBatch);
|
||||
|
||||
GuardedMessageQueue messages = getOrCreateQueue(storageKey);
|
||||
@@ -2108,7 +2106,7 @@ public class SqsService implements Resettable, ResourceProvider {
|
||||
|
||||
public List<BatchResultEntry> changeMessageVisibilityBatch(String queueUrl,
|
||||
List<ChangeVisibilityBatchEntry> entries, String region) {
|
||||
ensureQueueExists(regionKey(region, queueUrl));
|
||||
ensureQueueExists(regionKey(region, queueUrl), queueUrl);
|
||||
List<BatchResultEntry> results = new ArrayList<>();
|
||||
for (ChangeVisibilityBatchEntry entry : entries) {
|
||||
try {
|
||||
@@ -2489,11 +2487,22 @@ public class SqsService implements Resettable, ResourceProvider {
|
||||
|
||||
private void ensureQueueExists(String storageKey) {
|
||||
if (queueStore.get(storageKey).isEmpty()) {
|
||||
throw new AwsException("AWS.SimpleQueueService.NonExistentQueue",
|
||||
"The specified queue does not exist.", 400);
|
||||
throw nonExistentQueue();
|
||||
}
|
||||
}
|
||||
|
||||
/** Looks the queue up in the account its URL names, as the message operations do, not the caller's. */
|
||||
private void ensureQueueExists(String storageKey, String queueUrl) {
|
||||
if (getQueueByUrl(storageKey, queueUrl).isEmpty()) {
|
||||
throw nonExistentQueue();
|
||||
}
|
||||
}
|
||||
|
||||
private static AwsException nonExistentQueue() {
|
||||
return new AwsException("AWS.SimpleQueueService.NonExistentQueue",
|
||||
"The specified queue does not exist.", 400);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up a queue by URL, deriving the account from the URL path rather than from request
|
||||
* context. This allows background workers (e.g. pollers) to access queues for any account
|
||||
|
||||
Reference in new issue
Block a user