rubocop-discourse 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 241e38fe74159637bc9e21c3076fcf7cc9b423d35f28d8dcb52167a88dce853f
|
|
4
|
+
data.tar.gz: 04a1466202894eced5ab6233fd67badca63ab78e59b7bd6f7d9cdc34d38c7c2f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a63dcb384dadee7ac549e485911f92b6d81ea7934197fea492e331d1ff8c617269ff171ecbc4902927b61d0ebd3c30d66ea9ec91114608e77a7197dda61d7812
|
|
7
|
+
data.tar.gz: fe8fc549c0d959627787086287fa6079f7c4c833640d77925181bbe5c9d6342ab4aee539d2043df6e96c4beded40e4234749fea73cb982e5aa8b476380b321a7
|
data/config/default.yml
CHANGED
|
@@ -18,6 +18,16 @@ Discourse/NoAddReferenceOrAliasesActiveRecordMigration:
|
|
|
18
18
|
Discourse/NoNokogiriHtmlFragment:
|
|
19
19
|
Enabled: true
|
|
20
20
|
|
|
21
|
+
Discourse/NoTlsVerificationBypass:
|
|
22
|
+
Description: "Do not disable TLS certificate or hostname verification."
|
|
23
|
+
Enabled: true
|
|
24
|
+
Exclude:
|
|
25
|
+
- "**/spec/**/*"
|
|
26
|
+
|
|
27
|
+
Discourse/NoNetHttpSettingsInStartBlock:
|
|
28
|
+
Description: "Do not assign connection settings inside the block given to `Net::HTTP.start`."
|
|
29
|
+
Enabled: true
|
|
30
|
+
|
|
21
31
|
Discourse/NoResetColumnInformationInMigrations:
|
|
22
32
|
Enabled: false
|
|
23
33
|
Include:
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Discourse
|
|
6
|
+
class NoNetHttpSettingsInStartBlock < Base
|
|
7
|
+
MSG =
|
|
8
|
+
"`%<setting>s` set inside the `start` block only applies to reconnections. " \
|
|
9
|
+
"Pass it as an option to `start` instead."
|
|
10
|
+
|
|
11
|
+
CONNECTION_SETTINGS = %i[
|
|
12
|
+
ca_file=
|
|
13
|
+
ca_path=
|
|
14
|
+
cert=
|
|
15
|
+
cert_store=
|
|
16
|
+
ciphers=
|
|
17
|
+
extra_chain_cert=
|
|
18
|
+
ipaddr=
|
|
19
|
+
key=
|
|
20
|
+
local_host=
|
|
21
|
+
local_port=
|
|
22
|
+
max_version=
|
|
23
|
+
min_version=
|
|
24
|
+
open_timeout=
|
|
25
|
+
ssl_timeout=
|
|
26
|
+
ssl_version=
|
|
27
|
+
use_ssl=
|
|
28
|
+
verify_callback=
|
|
29
|
+
verify_depth=
|
|
30
|
+
verify_hostname=
|
|
31
|
+
verify_mode=
|
|
32
|
+
].to_set.freeze
|
|
33
|
+
|
|
34
|
+
def_node_matcher :http_start_block, <<~PATTERN
|
|
35
|
+
(block
|
|
36
|
+
(send {(const _ :HTTP) (send (const _ :HTTP) :new ...)} :start ...)
|
|
37
|
+
(args (arg $_) ...)
|
|
38
|
+
$_)
|
|
39
|
+
PATTERN
|
|
40
|
+
|
|
41
|
+
def on_block(node)
|
|
42
|
+
http_start_block(node) do |http, body|
|
|
43
|
+
body&.each_node(:send) do |send_node|
|
|
44
|
+
next if !CONNECTION_SETTINGS.include?(send_node.method_name)
|
|
45
|
+
next if !send_node.receiver&.lvar_type?
|
|
46
|
+
next if send_node.receiver.children.first != http
|
|
47
|
+
|
|
48
|
+
add_offense(
|
|
49
|
+
send_node,
|
|
50
|
+
message: format(MSG, setting: send_node.method_name.to_s.delete_suffix("=")),
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RuboCop
|
|
4
|
+
module Cop
|
|
5
|
+
module Discourse
|
|
6
|
+
class NoTlsVerificationBypass < Base
|
|
7
|
+
MSG = "Do not disable TLS certificate or hostname verification."
|
|
8
|
+
|
|
9
|
+
def_node_matcher :verify_none?, <<~PATTERN
|
|
10
|
+
(const (const (const {nil? cbase} :OpenSSL) :SSL) :VERIFY_NONE)
|
|
11
|
+
PATTERN
|
|
12
|
+
|
|
13
|
+
def_node_matcher :comparison?, <<~PATTERN
|
|
14
|
+
(send _ {:== :!= :equal? :eql?} _)
|
|
15
|
+
PATTERN
|
|
16
|
+
|
|
17
|
+
def_node_matcher :disabling_option?, <<~PATTERN
|
|
18
|
+
(pair (sym {:verify :verify_peer :ssl_verify_peer :verify_hostname}) false)
|
|
19
|
+
PATTERN
|
|
20
|
+
|
|
21
|
+
def_node_matcher :disabling_assignment?, <<~PATTERN
|
|
22
|
+
{
|
|
23
|
+
(send _ :verify_hostname= false)
|
|
24
|
+
(send _ :[]= (sym {:verify :verify_peer :ssl_verify_peer :verify_hostname}) false)
|
|
25
|
+
}
|
|
26
|
+
PATTERN
|
|
27
|
+
|
|
28
|
+
def on_const(node)
|
|
29
|
+
return if !verify_none?(node)
|
|
30
|
+
return if node.parent && comparison?(node.parent)
|
|
31
|
+
|
|
32
|
+
add_offense(node)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def on_pair(node)
|
|
36
|
+
add_offense(node) if disabling_option?(node)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def on_send(node)
|
|
40
|
+
add_offense(node) if disabling_assignment?(node)
|
|
41
|
+
end
|
|
42
|
+
alias on_csend on_send
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-discourse
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Discourse Team
|
|
@@ -180,10 +180,12 @@ files:
|
|
|
180
180
|
- lib/rubocop/cop/discourse/no_json_parse_response.rb
|
|
181
181
|
- lib/rubocop/cop/discourse/no_mixing_multisite_and_standard_specs.rb
|
|
182
182
|
- lib/rubocop/cop/discourse/no_mocking_jobs.rb
|
|
183
|
+
- lib/rubocop/cop/discourse/no_net_http_settings_in_start_block.rb
|
|
183
184
|
- lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb
|
|
184
185
|
- lib/rubocop/cop/discourse/no_reset_column_information_in_migrations.rb
|
|
185
186
|
- lib/rubocop/cop/discourse/no_system_spec_metadata.rb
|
|
186
187
|
- lib/rubocop/cop/discourse/no_time_new_without_args.rb
|
|
188
|
+
- lib/rubocop/cop/discourse/no_tls_verification_bypass.rb
|
|
187
189
|
- lib/rubocop/cop/discourse/no_uri_escape_encode.rb
|
|
188
190
|
- lib/rubocop/cop/discourse/only_top_level_multisite_specs.rb
|
|
189
191
|
- lib/rubocop/cop/discourse/plugins/call_requires_plugin.rb
|