<commit_before># encoding: utf-8

require 'active_support/concern'

module ApiSearchable
  extend ActiveSupport::Concern

  def search_query
    params.permit(:q)[:q]
  end

  def search_params
    params.permit(:page, :size, :sort, fields: {}, fq: searchable_fields).to_h
  end

  def searchable_fields
    []
  end
end<commit_msg>Do not allow arbitrary fields to be searched<commit_after># encoding: utf-8

require 'active_support/concern'

module ApiSearchable
  extend ActiveSupport::Concern

  def search_query
    params.permit(:q)[:q]
  end

  def search_params
    params.permit(:page, :size, :sort, fq: searchable_fields).to_h
  end

  def searchable_fields
    []
  end
end
{'fraction_non_alphanumeric': 0.09663250366032211, 'fraction_numerical': 0.0029282576866764276, 'mean_word_length': 4.181818181818182, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1202958', 'n_tokens_mistral': 239, 'n_tokens_neox': 232, 'n_words': 57}