cookstyle 7.25.9 → 7.28.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/cookstyle.yml +44 -0
- data/config/disable_all.yml +14 -0
- data/config/upstream.yml +83 -5
- data/lib/cookstyle/version.rb +2 -2
- data/lib/rubocop/cop/chef/correctness/invalid_cookbook_name.rb +47 -0
- data/lib/rubocop/cop/chef/correctness/invalid_notification_resource.rb +59 -0
- data/lib/rubocop/cop/chef/security/ssh_private_key.rb +49 -0
- data/lib/rubocop/monkey_patches/directive_comment.rb +1 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 205f14a7f600dc2fe712e9407e16165b72cadab5624913efba78a6f0748f65ae
|
4
|
+
data.tar.gz: c03813392f90967e5036e49a8886d6c1b7e31ea7319da75c12008d3a01c635f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f7f8c8c719dbb83b740882be2f247250c95fb7f330a82a0cf8d7b5b96fa7071ca7b55761a8a599ac4801f2c75eb403f64c04bde4245f31fc12b8f753418d3f5
|
7
|
+
data.tar.gz: 8a32adeedb7654948337162eeb9a8c660f66ab13655ec537aa584b15a156f726130f16630dddb2f1fa0169d10e5dd4a84b7353392591431490f12129ed0245c4
|
data/config/cookstyle.yml
CHANGED
@@ -506,6 +506,24 @@ Chef/Correctness/MetadataMissingVersion:
|
|
506
506
|
Include:
|
507
507
|
- '**/metadata.rb'
|
508
508
|
|
509
|
+
Chef/Correctness/InvalidCookbookName:
|
510
|
+
Description: Cookbook names should not contain invalid characters such as periods.
|
511
|
+
StyleGuide: 'chef_correctness_invalidcookbookname'
|
512
|
+
Enabled: true
|
513
|
+
VersionAdded: '7.27'
|
514
|
+
Include:
|
515
|
+
- '**/metadata.rb'
|
516
|
+
|
517
|
+
Chef/Correctness/InvalidNotificationResource:
|
518
|
+
Description: The resource to notify when calling `notifies` or `subscribes` must be a string.
|
519
|
+
StyleGuide: 'chef_correctness_invalidnotificationresource'
|
520
|
+
Enabled: true
|
521
|
+
VersionAdded: '7.28'
|
522
|
+
Exclude:
|
523
|
+
- '**/attributes/*.rb'
|
524
|
+
- '**/metadata.rb'
|
525
|
+
- '**/Berksfile'
|
526
|
+
|
509
527
|
###############################
|
510
528
|
# Chef/Sharing: Issues that prevent sharing code with other teams or with the Chef community in general
|
511
529
|
###############################
|
@@ -2281,6 +2299,24 @@ InSpec/Deprecations/AttributeDefault:
|
|
2281
2299
|
Include:
|
2282
2300
|
- '**/controls/*.rb'
|
2283
2301
|
|
2302
|
+
#### Security Cops
|
2303
|
+
|
2304
|
+
Chef/Security:
|
2305
|
+
StyleGuideBaseURL: https://docs.chef.io/workstation/cookstyle/
|
2306
|
+
|
2307
|
+
Chef/Security/ :
|
2308
|
+
Description: Do not include plain text SSH private keys in your cookbook code. This sensitive data should be fetched from secrets management systems so that secrets are not uploaded in plain text to the Chef Infra Server or committed to source control systems.
|
2309
|
+
StyleGuide: 'chef_security_sshprivatekey'
|
2310
|
+
Enabled: true
|
2311
|
+
VersionAdded: '7.28'
|
2312
|
+
Include:
|
2313
|
+
- '**/libraries/*.rb'
|
2314
|
+
- '**/resources/*.rb'
|
2315
|
+
- '**/providers/*.rb'
|
2316
|
+
- '**/recipes/*.rb'
|
2317
|
+
- '**/attributes/*.rb'
|
2318
|
+
- '**/definitions/*.rb'
|
2319
|
+
|
2284
2320
|
#### The base rubocop 0.37 enabled.yml file we started with ####
|
2285
2321
|
|
2286
2322
|
Layout/AccessModifierIndentation:
|
@@ -3035,3 +3071,11 @@ Lint/DeprecatedConstants:
|
|
3035
3071
|
# always turn on deprecation cops from rubocop
|
3036
3072
|
Lint/ErbNewArguments:
|
3037
3073
|
Enabled: true
|
3074
|
+
|
3075
|
+
# reduce file read complexity
|
3076
|
+
Style/FileRead:
|
3077
|
+
Enabled: true
|
3078
|
+
|
3079
|
+
# reduce file write complexity
|
3080
|
+
Style/FileWrite:
|
3081
|
+
Enabled: true
|
data/config/disable_all.yml
CHANGED
@@ -19,6 +19,8 @@ Gemspec/DuplicatedAssignment:
|
|
19
19
|
Enabled: false
|
20
20
|
Gemspec/OrderedDependencies:
|
21
21
|
Enabled: false
|
22
|
+
Gemspec/RequireMFA:
|
23
|
+
Enabled: false
|
22
24
|
Gemspec/RequiredRubyVersion:
|
23
25
|
Enabled: false
|
24
26
|
Gemspec/RubyVersionGlobalsUsage:
|
@@ -459,6 +461,8 @@ Lint/UselessElseWithoutRescue:
|
|
459
461
|
Enabled: false
|
460
462
|
Lint/UselessMethodDefinition:
|
461
463
|
Enabled: false
|
464
|
+
Lint/UselessRuby2Keywords:
|
465
|
+
Enabled: false
|
462
466
|
Lint/UselessSetterCall:
|
463
467
|
Enabled: false
|
464
468
|
Lint/UselessTimes:
|
@@ -487,6 +491,8 @@ Naming/AccessorMethodName:
|
|
487
491
|
Enabled: false
|
488
492
|
Naming/AsciiIdentifiers:
|
489
493
|
Enabled: false
|
494
|
+
Naming/BlockForwarding:
|
495
|
+
Enabled: false
|
490
496
|
Naming/BlockParameterName:
|
491
497
|
Enabled: false
|
492
498
|
Naming/ClassAndModuleCamelCase:
|
@@ -637,6 +643,10 @@ Style/ExplicitBlockArgument:
|
|
637
643
|
Enabled: false
|
638
644
|
Style/ExponentialNotation:
|
639
645
|
Enabled: false
|
646
|
+
Style/FileRead:
|
647
|
+
Enabled: false
|
648
|
+
Style/FileWrite:
|
649
|
+
Enabled: false
|
640
650
|
Style/FloatDivision:
|
641
651
|
Enabled: false
|
642
652
|
Style/For:
|
@@ -701,6 +711,8 @@ Style/LambdaCall:
|
|
701
711
|
Enabled: false
|
702
712
|
Style/LineEndConcatenation:
|
703
713
|
Enabled: false
|
714
|
+
Style/MapToHash:
|
715
|
+
Enabled: false
|
704
716
|
Style/MethodCallWithoutArgsParentheses:
|
705
717
|
Enabled: false
|
706
718
|
Style/MethodCallWithArgsParentheses:
|
@@ -709,6 +721,8 @@ Style/MultilineInPatternThen:
|
|
709
721
|
Enabled: false
|
710
722
|
Style/NumberedParameters:
|
711
723
|
Enabled: false
|
724
|
+
Style/OpenStructUse:
|
725
|
+
Enabled: false
|
712
726
|
Style/RedundantAssignment:
|
713
727
|
Enabled: false
|
714
728
|
Style/RedundantFetchBlock:
|
data/config/upstream.yml
CHANGED
@@ -78,6 +78,8 @@ AllCops:
|
|
78
78
|
# When specifying style guide URLs, any paths and/or fragments will be
|
79
79
|
# evaluated relative to the base URL.
|
80
80
|
StyleGuideBaseURL: https://rubystyle.guide
|
81
|
+
# Documentation URLs will be constructed using the base URL.
|
82
|
+
DocumentationBaseURL: https://docs.rubocop.org/rubocop
|
81
83
|
# Extra details are not displayed in offense messages by default. Change
|
82
84
|
# behavior by overriding ExtraDetails, or by giving the
|
83
85
|
# `-E/--extra-details` option.
|
@@ -150,6 +152,7 @@ AllCops:
|
|
150
152
|
rubocop-minitest: [minitest]
|
151
153
|
rubocop-sequel: [sequel]
|
152
154
|
rubocop-rake: [rake]
|
155
|
+
rubocop-graphql: [graphql]
|
153
156
|
|
154
157
|
#################### Bundler ###############################
|
155
158
|
|
@@ -258,6 +261,15 @@ Gemspec/OrderedDependencies:
|
|
258
261
|
Include:
|
259
262
|
- '**/*.gemspec'
|
260
263
|
|
264
|
+
Gemspec/RequireMFA:
|
265
|
+
Description: 'Checks that the gemspec has metadata to require MFA from RubyGems.'
|
266
|
+
Enabled: pending
|
267
|
+
VersionAdded: '1.23'
|
268
|
+
Reference:
|
269
|
+
- https://guides.rubygems.org/mfa-requirement-opt-in/
|
270
|
+
Include:
|
271
|
+
- '**/*.gemspec'
|
272
|
+
|
261
273
|
Gemspec/RequiredRubyVersion:
|
262
274
|
Description: 'Checks that `required_ruby_version` of gemspec is specified and equal to `TargetRubyVersion` of .rubocop.yml.'
|
263
275
|
Enabled: true
|
@@ -439,7 +451,11 @@ Layout/ClosingParenthesisIndentation:
|
|
439
451
|
Layout/CommentIndentation:
|
440
452
|
Description: 'Indentation of comments.'
|
441
453
|
Enabled: true
|
454
|
+
# When true, allows comments to have extra indentation if that aligns them
|
455
|
+
# with a comment on the preceding line.
|
456
|
+
AllowForAlignment: false
|
442
457
|
VersionAdded: '0.49'
|
458
|
+
VersionChanged: '1.24'
|
443
459
|
|
444
460
|
Layout/ConditionPosition:
|
445
461
|
Description: >-
|
@@ -511,13 +527,13 @@ Layout/EmptyLineBetweenDefs:
|
|
511
527
|
StyleGuide: '#empty-lines-between-methods'
|
512
528
|
Enabled: true
|
513
529
|
VersionAdded: '0.49'
|
514
|
-
VersionChanged: '1.
|
530
|
+
VersionChanged: '1.23'
|
515
531
|
EmptyLineBetweenMethodDefs: true
|
516
532
|
EmptyLineBetweenClassDefs: true
|
517
533
|
EmptyLineBetweenModuleDefs: true
|
518
|
-
#
|
519
|
-
# need an empty line between them.
|
520
|
-
AllowAdjacentOneLineDefs:
|
534
|
+
# `AllowAdjacentOneLineDefs` means that single line method definitions don't
|
535
|
+
# need an empty line between them. `true` by default.
|
536
|
+
AllowAdjacentOneLineDefs: true
|
521
537
|
# Can be array to specify minimum and maximum number of empty lines, e.g. [1, 2]
|
522
538
|
NumberOfEmptyLines: 1
|
523
539
|
|
@@ -1786,7 +1802,9 @@ Lint/ImplicitStringConcatenation:
|
|
1786
1802
|
Lint/IncompatibleIoSelectWithFiberScheduler:
|
1787
1803
|
Description: 'Checks for `IO.select` that is incompatible with Fiber Scheduler.'
|
1788
1804
|
Enabled: pending
|
1805
|
+
SafeAutoCorrect: false
|
1789
1806
|
VersionAdded: '1.21'
|
1807
|
+
VersionChanged: '1.24'
|
1790
1808
|
|
1791
1809
|
Lint/IneffectiveAccessModifier:
|
1792
1810
|
Description: >-
|
@@ -2308,6 +2326,11 @@ Lint/UselessMethodDefinition:
|
|
2308
2326
|
Safe: false
|
2309
2327
|
AllowComments: true
|
2310
2328
|
|
2329
|
+
Lint/UselessRuby2Keywords:
|
2330
|
+
Description: 'Finds unnecessary uses of `ruby2_keywords`.'
|
2331
|
+
Enabled: pending
|
2332
|
+
VersionAdded: '1.23'
|
2333
|
+
|
2311
2334
|
Lint/UselessSetterCall:
|
2312
2335
|
Description: 'Checks for useless setter call to a local variable.'
|
2313
2336
|
Enabled: true
|
@@ -2464,6 +2487,16 @@ Naming/BinaryOperatorParameterName:
|
|
2464
2487
|
VersionAdded: '0.50'
|
2465
2488
|
VersionChanged: '1.2'
|
2466
2489
|
|
2490
|
+
Naming/BlockForwarding:
|
2491
|
+
Description: 'Use anonymous block forwarding.'
|
2492
|
+
StyleGuide: '#block-forwarding'
|
2493
|
+
Enabled: pending
|
2494
|
+
VersionAdded: '1.24'
|
2495
|
+
EnforcedStyle: anonymous
|
2496
|
+
SupportedStyles:
|
2497
|
+
- anonymous
|
2498
|
+
- explicit
|
2499
|
+
|
2467
2500
|
Naming/BlockParameterName:
|
2468
2501
|
Description: >-
|
2469
2502
|
Checks for block parameter names that contain capital letters,
|
@@ -2501,6 +2534,7 @@ Naming/FileName:
|
|
2501
2534
|
StyleGuide: '#snake-case-files'
|
2502
2535
|
Enabled: true
|
2503
2536
|
VersionAdded: '0.50'
|
2537
|
+
VersionChanged: '1.23'
|
2504
2538
|
# Camel case file names listed in `AllCops:Include` and all file names listed
|
2505
2539
|
# in `AllCops:Exclude` are excluded by default. Add extra excludes here.
|
2506
2540
|
Exclude: []
|
@@ -2513,6 +2547,13 @@ Naming/FileName:
|
|
2513
2547
|
# whether each source file's class or module name matches the file name --
|
2514
2548
|
# not whether the nested module hierarchy matches the subdirectory path.
|
2515
2549
|
CheckDefinitionPathHierarchy: true
|
2550
|
+
# paths that are considered root directories, for example "lib" in most ruby projects
|
2551
|
+
# or "app/models" in rails projects
|
2552
|
+
CheckDefinitionPathHierarchyRoots:
|
2553
|
+
- lib
|
2554
|
+
- spec
|
2555
|
+
- test
|
2556
|
+
- src
|
2516
2557
|
# If non-`nil`, expect all source file names to match the following regex.
|
2517
2558
|
# Only the file name itself is matched, not the entire file path.
|
2518
2559
|
# Use anchors as necessary if you want to match the entire name rather than
|
@@ -3469,6 +3510,18 @@ Style/ExponentialNotation:
|
|
3469
3510
|
- engineering
|
3470
3511
|
- integral
|
3471
3512
|
|
3513
|
+
Style/FileRead:
|
3514
|
+
Description: 'Favor `File.(bin)read` convenience methods.'
|
3515
|
+
StyleGuide: '#file-read'
|
3516
|
+
Enabled: pending
|
3517
|
+
VersionAdded: '1.24'
|
3518
|
+
|
3519
|
+
Style/FileWrite:
|
3520
|
+
Description: 'Favor `File.(bin)write` convenience methods.'
|
3521
|
+
StyleGuide: '#file-write'
|
3522
|
+
Enabled: pending
|
3523
|
+
VersionAdded: '1.24'
|
3524
|
+
|
3472
3525
|
Style/FloatDivision:
|
3473
3526
|
Description: 'For performing float division, coerce one side only.'
|
3474
3527
|
StyleGuide: '#float-division'
|
@@ -3627,7 +3680,7 @@ Style/HashSyntax:
|
|
3627
3680
|
StyleGuide: '#hash-literals'
|
3628
3681
|
Enabled: true
|
3629
3682
|
VersionAdded: '0.9'
|
3630
|
-
VersionChanged: '
|
3683
|
+
VersionChanged: '1.24'
|
3631
3684
|
EnforcedStyle: ruby19
|
3632
3685
|
SupportedStyles:
|
3633
3686
|
# checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
|
@@ -3638,6 +3691,13 @@ Style/HashSyntax:
|
|
3638
3691
|
- no_mixed_keys
|
3639
3692
|
# enforces both ruby19 and no_mixed_keys styles
|
3640
3693
|
- ruby19_no_mixed_keys
|
3694
|
+
# Force hashes that have a hash value omission
|
3695
|
+
EnforcedShorthandSyntax: always
|
3696
|
+
SupportedShorthandSyntax:
|
3697
|
+
# forces use of the 3.1 syntax (e.g. {foo:}) when the hash key and value are the same.
|
3698
|
+
- always
|
3699
|
+
# forces use of explicit hash literal value.
|
3700
|
+
- never
|
3641
3701
|
# Force hashes that have a symbol value to use hash rockets
|
3642
3702
|
UseHashRocketsWithSymbolValues: false
|
3643
3703
|
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
|
@@ -3814,6 +3874,12 @@ Style/LineEndConcatenation:
|
|
3814
3874
|
VersionAdded: '0.18'
|
3815
3875
|
VersionChanged: '0.64'
|
3816
3876
|
|
3877
|
+
Style/MapToHash:
|
3878
|
+
Description: 'Prefer `to_h` with a block over `map.to_h`.'
|
3879
|
+
Enabled: pending
|
3880
|
+
VersionAdded: '1.24'
|
3881
|
+
Safe: false
|
3882
|
+
|
3817
3883
|
Style/MethodCallWithArgsParentheses:
|
3818
3884
|
Description: 'Use parentheses for method calls with arguments.'
|
3819
3885
|
StyleGuide: '#method-invocation-parens'
|
@@ -4182,6 +4248,8 @@ Style/NumericLiterals:
|
|
4182
4248
|
VersionChanged: '0.48'
|
4183
4249
|
MinDigits: 5
|
4184
4250
|
Strict: false
|
4251
|
+
# You can specify allowed numbers. (e.g. port number 3000, 8080, and etc)
|
4252
|
+
AllowedNumbers: []
|
4185
4253
|
|
4186
4254
|
Style/NumericPredicate:
|
4187
4255
|
Description: >-
|
@@ -4216,6 +4284,16 @@ Style/OneLineConditional:
|
|
4216
4284
|
VersionAdded: '0.9'
|
4217
4285
|
VersionChanged: '0.90'
|
4218
4286
|
|
4287
|
+
Style/OpenStructUse:
|
4288
|
+
Description: >-
|
4289
|
+
Avoid using OpenStruct. As of Ruby 3.0, use is officially discouraged due to performance,
|
4290
|
+
version compatibility, and potential security issues.
|
4291
|
+
Reference:
|
4292
|
+
- https://docs.ruby-lang.org/en/3.0.0/OpenStruct.html#class-OpenStruct-label-Caveats
|
4293
|
+
|
4294
|
+
Enabled: pending
|
4295
|
+
VersionAdded: '1.23'
|
4296
|
+
|
4219
4297
|
Style/OptionHash:
|
4220
4298
|
Description: "Don't use option hashes when you can use keyword arguments."
|
4221
4299
|
Enabled: false
|
data/lib/cookstyle/version.rb
CHANGED
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2022, Chef Software Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Correctness
|
22
|
+
# Cookbook names should not contain invalid characters such as periods.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# name 'foo.bar'
|
28
|
+
#
|
29
|
+
# #### correct
|
30
|
+
# name 'foo_bar'
|
31
|
+
#
|
32
|
+
class InvalidCookbookName < Base
|
33
|
+
RESTRICT_ON_SEND = [:name].freeze
|
34
|
+
MSG = 'Cookbook names should not contain invalid characters such as periods.'
|
35
|
+
|
36
|
+
def_node_matcher :has_name?, '(send nil? :name $str)'
|
37
|
+
|
38
|
+
def on_send(node)
|
39
|
+
has_name?(node) do |val|
|
40
|
+
add_offense(node, message: MSG, severity: :refactor) if val.value.include?('.')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2022, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Correctness
|
22
|
+
# The resource to notify when calling `notifies` or `subscribes` must be a string.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
#
|
28
|
+
# template '/etc/www/configures-apache.conf' do
|
29
|
+
# notifies :restart, service['apache'], :immediately
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# template '/etc/www/configures-apache.conf' do
|
33
|
+
# notifies :restart, service[apache], :immediately
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# #### correct
|
37
|
+
#
|
38
|
+
# template '/etc/www/configures-apache.conf' do
|
39
|
+
# notifies :restart, 'service[apache]', :immediately
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
class InvalidNotificationResource < Base
|
43
|
+
MSG = 'The resource to notify when calling `notifies` or `subscribes` must be a string.'
|
44
|
+
RESTRICT_ON_SEND = [:notifies, :subscribes].freeze
|
45
|
+
|
46
|
+
def_node_matcher :invalid_notification?, <<-PATTERN
|
47
|
+
(send nil? {:notifies :subscribes} (sym _) $(send (send nil? _) :[] ...) ...)
|
48
|
+
PATTERN
|
49
|
+
|
50
|
+
def on_send(node)
|
51
|
+
invalid_notification?(node) do |resource|
|
52
|
+
add_offense(resource, message: MSG, severity: :refactor)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Copyright:: 2021-2022, Chef Software, Inc.
|
4
|
+
# Author:: Tim Smith (<tsmith@chef.io>)
|
5
|
+
#
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
# you may not use this file except in compliance with the License.
|
8
|
+
# You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
# See the License for the specific language governing permissions and
|
16
|
+
# limitations under the License.
|
17
|
+
#
|
18
|
+
module RuboCop
|
19
|
+
module Cop
|
20
|
+
module Chef
|
21
|
+
module Security
|
22
|
+
# Do not include plain text SSH private keys in your cookbook code. This sensitive data should be fetched from secrets management systems so that secrets are not uploaded in plain text to the Chef Infra Server or committed to source control systems.
|
23
|
+
#
|
24
|
+
# @example
|
25
|
+
#
|
26
|
+
# #### incorrect
|
27
|
+
# file '/Users/bob_bobberson/.ssh/id_rsa' do
|
28
|
+
# content '-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----'
|
29
|
+
# mode '600'
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
class SshPrivateKey < Base
|
33
|
+
MSG = 'Do not include plain text SSH private keys in your cookbook code. This sensitive data should be fetched from secrets management systems so that secrets are not uploaded in plain text to the Chef Infra Server or committed to source control systems.'
|
34
|
+
|
35
|
+
def on_send(node)
|
36
|
+
return unless node.arguments?
|
37
|
+
node.arguments.each do |arg|
|
38
|
+
next unless arg.str_type? || arg.dstr_type?
|
39
|
+
|
40
|
+
if arg.value.start_with?('-----BEGIN RSA PRIVATE', '-----BEGIN EC PRIVATE') # cookstyle: disable Chef/Security/SshPrivateKey
|
41
|
+
add_offense(node, message: MSG, severity: :warning)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -3,7 +3,7 @@ module RuboCop
|
|
3
3
|
# we're monkey patching the config regex to allow for # cookstyle: disable whatever
|
4
4
|
# in addition to the # rubocop: disable whatever that comes with RuboCop
|
5
5
|
class DirectiveComment
|
6
|
-
remove_const(
|
6
|
+
remove_const(:DIRECTIVE_COMMENT_REGEXP)
|
7
7
|
DIRECTIVE_COMMENT_REGEXP = Regexp.new(
|
8
8
|
"# (?:rubocop|cookstyle) : ((?:disable|enable|todo))\\b #{COPS_PATTERN}"
|
9
9
|
.gsub(' ', '\s*')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cookstyle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 7.
|
4
|
+
version: 7.28.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thom May
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-01-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubocop
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - '='
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 1.
|
20
|
+
version: 1.24.1
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - '='
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 1.
|
27
|
+
version: 1.24.1
|
28
28
|
description:
|
29
29
|
email:
|
30
30
|
- thom@chef.io
|
@@ -55,7 +55,9 @@ files:
|
|
55
55
|
- lib/rubocop/cop/chef/correctness/conditional_ruby_shellout.rb
|
56
56
|
- lib/rubocop/cop/chef/correctness/dnf_package_allow_downgrades.rb
|
57
57
|
- lib/rubocop/cop/chef/correctness/incorrect_library_injection.rb
|
58
|
+
- lib/rubocop/cop/chef/correctness/invalid_cookbook_name.rb
|
58
59
|
- lib/rubocop/cop/chef/correctness/invalid_default_action.rb
|
60
|
+
- lib/rubocop/cop/chef/correctness/invalid_notification_resource.rb
|
59
61
|
- lib/rubocop/cop/chef/correctness/invalid_notification_timing.rb
|
60
62
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_helper.rb
|
61
63
|
- lib/rubocop/cop/chef/correctness/invalid_platform_family_values_in_case.rb
|
@@ -273,6 +275,7 @@ files:
|
|
273
275
|
- lib/rubocop/cop/chef/redundant/unnecessary_desired_state.rb
|
274
276
|
- lib/rubocop/cop/chef/redundant/unnecessary_name_property.rb
|
275
277
|
- lib/rubocop/cop/chef/redundant/use_create_if_missing.rb
|
278
|
+
- lib/rubocop/cop/chef/security/ssh_private_key.rb
|
276
279
|
- lib/rubocop/cop/chef/sharing/default_maintainer_metadata.rb
|
277
280
|
- lib/rubocop/cop/chef/sharing/empty_metadata_field.rb
|
278
281
|
- lib/rubocop/cop/chef/sharing/include_property_descriptions.rb
|