Sha256: 10fd041976820b79741b16a2ac36464835163e87d0fa9762e7f5618572b9cbe7

Contents?: true

Size: 1.02 KB

Versions: 9

Compression:

Stored size: 1.02 KB

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/rules/attrs'
require 'sqreen/rules/rule_cb'
require 'sqreen/safe_json'

module Sqreen
  module Rules
    class DeviseAuthTrackCB < RuleCB
      def initialize(*args)
        super(*args)
        @overtimeable = false
      end

      def post(_rv, instance, _args, _budget)
        status = instance.instance_variable_get(:@result).to_s
        data = instance.authentication_hash
        keys = instance.send(:authentication_keys)
        ip = framework.client_ip
        category = status == 'failure' ? 'auto-login-fail' : 'auto-login-success'
        data = data.select { |k, _| keys.include?(k) }

        if data.empty?
          Sqreen.log.debug { "#{category} from #{ip} but keys empty" }
          return
        end

        payload = { keys: data.to_a, ip: ip }

        record_observation(category, JSON.dump(payload), 1)
        advise_action(nil)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sqreen-1.18.6-java lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.6 lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.5-java lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.5 lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.4-java lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.4 lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.3-java lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.3 lib/sqreen/rules/devise_auth_track_cb.rb
sqreen-1.18.3.beta2 lib/sqreen/rules/devise_auth_track_cb.rb