Sha256: 0a60bca5698971c99d478ae2030d08df2c91b171344641033323e37de382df09

Contents?: true

Size: 892 Bytes

Versions: 39

Compression:

Stored size: 892 Bytes

Contents

# typed: ignore

# 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 AuthTrackCB < RuleCB
      def initialize(*args)
        super(*args)
        @overtimeable = false
      end

      def pre(_instance, args, _budget)
        success, authentication_keys = args
        ip = framework.client_ip
        category = success ? 'sdk-login-success' : 'sdk-login-fail'

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

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

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

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
sqreen-1.25.1 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.25.0 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.24.3 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.24.2 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.24.1 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.24.0 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.23.2 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.23.1 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.23.0 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.22.1 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.22.0-java lib/sqreen/rules/auth_track_cb.rb
sqreen-1.22.0 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.1-java lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.1 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.0-java lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.0 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.20.4-java lib/sqreen/rules/auth_track_cb.rb
sqreen-1.20.4 lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.0.beta3-java lib/sqreen/rules/auth_track_cb.rb
sqreen-1.21.0.beta3 lib/sqreen/rules/auth_track_cb.rb