Class: RuboCop::Cop::Chef::Sharing::InsecureCookbookURL
- Extended by:
- AutoCorrector
- Defined in:
- lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb
Overview
Use secure Github and Gitlab URLs for source_url and issues_url
Constant Summary collapse
- MSG =
'Insecure http Github or Gitlab URLs for metadata source_url/issues_url fields'
- RESTRICT_ON_SEND =
[:source_url, :issues_url].freeze
Instance Method Summary collapse
Methods inherited from Base
Instance Method Details
#insecure_url?(url) ⇒ Boolean
46 47 48 49 |
# File 'lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb', line 46 def insecure_url?(url) # https://rubular.com/r/dS6L6bQZvwWxWq url.match?(%r{http://(www.)*git(hub|lab)}) end |
#on_send(node) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/rubocop/cop/chef/sharing/insecure_cookbook_url.rb', line 51 def on_send(node) insecure_cb_url?(node) do add_offense(node, severity: :refactor) do |corrector| corrector.replace(node, node.source.gsub(%r{http://(www.)*}, 'https://')) end end end |