gitlab-styles 7.0.0 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9fcbcb3937df65b5a6ef170918f4abd96786642c5ba2e379b4f0c3273cd21411
4
- data.tar.gz: dde017a2f0091139175945e0bafd2f0d9c43f2ad280ca9f60c350093fe441dd2
3
+ metadata.gz: bdbe53a3630aedb6f9a4eb87e46ab9becc5b924dbaf2122eca8f8634ffa46d11
4
+ data.tar.gz: 8b64b09817b3d57edec615305e973f9aa86312bfc19b25cf999111f721d16cf3
5
5
  SHA512:
6
- metadata.gz: ccd9e7b074e48b11b2c9d13f929b2f20d7fcd71e6ad89ae6eaf558d690f1122cbfa78ea145494ada2944ca5f37113ee1ac77fa88679b3194126e24b1c563063c
7
- data.tar.gz: c38476316f30eed488850324802911e538369ba88a2110357d5b8c5dbb2be08fdf99119f640b05e2a11d90d703e7f2646425e2083a8d96fa96996bf1f7c2e966
6
+ metadata.gz: 691d29df5dd389a90f9169e0caa3637c5abad270eeab8e55742b2d45542056d819c18f24723b1e897e1f1cc343d1a6aa740efcb17df1eb6b1517ef580ad2dabd
7
+ data.tar.gz: e1ceae95be87aec10561836e415f7d12d3e59404d24604097efae1fb99290038eb77d1013f03982fae00d5ad1c819d72385a505b247580b2d16c32c7c390e7c2
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_dependency 'rubocop-rspec', '~> 1.44'
31
31
 
32
32
  spec.add_development_dependency 'bundler', '~> 2.1'
33
- spec.add_development_dependency 'gitlab-dangerfiles', '~> 2.6.1'
33
+ spec.add_development_dependency 'gitlab-dangerfiles', '~> 2.11.0'
34
34
  spec.add_development_dependency 'rake', '~> 10.0'
35
35
  spec.add_development_dependency 'rspec', '~> 3.0'
36
36
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Gitlab
4
+ module Styles
5
+ module Common
6
+ module BannedConstants
7
+ attr_reader :replacements, :message_template, :autocorrect
8
+
9
+ def on_const(node)
10
+ constant = node.source.delete_prefix('::')
11
+
12
+ return unless replacements.key?(constant)
13
+
14
+ replacement = replacements.fetch(constant)
15
+ message = format(message_template, { replacement: replacement })
16
+
17
+ add_offense(node, message: message) do |corrector|
18
+ next unless autocorrect
19
+
20
+ replacement = "::#{replacement}" if node.source.start_with?("::")
21
+
22
+ corrector.replace(node, replacement)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../common/banned_constants'
4
+
5
+ module Gitlab
6
+ module Styles
7
+ module Rubocop
8
+ module Cop
9
+ module Fips
10
+ class MD5 < RuboCop::Cop::Base
11
+ include Gitlab::Styles::Common::BannedConstants
12
+
13
+ MESSAGE_TEMPLATE = 'MD5 is not FIPS-compliant. Use %{replacement} instead.'
14
+
15
+ REPLACEMENTS = {
16
+ 'OpenSSL::Digest::MD5' => 'OpenSSL::Digest::SHA256',
17
+ 'Digest::MD5' => 'OpenSSL::Digest::SHA256'
18
+ }.freeze
19
+
20
+ def initialize(config = nil, options = nil)
21
+ @message_template = MESSAGE_TEMPLATE
22
+ @replacements = REPLACEMENTS
23
+ @autocorrect = false
24
+ super(config, options)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../common/banned_constants'
4
+
5
+ module Gitlab
6
+ module Styles
7
+ module Rubocop
8
+ module Cop
9
+ module Fips
10
+ class OpenSSL < RuboCop::Cop::Base
11
+ extend RuboCop::Cop::AutoCorrector
12
+ include Gitlab::Styles::Common::BannedConstants
13
+
14
+ MESSAGE_TEMPLATE = 'Usage of this class is not FIPS-compliant. Use %{replacement} instead.'
15
+
16
+ REPLACEMENTS = {
17
+ 'Digest::SHA1' => 'OpenSSL::Digest::SHA1',
18
+ 'Digest::SHA2' => 'OpenSSL::Digest::SHA2',
19
+ 'Digest::SHA256' => 'OpenSSL::Digest::SHA256',
20
+ 'Digest::SHA384' => 'OpenSSL::Digest::SHA384',
21
+ 'Digest::SHA512' => 'OpenSSL::Digest::SHA512'
22
+ }.freeze
23
+
24
+ def initialize(config = nil, options = nil)
25
+ @message_template = MESSAGE_TEMPLATE
26
+ @replacements = REPLACEMENTS
27
+ @autocorrect = true
28
+ super(config, options)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../common/banned_constants'
4
+
5
+ module Gitlab
6
+ module Styles
7
+ module Rubocop
8
+ module Cop
9
+ module Fips
10
+ class SHA1 < RuboCop::Cop::Base
11
+ include Gitlab::Styles::Common::BannedConstants
12
+
13
+ MESSAGE_TEMPLATE = 'SHA1 is likely to become non-compliant in the near future. Use %{replacement} instead.'
14
+
15
+ REPLACEMENTS = {
16
+ 'OpenSSL::Digest::SHA1' => 'OpenSSL::Digest::SHA256',
17
+ 'Digest::SHA1' => 'OpenSSL::Digest::SHA256'
18
+ }.freeze
19
+
20
+ def initialize(config = nil, options = nil)
21
+ @message_template = MESSAGE_TEMPLATE
22
+ @replacements = REPLACEMENTS
23
+ @autocorrect = false
24
+ super(config, options)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Styles
5
- VERSION = '7.0.0'
5
+ VERSION = '7.1.0'
6
6
  end
