Class: UploaderFinder

Inherits:
Object
  • Object
show all
Defined in:
app/finders/uploader_finder.rb

Instance Method Summary collapse

Constructor Details

#initialize(container, secret, file_path) ⇒ UploaderFinder

Instantiates a new FileUploader or NamespaceFileUploader based on container type FileUploader can be opened via .open agnostic of storage type Arguments correspond to Upload.secret, Upload.model_type and Upload.file_path Returns a FileUploader with uploaded file retrieved into the object state

container - project, project namespace or group secret - secret string in path to the file, based on FileUploader::MARKDOWN_PATTERN regex file_path - relative path to the file based on FileUploader::MARKDOWN_PATTERN regex



12
13
14
15
16
# File 'app/finders/uploader_finder.rb', line 12

def initialize(container, secret, file_path)
  @container = container
  @secret = secret
  @file_path = file_path
end

Instance Method Details

#executeObject



18
19
20
21
22
23
24
25
# File 'app/finders/uploader_finder.rb', line 18

def execute
  prevent_path_traversal_attack!
  retrieve_file_state!

  uploader
rescue ::Gitlab::PathTraversal::PathTraversalAttackError
  nil # no-op if for incorrect files
end