Phase 1 (Critical): - #1 JWT auth (done in v0.1.16) - #2 Batch message size validation in send_message_batch.go - #10 RLock in GetQueueUrlV1 (data race fix) Phase 2 (AWS-compatible limits): - #3 QueueName validation: max 80 chars, [a-zA-Z0-9_-](.fifo)? - #4 WaitTimeSeconds clamped to 0-20 - #5 ReceiveMessageWaitTimeSeconds clamped to 0-20 - #6 DelaySeconds clamped to 0-900 - #7 VisibilityTimeout clamped to 0-43200 - #8 MaxNumberOfMessages clamped to 1-10 - #9 Message attributes limited to 10 per message - #15 BatchEntryId length validated (max 80) - #16 DeduplicationID length validated (max 128) - #17 GroupID length validated (max 128) Phase 3 (Per-tenant resource limits): - #11 Max messages per queue (120K standard, 20K FIFO) - #12 Global tenant limit (1000) - #3.5 HTTP request body size limit (1MB via MaxBytesReader) Phase 4 (Stability): - #14 Duplicates map cleanup (already in PeriodicTasks) - #13 FIFO group lock timeout (already in visibility timeout reset) - #18 Redis size guard: skip save if >50MB Skipped (Low, no real risk): - #19 {account} URL param (informational only, not used for access) - #20 ReceiptHandle format (self-validating UUID#UUID) New file: app/gosqs/validation.go — centralized AWS SQS limits and validators
46 lines
1.5 KiB
Go
46 lines
1.5 KiB
Go
package gosqs
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
"shared-sqs/app/models"
|
|
)
|
|
|
|
// TODO - Support:
|
|
// - attr.MessageRetentionPeriod
|
|
// - attr.Policy
|
|
// - attr.RedriveAllowPolicy
|
|
func setQueueAttributesV1(q *models.Queue, attr models.QueueAttributes) error {
|
|
// AWS-совместимые лимиты: clamp значений к допустимым диапазонам
|
|
if attr.DelaySeconds >= 0 {
|
|
q.DelaySeconds = ClampInt(attr.DelaySeconds.Int(), 0, MaxDelaySeconds)
|
|
}
|
|
if attr.MaximumMessageSize >= 0 {
|
|
q.MaximumMessageSize = ClampInt(attr.MaximumMessageSize.Int(), MinMessageSizeLimit, MaxMessageSizeLimit)
|
|
}
|
|
if attr.MessageRetentionPeriod > 0 {
|
|
q.MessageRetentionPeriod = ClampInt(attr.MessageRetentionPeriod.Int(), MinMessageRetentionPeriod, MaxMessageRetentionPeriod)
|
|
}
|
|
if attr.ReceiveMessageWaitTimeSeconds > 0 {
|
|
q.ReceiveMessageWaitTimeSeconds = ClampInt(attr.ReceiveMessageWaitTimeSeconds.Int(), 0, MaxReceiveMessageWaitTimeSeconds)
|
|
}
|
|
if attr.VisibilityTimeout >= 0 {
|
|
q.VisibilityTimeout = ClampInt(attr.VisibilityTimeout.Int(), 0, MaxVisibilityTimeout)
|
|
}
|
|
if attr.RedrivePolicy != (models.RedrivePolicy{}) {
|
|
arnArray := strings.Split(attr.RedrivePolicy.DeadLetterTargetArn, ":")
|
|
queueName := arnArray[len(arnArray)-1]
|
|
deadLetterQueue, ok := models.SyncQueues.Queues[queueName]
|
|
if !ok {
|
|
log.Error("Invalid RedrivePolicy Attribute")
|
|
return fmt.Errorf("InvalidAttributeValue")
|
|
}
|
|
q.DeadLetterQueue = deadLetterQueue
|
|
q.MaxReceiveCount = attr.RedrivePolicy.MaxReceiveCount.Int()
|
|
}
|
|
return nil
|
|
}
|