Sha256: 68e56550da1918346a6586353cca5652378d847069bb0361ea488e1b94f0b3d0

Contents?: true

Size: 1010 Bytes

Versions: 4

Compression:

Stored size: 1010 Bytes

Contents

# frozen_string_literal: true

module SecureNative
  module Frameworks
    class Sinatra
      SECURENATIVE_COOKIE = '_sn'

      def self.get_client_token(request)
        begin
          request.env[SECURENATIVE_COOKIE]
        rescue StandardError
          begin
            request.cookies[SECURENATIVE_COOKIE]
          rescue StandardError
            nil
          end
        end
      end

      def self.get_url(request)
        begin
          request.env['REQUEST_URI']
        rescue StandardError
          nil
        end
      end

      def self.get_method(request)
        begin
          request.env['REQUEST_METHOD']
        rescue StandardError
          nil
        end
      end

      def self.get_headers(request)
        begin
          # Note: At the moment we're filtering out everything but user-agent since ruby's payload is way too big
          {'user-agent' => request.env['HTTP_USER_AGENT']}
        rescue StandardError
          nil
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
securenative-0.1.33 lib/securenative/frameworks/sinatra.rb
securenative-0.1.32 lib/securenative/frameworks/sinatra.rb
securenative-0.1.31 lib/securenative/frameworks/sinatra.rb
securenative-0.1.30 lib/securenative/frameworks/sinatra.rb