Class: Dependabot::UpdateCheckers::Base
- Inherits:
-
Object
- Object
- Dependabot::UpdateCheckers::Base
- Defined in:
- lib/dependabot/update_checkers/base.rb
Instance Attribute Summary collapse
-
#credentials ⇒ Object
readonly
Returns the value of attribute credentials.
-
#dependency ⇒ Object
readonly
Returns the value of attribute dependency.
-
#dependency_files ⇒ Object
readonly
Returns the value of attribute dependency_files.
-
#dependency_group ⇒ Object
readonly
Returns the value of attribute dependency_group.
-
#ignored_versions ⇒ Object
readonly
Returns the value of attribute ignored_versions.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#raise_on_ignored ⇒ Object
readonly
Returns the value of attribute raise_on_ignored.
-
#repo_contents_path ⇒ Object
readonly
Returns the value of attribute repo_contents_path.
-
#requirements_update_strategy ⇒ Object
readonly
Returns the value of attribute requirements_update_strategy.
-
#security_advisories ⇒ Object
readonly
Returns the value of attribute security_advisories.
Instance Method Summary collapse
- #can_update?(requirements_to_unlock:) ⇒ Boolean
-
#conflicting_dependencies ⇒ Array<Hash{String => String}] name [String] the blocking dependencies name version [String] the version of the blocking dependency requirement [String] the requirement on the target_dependency
Finds any dependencies in the lockfile that have a subdependency on the given dependency that do not satisfy the target_version.
- #ignore_requirements ⇒ Object
-
#initialize(dependency:, dependency_files:, repo_contents_path: nil, credentials:, ignored_versions: [], raise_on_ignored: false, security_advisories: [], requirements_update_strategy: nil, dependency_group: nil, options: {}) ⇒ Base
constructor
A new instance of Base.
- #latest_resolvable_previous_version(_updated_version) ⇒ Object
- #latest_resolvable_version ⇒ Object
- #latest_resolvable_version_with_no_unlock ⇒ Object
- #latest_version ⇒ Object
- #lowest_resolvable_security_fix_version ⇒ Object
-
#lowest_security_fix_version ⇒ Dependabot::<package manager>::Version, #to_s
Lowest available security fix version not checking resolvability.
- #preferred_resolvable_version ⇒ Object
- #requirement_class ⇒ Object
-
#requirements_unlocked_or_can_be? ⇒ Boolean
For some languages, the manifest file may be constructed such that Dependabot has no way to update it (e.g., if it fetches its versions from a web API).
- #up_to_date? ⇒ Boolean
- #updated_dependencies(requirements_to_unlock:) ⇒ Object
- #updated_requirements ⇒ Object
- #version_class ⇒ Object
- #vulnerable? ⇒ Boolean
Constructor Details
#initialize(dependency:, dependency_files:, repo_contents_path: nil, credentials:, ignored_versions: [], raise_on_ignored: false, security_advisories: [], requirements_update_strategy: nil, dependency_group: nil, options: {}) ⇒ Base
Returns a new instance of Base.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/dependabot/update_checkers/base.rb', line 16 def initialize(dependency:, dependency_files:, repo_contents_path: nil, credentials:, ignored_versions: [], raise_on_ignored: false, security_advisories: [], requirements_update_strategy: nil, dependency_group: nil, options: {}) @dependency = dependency @dependency_files = dependency_files @repo_contents_path = repo_contents_path @credentials = credentials @requirements_update_strategy = requirements_update_strategy @ignored_versions = ignored_versions @raise_on_ignored = raise_on_ignored @security_advisories = security_advisories @dependency_group = dependency_group @options = end |
Instance Attribute Details
#credentials ⇒ Object (readonly)
Returns the value of attribute credentials.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def credentials @credentials end |
#dependency ⇒ Object (readonly)
Returns the value of attribute dependency.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def dependency @dependency end |
#dependency_files ⇒ Object (readonly)
Returns the value of attribute dependency_files.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def dependency_files @dependency_files end |
#dependency_group ⇒ Object (readonly)
Returns the value of attribute dependency_group.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def dependency_group @dependency_group end |
#ignored_versions ⇒ Object (readonly)
Returns the value of attribute ignored_versions.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def ignored_versions @ignored_versions end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def @options end |
#raise_on_ignored ⇒ Object (readonly)
Returns the value of attribute raise_on_ignored.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def raise_on_ignored @raise_on_ignored end |
#repo_contents_path ⇒ Object (readonly)
Returns the value of attribute repo_contents_path.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def repo_contents_path @repo_contents_path end |
#requirements_update_strategy ⇒ Object (readonly)
Returns the value of attribute requirements_update_strategy.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def requirements_update_strategy @requirements_update_strategy end |
#security_advisories ⇒ Object (readonly)
Returns the value of attribute security_advisories.
11 12 13 |
# File 'lib/dependabot/update_checkers/base.rb', line 11 def security_advisories @security_advisories end |
Instance Method Details
#can_update?(requirements_to_unlock:) ⇒ Boolean
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dependabot/update_checkers/base.rb', line 41 def can_update?(requirements_to_unlock:) # Can't update if all versions are being ignored return false if ignore_requirements.include?(requirement_class.new(">= 0")) if dependency.version version_can_update?(requirements_to_unlock: requirements_to_unlock) else # TODO: Handle full unlock updates for dependencies without a lockfile return false if requirements_to_unlock == :none requirements_can_update? end end |
#conflicting_dependencies ⇒ Array<Hash{String => String}] name [String] the blocking dependencies name version [String] the version of the blocking dependency requirement [String] the requirement on the target_dependency
Finds any dependencies in the lockfile that have a subdependency on the given dependency that do not satisfy the target_version.
105 106 107 |
# File 'lib/dependabot/update_checkers/base.rb', line 105 def conflicting_dependencies [] # return an empty array for ecosystems that don't support this yet end |
#ignore_requirements ⇒ Object
145 146 147 |
# File 'lib/dependabot/update_checkers/base.rb', line 145 def ignore_requirements ignored_versions.flat_map { |req| requirement_class.requirements_array(req) } end |
#latest_resolvable_previous_version(_updated_version) ⇒ Object
109 110 111 |
# File 'lib/dependabot/update_checkers/base.rb', line 109 def latest_resolvable_previous_version(_updated_version) dependency.version end |
#latest_resolvable_version ⇒ Object
81 82 83 |
# File 'lib/dependabot/update_checkers/base.rb', line 81 def latest_resolvable_version raise NotImplementedError end |
#latest_resolvable_version_with_no_unlock ⇒ Object
95 96 97 |
# File 'lib/dependabot/update_checkers/base.rb', line 95 def latest_resolvable_version_with_no_unlock raise NotImplementedError end |
#latest_version ⇒ Object
66 67 68 |
# File 'lib/dependabot/update_checkers/base.rb', line 66 def latest_version raise NotImplementedError end |
#lowest_resolvable_security_fix_version ⇒ Object
91 92 93 |
# File 'lib/dependabot/update_checkers/base.rb', line 91 def lowest_resolvable_security_fix_version raise NotImplementedError end |
#lowest_security_fix_version ⇒ Dependabot::<package manager>::Version, #to_s
Lowest available security fix version not checking resolvability
87 88 89 |
# File 'lib/dependabot/update_checkers/base.rb', line 87 def lowest_security_fix_version raise NotImplementedError end |
#preferred_resolvable_version ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/dependabot/update_checkers/base.rb', line 70 def preferred_resolvable_version # If this dependency is vulnerable, prefer trying to update to the # lowest_resolvable_security_fix_version. Otherwise update all the way # to the latest_resolvable_version. return lowest_resolvable_security_fix_version if vulnerable? latest_resolvable_version rescue NotImplementedError latest_resolvable_version end |
#requirement_class ⇒ Object
121 122 123 |
# File 'lib/dependabot/update_checkers/base.rb', line 121 def requirement_class dependency.requirement_class end |
#requirements_unlocked_or_can_be? ⇒ Boolean
For some languages, the manifest file may be constructed such that Dependabot has no way to update it (e.g., if it fetches its versions from a web API). This method is overridden in those cases.
128 129 130 |
# File 'lib/dependabot/update_checkers/base.rb', line 128 def requirements_unlocked_or_can_be? true end |
#up_to_date? ⇒ Boolean
33 34 35 36 37 38 39 |
# File 'lib/dependabot/update_checkers/base.rb', line 33 def up_to_date? if dependency.version version_up_to_date? else requirements_up_to_date? end end |
#updated_dependencies(requirements_to_unlock:) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dependabot/update_checkers/base.rb', line 55 def updated_dependencies(requirements_to_unlock:) return [] unless can_update?(requirements_to_unlock: requirements_to_unlock) case requirements_to_unlock&.to_sym when :none then [updated_dependency_without_unlock] when :own then [updated_dependency_with_own_req_unlock] when :all then updated_dependencies_after_full_unlock else raise "Unknown unlock level '#{requirements_to_unlock}'" end end |
#updated_requirements ⇒ Object
113 114 115 |
# File 'lib/dependabot/update_checkers/base.rb', line 113 def updated_requirements raise NotImplementedError end |
#version_class ⇒ Object
117 118 119 |
# File 'lib/dependabot/update_checkers/base.rb', line 117 def version_class dependency.version_class end |
#vulnerable? ⇒ Boolean
132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/dependabot/update_checkers/base.rb', line 132 def vulnerable? return false if security_advisories.none? # Can't (currently) detect whether dependencies without a version # (i.e., for repos without a lockfile) are vulnerable return false unless dependency.version # Can't (currently) detect whether git dependencies are vulnerable return false if existing_version_is_sha? active_advisories.any? end |