cfn-nag 0.4.54 → 0.4.55
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 +4 -4
- data/lib/cfn-nag/custom_rules/KinesisStreamStreamEncryptionRule.rb +40 -0
- data/lib/cfn-nag/custom_rules/OpsWorksStackRdsDbInstancesDbPasswordRule.rb +31 -0
- data/lib/cfn-nag/custom_rules/password_base_rule.rb +25 -23
- data/lib/cfn-nag/custom_rules/sub_property_with_list_password_base_rule.rb +48 -0
- metadata +5 -3
- data/lib/cfn-nag/custom_rules/OpsWorksStackRdsDbInstancePasswordRule.rb +0 -56
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2682c698c9f4b4cc462275cb36c2789f62305084d85175f5f3a2be1d1bc28095
|
4
|
+
data.tar.gz: f0718d888c66edb0d5efa8da809e0379be6c3b9f079299bee93bd73fc396b5d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0042f93b7b41c7f3203b532d7bb4342adf8f5c61e0a0aecc962ecb7b2f2bda87cffaed100a6be8464399a9bd3355029f80178319653dfd7e05339e97d3eb149d
|
7
|
+
data.tar.gz: 1ea773c620e0d22ff2e1225022304879b13615c72aabbfbd813630d15b64a3f8c3e31f889fae37dc315fdf2b3990289b843033552c34c7d1dd46bce06834ede8
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
class KinesisStreamStreamEncryptionRule < BaseRule
|
7
|
+
def rule_text
|
8
|
+
'Kinesis Stream should specify StreamEncryption. EncryptionType should be KMS and specify KMS Key Id.'
|
9
|
+
end
|
10
|
+
|
11
|
+
def rule_type
|
12
|
+
Violation::WARNING
|
13
|
+
end
|
14
|
+
|
15
|
+
def rule_id
|
16
|
+
'W49'
|
17
|
+
end
|
18
|
+
|
19
|
+
def audit_impl(cfn_model)
|
20
|
+
violating_kinesis_streams = cfn_model.resources_by_type('AWS::Kinesis::Stream').select do |kinesis_stream|
|
21
|
+
violating_kinesis_streams?(kinesis_stream)
|
22
|
+
end
|
23
|
+
|
24
|
+
violating_kinesis_streams.map(&:logical_resource_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def violating_kinesis_streams?(kinesis_stream)
|
30
|
+
if kinesis_stream.streamEncryption.nil?
|
31
|
+
true
|
32
|
+
elsif kinesis_stream.streamEncryption['EncryptionType'].nil?
|
33
|
+
true
|
34
|
+
elsif kinesis_stream.streamEncryption['KeyId'].nil?
|
35
|
+
true
|
36
|
+
else
|
37
|
+
kinesis_stream.streamEncryption['EncryptionType'] == 'NONE'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'sub_property_with_list_password_base_rule'
|
5
|
+
|
6
|
+
class OpsWorksStackRdsDbInstancesDbPasswordRule < SubPropertyWithListPasswordBaseRule
|
7
|
+
def rule_text
|
8
|
+
'OpsWorks Stack RDS DbInstance DbPassword must not be a plaintext ' \
|
9
|
+
'string or a Ref to a NoEcho Parameter with a Default value.' \
|
10
|
+
end
|
11
|
+
|
12
|
+
def rule_type
|
13
|
+
Violation::FAILING_VIOLATION
|
14
|
+
end
|
15
|
+
|
16
|
+
def rule_id
|
17
|
+
'F54'
|
18
|
+
end
|
19
|
+
|
20
|
+
def resource_type
|
21
|
+
'AWS::OpsWorks::Stack'
|
22
|
+
end
|
23
|
+
|
24
|
+
def password_property
|
25
|
+
:rdsDbInstances
|
26
|
+
end
|
27
|
+
|
28
|
+
def sub_property_name
|
29
|
+
'DbPassword'
|
30
|
+
end
|
31
|
+
end
|
@@ -20,7 +20,7 @@ class PasswordBaseRule < BaseRule
|
|
20
20
|
resources = cfn_model.resources_by_type(resource_type)
|
21
21
|
|
22
22
|
violating_resources = resources.select do |resource|
|
23
|
-
if
|
23
|
+
if property_does_not_exist(resource, password_property, sub_property_name)
|
24
24
|
false
|
25
25
|
else
|
26
26
|
verify_insecure_string_and_parameter(
|
@@ -31,32 +31,34 @@ class PasswordBaseRule < BaseRule
|
|
31
31
|
|
32
32
|
violating_resources.map(&:logical_resource_id)
|
33
33
|
end
|
34
|
-
end
|
35
34
|
|
36
|
-
private
|
35
|
+
private
|
37
36
|
|
38
|
-
def
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
37
|
+
def property_does_not_exist(resource, password_property, sub_property_name)
|
38
|
+
if resource.send(password_property).nil?
|
39
|
+
true
|
40
|
+
elsif sub_property_name.nil?
|
41
|
+
false
|
42
|
+
else
|
43
|
+
resource.send(password_property)[sub_property_name].nil?
|
44
|
+
end
|
43
45
|
end
|
44
|
-
end
|
45
46
|
|
46
|
-
def verify_insecure_string_and_parameter(
|
47
|
-
|
48
|
-
)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
cfn_model, resource.send(password_property)[sub_property_name]
|
57
|
-
) ||
|
58
|
-
insecure_string_or_dynamic_reference?(
|
47
|
+
def verify_insecure_string_and_parameter(
|
48
|
+
cfn_model, resource, password_property, sub_property_name
|
49
|
+
)
|
50
|
+
if sub_property_name.nil?
|
51
|
+
insecure_parameter?(cfn_model, resource.send(password_property)) ||
|
52
|
+
insecure_string_or_dynamic_reference?(
|
53
|
+
cfn_model, resource.send(password_property)
|
54
|
+
)
|
55
|
+
else
|
56
|
+
insecure_parameter?(
|
59
57
|
cfn_model, resource.send(password_property)[sub_property_name]
|
60
|
-
)
|
58
|
+
) ||
|
59
|
+
insecure_string_or_dynamic_reference?(
|
60
|
+
cfn_model, resource.send(password_property)[sub_property_name]
|
61
|
+
)
|
62
|
+
end
|
61
63
|
end
|
62
64
|
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require 'cfn-nag/util/enforce_reference_parameter'
|
5
|
+
require 'cfn-nag/util/enforce_string_or_dynamic_reference'
|
6
|
+
require_relative 'base'
|
7
|
+
|
8
|
+
class SubPropertyWithListPasswordBaseRule < BaseRule
|
9
|
+
def resource_type
|
10
|
+
raise 'must implement in subclass'
|
11
|
+
end
|
12
|
+
|
13
|
+
def password_property
|
14
|
+
raise 'must implement in subclass'
|
15
|
+
end
|
16
|
+
|
17
|
+
def sub_property_name; end
|
18
|
+
|
19
|
+
def audit_impl(cfn_model)
|
20
|
+
resources = cfn_model.resources_by_type(resource_type)
|
21
|
+
|
22
|
+
violating_resources = resources.select do |resource|
|
23
|
+
verify_insecure_string_and_parameter_with_list(
|
24
|
+
cfn_model, resource, password_property, sub_property_name
|
25
|
+
)
|
26
|
+
end
|
27
|
+
|
28
|
+
violating_resources.map(&:logical_resource_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def verify_insecure_string_and_parameter_with_list(
|
34
|
+
cfn_model, resource, password_property, sub_property_name
|
35
|
+
)
|
36
|
+
sub_property_checks_result = ''
|
37
|
+
|
38
|
+
resource.send(password_property).select do |sub_property|
|
39
|
+
sub_property_checks_result = insecure_parameter?(
|
40
|
+
cfn_model, sub_property[sub_property_name]
|
41
|
+
) || insecure_string_or_dynamic_reference?(
|
42
|
+
cfn_model, sub_property[sub_property_name]
|
43
|
+
)
|
44
|
+
end
|
45
|
+
|
46
|
+
sub_property_checks_result
|
47
|
+
end
|
48
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cfn-nag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.55
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -200,12 +200,13 @@ files:
|
|
200
200
|
- lib/cfn-nag/custom_rules/IotPolicyWildcardActionRule.rb
|
201
201
|
- lib/cfn-nag/custom_rules/IotPolicyWildcardResourceRule.rb
|
202
202
|
- lib/cfn-nag/custom_rules/KMSKeyRotationRule.rb
|
203
|
+
- lib/cfn-nag/custom_rules/KinesisStreamStreamEncryptionRule.rb
|
203
204
|
- lib/cfn-nag/custom_rules/LambdaPermissionInvokeFunctionActionRule.rb
|
204
205
|
- lib/cfn-nag/custom_rules/LambdaPermissionWildcardPrincipalRule.rb
|
205
206
|
- lib/cfn-nag/custom_rules/ManagedPolicyOnUserRule.rb
|
206
207
|
- lib/cfn-nag/custom_rules/MissingBucketPolicyRule.rb
|
207
208
|
- lib/cfn-nag/custom_rules/NeptuneDBClusterStorageEncryptedRule.rb
|
208
|
-
- lib/cfn-nag/custom_rules/
|
209
|
+
- lib/cfn-nag/custom_rules/OpsWorksStackRdsDbInstancesDbPasswordRule.rb
|
209
210
|
- lib/cfn-nag/custom_rules/PolicyOnUserRule.rb
|
210
211
|
- lib/cfn-nag/custom_rules/RDSDBClusterMasterUserPasswordRule.rb
|
211
212
|
- lib/cfn-nag/custom_rules/RDSDBClusterStorageEncryptedRule.rb
|
@@ -250,6 +251,7 @@ files:
|
|
250
251
|
- lib/cfn-nag/custom_rules/boolean_base_rule.rb
|
251
252
|
- lib/cfn-nag/custom_rules/passrole_base_rule.rb
|
252
253
|
- lib/cfn-nag/custom_rules/password_base_rule.rb
|
254
|
+
- lib/cfn-nag/custom_rules/sub_property_with_list_password_base_rule.rb
|
253
255
|
- lib/cfn-nag/ip_addr.rb
|
254
256
|
- lib/cfn-nag/jmes_path_discovery.rb
|
255
257
|
- lib/cfn-nag/jmes_path_evaluator.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'cfn-nag/violation'
|
4
|
-
require 'cfn-nag/util/enforce_reference_parameter'
|
5
|
-
require 'cfn-nag/util/enforce_string_or_dynamic_reference'
|
6
|
-
require_relative 'base'
|
7
|
-
|
8
|
-
class OpsWorksStackRdsDbInstancePasswordRule < BaseRule
|
9
|
-
def rule_text
|
10
|
-
'OpsWorks Stack RDS DBInstance Password property should not show password ' \
|
11
|
-
'in plain text, resolve an unsecure ssm string, or have a default value for parameter.'
|
12
|
-
end
|
13
|
-
|
14
|
-
def rule_type
|
15
|
-
Violation::FAILING_VIOLATION
|
16
|
-
end
|
17
|
-
|
18
|
-
def rule_id
|
19
|
-
'F54'
|
20
|
-
end
|
21
|
-
|
22
|
-
def audit_impl(cfn_model)
|
23
|
-
opsworks_stacks = cfn_model.resources_by_type('AWS::OpsWorks::Stack')
|
24
|
-
violating_opsworks_stacks = opsworks_stacks.select do |opsworks_stack|
|
25
|
-
violating_db_instances?(cfn_model, opsworks_stack)
|
26
|
-
end
|
27
|
-
violating_opsworks_stacks.map(&:logical_resource_id)
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def db_instance_has_insecure_password?(cfn_model, dbinstance)
|
33
|
-
if dbinstance.key? 'DbPassword'
|
34
|
-
if insecure_parameter?(cfn_model, dbinstance['DbPassword'])
|
35
|
-
true
|
36
|
-
elsif insecure_string_or_dynamic_reference?(cfn_model, dbinstance['DbPassword'])
|
37
|
-
true
|
38
|
-
elsif dbinstance['DbPassword'].nil?
|
39
|
-
true
|
40
|
-
end
|
41
|
-
else
|
42
|
-
true
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
def violating_db_instances?(cfn_model, opsworks_stack)
|
47
|
-
if !opsworks_stack.rdsDbInstances.nil?
|
48
|
-
violating_dbinstances = opsworks_stack.rdsDbInstances.select do |dbinstance|
|
49
|
-
db_instance_has_insecure_password?(cfn_model, dbinstance)
|
50
|
-
end
|
51
|
-
!violating_dbinstances.empty?
|
52
|
-
else
|
53
|
-
false
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|