Class: Gitlab::Search::AbuseDetection

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations, AbuseValidators
Defined in:
lib/gitlab/search/abuse_detection.rb

Constant Summary collapse

MAX_PIPE_SYNTAX_FILTERS =
5
ABUSIVE_TERM_SIZE =
100
ALLOWED_CHARS_REGEX =
%r{\A[[:alnum:]_\-\+\/\.!]+\z}
ALLOWED_SCOPES =
%w[
  blobs
  code
  commits
  epics
  issues
  merge_requests
  milestones
  notes
  projects
  snippet_titles
  users
  wiki_blobs
].freeze
READABLE_PARAMS =
%i[
  group_id
  project_id
  project_ref
  query_string
  repository_ref
  scope
].freeze
STOP_WORDS =
%w[
  a an and are as at be but by for if in into is it no not of on or such that the their then there these they this to was will with
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, detect_abusive_pipes: true) ⇒ AbuseDetection

Returns a new instance of AbuseDetection.



66
67
68
69
70
71
72
73
# File 'lib/gitlab/search/abuse_detection.rb', line 66

def initialize(params, detect_abusive_pipes: true)
  @raw_params = {}
  READABLE_PARAMS.each do |p|
    instance_variable_set("@#{p}", params[p])
    @raw_params[p] = params[p]
  end
  @detect_abusive_pipes = detect_abusive_pipes
end

Instance Attribute Details

#detect_abusive_pipesObject (readonly)

Returns the value of attribute detect_abusive_pipes.



64
65
66
# File 'lib/gitlab/search/abuse_detection.rb', line 64

def detect_abusive_pipes
  @detect_abusive_pipes
end

#raw_paramsObject (readonly)

Returns the value of attribute raw_params.



64
65
66
# File 'lib/gitlab/search/abuse_detection.rb', line 64

def raw_params
  @raw_params
end