Class: RuboCop::Cop::Chef::ChefCorrectness::InsecureCookbookURL
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Chef::ChefCorrectness::InsecureCookbookURL
- Defined in:
- lib/rubocop/cop/chef/correctness/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'.freeze
Instance Method Summary collapse
Instance Method Details
#autocorrect(node) ⇒ Object
53 54 55 56 57 |
# File 'lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb', line 53 def autocorrect(node) lambda do |corrector| corrector.replace(node.loc.expression, node.source.gsub(%r{http://(www.)*}, 'https://')) end end |
#insecure_url?(url) ⇒ Boolean
42 43 44 45 |
# File 'lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb', line 42 def insecure_url?(url) # https://rubular.com/r/dS6L6bQZvwWxWq url.match?(%r{http://(www.)*git(hub|lab)}) end |
#on_send(node) ⇒ Object
47 48 49 50 51 |
# File 'lib/rubocop/cop/chef/correctness/insecure_cookbook_url.rb', line 47 def on_send(node) insecure_cb_url?(node) do add_offense(node, location: :expression, message: MSG, severity: :refactor) end end |