Sha256: adbe316404469c1794c1271957cf719cf95c2b5490e869a59af0981ac55e5e0d

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require 'thor'
require 'paraxial/engine'
require 'rubocop'
require_relative 'rubocop/cop/paraxial/csrf'
require_relative 'rubocop/cop/paraxial/system'
require_relative 'rubocop/cop/paraxial/send'
require_relative 'rubocop/cop/paraxial/constantize'
require_relative 'rubocop/cop/paraxial/html_safe'
require_relative 'rubocop/cop/paraxial/sql'
require_relative 'paraxial/version'
require_relative 'paraxial/cli'

module Paraxial
  class Error < StandardError; end
  # Your code goes here...

  class Defense
    def initialize(app)
      @app = app
    end

    def call(env)
      request_path = env['PATH_INFO']

      if request_path.end_with?('.php')
        # Return a 404 response if the request path ends with '.php'
        [404, { 'Content-Type' => 'text/plain' }, ['Not Found from Paraxial.io']]
      else
        # Pass the request to the next middleware or the application
        @app.call(env)
      end
    end
  end

  def self.get_timestamp
    utc_time = Time.now.utc
    utc_time.strftime('%Y-%m-%d %H:%M:%S.%6N') + 'Z'
  end

  def self.cloud_ip?(ip)
    !!(PARAXIAL_IPV4.search_best(ip) or PARAXIAL_IPV6.search_best(ip))
  end

  def self.ban_ip(ip)
    Paraxial::Checker.ban_ip(ip)
  end

  def self.allow_ip?(ip)
    Paraxial::Checker.allow_ip?(ip)
  end

  def self.trim_dep(input)
    if input.nil?
      nil
    else
      cleaned_string = input.gsub(/\n/, '')

      # Find the position of the first period
      period_index = cleaned_string.index('.')

      # If there's a period, truncate the string up to that point
      cleaned_string = cleaned_string[0..period_index] if period_index

      cleaned_string
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
paraxial-0.4.0 lib/paraxial.rb