7
7
  end
data/rubocop-default.yml CHANGED
@@ -10,6 +10,7 @@ require:
10
10
  inherit_from:
11
11
  - rubocop-all.yml
12
12
  - rubocop-bundler.yml
13
+ - rubocop-fips.yml
13
14
  - rubocop-gemspec.yml
14
15
  - rubocop-graphql.yml
15
16
  - rubocop-layout.yml
data/rubocop-fips.yml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ require:
3
+ - ./lib/gitlab/styles/rubocop
4
+
5
+ # Denies usage of MD5
6
+ Fips/MD5:
7
+ Enabled: true
8
+
9
+ # Denies usage of SHA1
10
+ Fips/SHA1:
11
+ Enabled: true
12
+
13
+ # Replaces ::Digest with ::OpenSSL::Digest
14
+ Fips/OpenSSL:
15
+ Enabled: true
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-styles
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-02 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -120,14 +120,14 @@ dependencies:
120
120
  requirements:
121
121
  - - "~>"
122
122
  - !ruby/object:Gem::Version
123
- version: 2.6.1
123
+ version: 2.11.0
124
124
  type: :development
125
125
  prerelease: false
126
126
  version_requirements: !ruby/object:Gem::Requirement
127
127
  requirements:
128
128
  - - "~>"
129
129
  - !ruby/object:Gem::Version
130
- version: 2.6.1
130
+ version: 2.11.0
131
131
  - !ruby/object:Gem::Dependency
132
132
  name: rake
133
133
  requirement: !ruby/object:Gem::Requirement
@@ -182,12 +182,16 @@ files:
182
182
  - bin/setup
183
183
  - gitlab-styles.gemspec
184
184
  - lib/gitlab/styles.rb
185
+ - lib/gitlab/styles/common/banned_constants.rb
185
186
  - lib/gitlab/styles/rubocop.rb
186
187
  - lib/gitlab/styles/rubocop/cop/active_record_dependent.rb
187
188
  - lib/gitlab/styles/rubocop/cop/active_record_serialize.rb
188
189
  - lib/gitlab/styles/rubocop/cop/avoid_return_from_blocks.rb
189
190
  - lib/gitlab/styles/rubocop/cop/code_reuse/active_record.rb
190
191
  - lib/gitlab/styles/rubocop/cop/custom_error_class.rb
192
+ - lib/gitlab/styles/rubocop/cop/fips/md5.rb
193
+ - lib/gitlab/styles/rubocop/cop/fips/open_ssl.rb
194
+ - lib/gitlab/styles/rubocop/cop/fips/sha1.rb
191
195
  - lib/gitlab/styles/rubocop/cop/gem_fetcher.rb
192
196
  - lib/gitlab/styles/rubocop/cop/in_batches.rb
193
197
  - lib/gitlab/styles/rubocop/cop/internal_affairs/deprecate_cop_helper.rb
@@ -217,6 +221,7 @@ files:
217
221
  - rubocop-bundler.yml
218
222
  - rubocop-code_reuse.yml
219
223
  - rubocop-default.yml
224
+ - rubocop-fips.yml
220
225
  - rubocop-gemspec.yml
221
226
  - rubocop-graphql.yml
222
227
  - rubocop-layout.yml