From 4c35f1dbbe9c2d43debb2932cc5d6119ad378f0a Mon Sep 17 00:00:00 2001 From: Stephen Paul Weber Date: Mon, 20 May 2024 14:58:22 -0500 Subject: [PATCH] Pass stanzas from any trusted backend --- sgx_jmp.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sgx_jmp.rb b/sgx_jmp.rb index 1d8cc74da8dc8e89b50ebc1038bb379822b883a9..e05e441caf074c5c9146fb276f5f5c1628bc3bf2 100644 --- a/sgx_jmp.rb +++ b/sgx_jmp.rb @@ -254,11 +254,15 @@ message to: /\Aaccount@/, body: /./ do |m| } end +FROM_BACKEND = + "(?:#{([CONFIG[:sgx]] + CONFIG[:sgx_creds].keys) + .map(&Regexp.method(:escape)).join('|')})" + before( :iq, type: [:error, :result], to: /\Acustomer_/, - from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ + from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/ ) { |iq| halt if IQ_MANAGER.fulfill(iq) } SPAM_ERRS = [ @@ -267,7 +271,7 @@ SPAM_ERRS = [ "destination-rejected-due-to-spam-detection" ].freeze -before nil, to: /\Acustomer_/, from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ do |s| +before nil, to: /\Acustomer_/, from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/ do |s| StatsD.increment("stanza_customer") Sentry.get_current_scope.set_transaction_name("stanza_customer") @@ -299,7 +303,7 @@ end ADDRESSES_NS = "http://jabber.org/protocol/address" message( to: /\A#{CONFIG[:component][:jid]}\Z/, - from: /(\A|@)#{CONFIG[:sgx]}(\/|\Z)/ + from: /(\A|@)#{FROM_BACKEND}(\/|\Z)/ ) do |m| StatsD.increment("inbound_group_text") Sentry.get_current_scope.set_transaction_name("inbound_group_text")