<commit_before>module SalesforceArSync
  class SoapMessageController < ::ApplicationController
    before_filter :validate_ip_ranges
    
    def sync_object
      delayed_soap_handler SalesforceArSync::SoapHandler::Base
    end

    def delete
      delayed_soap_handler SalesforceArSync::SoapHandler::Delete
    end

    private

    def delayed_soap_handler (klass, priority = 90)
      begin
        soap_handler = klass.new(SalesforceArSync.config["ORGANIZATION_ID"], params)
        soap_handler.process_notifications(priority) if soap_handler.sobjects
        render :xml => soap_handler.generate_response, :status => :created
      rescue Exception => ex
        render :xml => soap_handler.generate_response(ex), :status => :created
      end
    end

    # to be used in a before_filter, checks ip ranges specified in configuration
    # and renders a 404 unless the request matches
    def validate_ip_ranges
      raise ActionController::RoutingError.new('Not Found') unless SalesforceArSync::IPConstraint.new.matches?(request)
    end
  end
end<commit_msg>Added protect_from_forgery setting in the Soap Controller to allow funcationallity to continue to work in Rails 4.2.1<commit_after>module SalesforceArSync
  class SoapMessageController < ::ApplicationController

    protect_from_forgery with: :null_session
    before_filter :validate_ip_ranges

    def sync_object
      delayed_soap_handler SalesforceArSync::SoapHandler::Base
    end

    def delete
      delayed_soap_handler SalesforceArSync::SoapHandler::Delete
    end

    private

    def delayed_soap_handler (klass, priority = 90)
      begin
        soap_handler = klass.new(SalesforceArSync.config["ORGANIZATION_ID"], params)
        soap_handler.process_notifications(priority) if soap_handler.sobjects
        render :xml => soap_handler.generate_response, :status => :created
      rescue Exception => ex
        render :xml => soap_handler.generate_response(ex), :status => :created
      end
    end

    # to be used in a before_filter, checks ip ranges specified in configuration
    # and renders a 404 unless the request matches
    def validate_ip_ranges
      raise ActionController::RoutingError.new('Not Found') unless SalesforceArSync::IPConstraint.new.matches?(request)
    end
  end
end
{'fraction_non_alphanumeric': 0.0647985989492119, 'fraction_numerical': 0.005691768826619965, 'mean_word_length': 3.892933618843683, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3748819', 'n_tokens_mistral': 634, 'n_tokens_neox': 621, 'n_words': 168}