Class: RuboCop::Cop::Gemspec::RequireMFA
- Extended by:
- AutoCorrector
- Includes:
- RuboCop::Cop::GemspecHelp
- Defined in:
- lib/rubocop/cop/gemspec/require_mfa.rb
Overview
Requires a gemspec to have ‘rubygems_mfa_required` metadata set.
This setting tells RubyGems that MFA (Multi-Factor Authentication) is required for accounts to be able perform privileged operations, such as (see RubyGems’ documentation for the full list of privileged operations):
-
‘gem push`
-
‘gem yank`
-
‘gem owner –add/remove`
-
adding or removing owners using gem ownership page
This helps make your gem more secure, as users can be more confident that gem updates were pushed by maintainers.
Constant Summary collapse
- MSG =
"`metadata['rubygems_mfa_required']` must be set to `'true'`."
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #metadata(node) ⇒ Object
-
#on_block(node) ⇒ Object
rubocop:disable Metrics/MethodLength, InternalAffairs/NumblockHandler.
- #rubygems_mfa_required(node) ⇒ Object
- #true_string?(node) ⇒ Object
Methods included from AutoCorrector
Methods included from RuboCop::Cop::GemspecHelp
#gem_specification, #gem_specification?
Methods inherited from Base
#active_support_extensions_enabled?, #add_global_offense, #add_offense, #always_autocorrect?, autocorrect_incompatible_with, badge, #begin_investigation, #callbacks_needed, callbacks_needed, #config_to_allow_offenses, #config_to_allow_offenses=, #contextual_autocorrect?, #cop_config, cop_name, #cop_name, department, documentation_url, exclude_from_registry, #excluded_file?, #external_dependency_checksum, inherited, #initialize, #inspect, joining_forces, lint?, match?, #message, #offenses, #on_investigation_end, #on_new_investigation, #on_other_file, #parse, #parser_engine, #ready, #relevant_file?, requires_gem, #string_literals_frozen_by_default?, support_autocorrect?, support_multiple_source?, #target_rails_version, #target_ruby_version
Methods included from ExcludeLimit
Methods included from AutocorrectLogic
#autocorrect?, #autocorrect_enabled?, #autocorrect_requested?, #autocorrect_with_disable_uncorrectable?, #correctable?, #disable_uncorrectable?, #safe_autocorrect?
Methods included from IgnoredNode
#ignore_node, #ignored_node?, #part_of_ignored_node?
Methods included from Util
Constructor Details
This class inherits a constructor from RuboCop::Cop::Base
Instance Method Details
#metadata(node) ⇒ Object
70 71 72 73 74 75 |
# File 'lib/rubocop/cop/gemspec/require_mfa.rb', line 70 def_node_matcher :metadata, <<~PATTERN `{ (send _ :metadata= $_) (send (send _ :metadata) :[]= (str "rubygems_mfa_required") $_) } PATTERN |
#on_block(node) ⇒ Object
rubocop:disable Metrics/MethodLength, InternalAffairs/NumblockHandler
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rubocop/cop/gemspec/require_mfa.rb', line 87 def on_block(node) # rubocop:disable Metrics/MethodLength, InternalAffairs/NumblockHandler gem_specification(node) do |block_var| = (node) mfa_value = mfa_value() if mfa_value unless true_string?(mfa_value) add_offense(mfa_value) do |corrector| change_value(corrector, mfa_value) end end else add_offense(node) do |corrector| autocorrect(corrector, node, block_var, ) end end end end |
#rubygems_mfa_required(node) ⇒ Object
78 79 80 |
# File 'lib/rubocop/cop/gemspec/require_mfa.rb', line 78 def_node_search :rubygems_mfa_required, <<~PATTERN (pair (str "rubygems_mfa_required") $_) PATTERN |
#true_string?(node) ⇒ Object
83 84 85 |
# File 'lib/rubocop/cop/gemspec/require_mfa.rb', line 83 def_node_matcher :true_string?, <<~PATTERN (str "true") PATTERN |