Class: Dependabot::Python::PoetryPluginInstaller

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/python/poetry_plugin_installer.rb

Constant Summary collapse

VALID_PLUGIN_NAME =

Only allow valid PyPI package names to prevent command injection

/\A[a-zA-Z0-9]([a-zA-Z0-9._-]*[a-zA-Z0-9])?\z/
VALID_CONSTRAINT =

Only allow valid version constraint characters to prevent command injection

/\A[a-zA-Z0-9.*,!=<>~^ ]+\z/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pyproject_content:) ⇒ PoetryPluginInstaller

Returns a new instance of PoetryPluginInstaller.



29
30
31
32
# File 'lib/dependabot/python/poetry_plugin_installer.rb', line 29

def initialize(pyproject_content:)
  @pyproject_content = T.let(pyproject_content, T.nilable(String))
  @plugins_installed = T.let(false, T::Boolean)
end

Class Method Details

.from_dependency_files(dependency_files) ⇒ Object



23
24
25
26
# File 'lib/dependabot/python/poetry_plugin_installer.rb', line 23

def self.from_dependency_files(dependency_files)
  pyproject_content = dependency_files.find { |f| f.name == "pyproject.toml" }&.content
  new(pyproject_content: pyproject_content)
end

Instance Method Details

#install_required_pluginsObject



35
36
37
38
39
40
41
42
43
# File 'lib/dependabot/python/poetry_plugin_installer.rb', line 35

def install_required_plugins
  return if @plugins_installed

  required_plugins.each do |name, constraint|
    install_plugin(name, constraint)
  end

  @plugins_installed = true
end