Class: Dependabot::Hex::FileUpdater::MixfileSanitizer

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/hex/file_updater/mixfile_sanitizer.rb

Constant Summary collapse

FILE_READ =
/File.read\(.*?\)/
FILE_READ_BANG =
/File.read!\(.*?\)/
PIPE =
T.let(Regexp.escape("|>").freeze, String)
VERSION_FILE =
/"VERSION"/i
NESTED_VERSION_FILE_READ =
/String\.trim\(#{FILE_READ}\)/
NESTED_VERSION_FILE_READ_BANG =
/String\.trim\(#{FILE_READ_BANG}\)/
PIPED_VERSION_FILE_READ =
/#{VERSION_FILE}[[:space:]]+#{PIPE}[[:space:]]+#{FILE_READ}/
PIPED_VERSION_FILE_READ_BANG =
/#{VERSION_FILE}[[:space:]]+#{PIPE}[[:space:]]+#{FILE_READ_BANG}/

Instance Method Summary collapse

Constructor Details

#initialize(mixfile_content:) ⇒ MixfileSanitizer

Returns a new instance of MixfileSanitizer.



14
15
16
# File 'lib/dependabot/hex/file_updater/mixfile_sanitizer.rb', line 14

def initialize(mixfile_content:)
  @mixfile_content = mixfile_content
end

Instance Method Details

#sanitized_contentObject



29
30
31
32
33
# File 'lib/dependabot/hex/file_updater/mixfile_sanitizer.rb', line 29

def sanitized_content
  @mixfile_content
    .then { |content| prevent_version_file_loading(content) }
    .then { |content| prevent_config_path_loading(content) }
end