cfn-nag 0.4.41 → 0.4.42

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: 5717509a5713623b4f9f0e8842ea6f9763f3c16282d883438b79f7792c5ca7f1
4
- data.tar.gz: ebeea57d8a3fc5a59fd461b65d16ef11af5f14da66a3f854de7cc9ac6c2d50a9
3
+ metadata.gz: cf9086143d88b00f7108e8789779d2ef446fab7ebb704026bcc80003bdfc39c4
4
+ data.tar.gz: 6fb9e538518f2552bb9aa43797735ae42cad6e01f3b65a400c16557a4626a4fe
5
5
  SHA512:
6
- metadata.gz: 8412f74d9508acfa2cf7134e27d885fb0953bda6727299c200df28f9ca4bb3d0535e9a9484f736823581aa93ea0668a3cf5abe814063de040042e7064d263725
7
- data.tar.gz: 7fbf0e3d0f31ef8753804d208efc816209b47afb65368959f1303e06030332e340853459e786d74863c4e2bf30cb1be24622047b5982da01574f5d143ca4b358
6
+ metadata.gz: 305cf556e4aaa473311687388b96270cf52d5251317e95c80fd969d438128dd462f308471f581571583bbed8f3256f0cd9335bc70c7a67fcdd5896871d5de771
7
+ data.tar.gz: 3cccb913d3cc87dc4cbccf54b26e6085fb215c264c5ceccf45f8d7fd5920d68498ab027842e2a018823d9200fdf50166ed6a779f97bfe1af1228717cceb3e573
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cfn-nag/violation'
4
+ require_relative 'base'
5
+
6
+ class ApiGatewayAccessLoggingRule < BaseRule
7
+ def rule_text
8
+ 'ApiGateway should have access logging configured'
9
+ end
10
+
11
+ def rule_type
12
+ Violation::WARNING
13
+ end
14
+
15
+ def rule_id
16
+ 'W45'
17
+ end
18
+
19
+ def audit_impl(cfn_model)
20
+ violating_deployments = cfn_model.resources_by_type('AWS::ApiGateway::Deployment').select do |deployment|
21
+ deployment.stageDescription.nil? || deployment.stageDescription['AccessLogSetting'].nil?
22
+ end
23
+
24
+ violating_deployments.map(&:logical_resource_id)
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'cfn-nag/violation'
4
+ require_relative 'base'
5
+
6
+ class IamRoleElevatedManagedPolicyRule < BaseRule
7
+ def rule_text
8
+ 'IAM role should not have Elevated Managed policy'
9
+ end
10
+
11
+ def rule_type
12
+ Violation::WARNING
13
+ end
14
+
15
+ def rule_id
16
+ 'W44'
17
+ end
18
+
19
+ def includes_elevated_policy(role)
20
+ role.managedPolicyArns.find do |policy|
21
+ policy.include?('arn:aws:iam::aws:policy/PowerUserAccess') ||
22
+ policy.include?('arn:aws:iam::aws:policy/IAMFullAccess')
23
+ end
24
+ end
25
+
26
+ def audit_impl(cfn_model)
27
+ violating_roles = cfn_model.resources_by_type('AWS::IAM::Role').select do |role|
28
+ includes_elevated_policy(role)
29
+ end
30
+ violating_roles.map(&:logical_resource_id)
31
+ end
32
+ end
@@ -22,24 +22,26 @@ class SecurityGroupEgressAllProtocolsRule < BaseRule
22
22
  def audit_impl(cfn_model)
23
23
  violating_security_groups = cfn_model.security_groups.select do |security_group|
24
24
  violating_egresses = security_group.egresses.select do |egress|
25
- if egress.ipProtocol.is_a?(Integer) || egress.ipProtocol.is_a?(String)
26
- egress.ipProtocol.to_i == -1
27
- else
28
- false
29
- end
25
+ violating_egress(egress)
30
26
  end
31
27
 
32
28
  !violating_egresses.empty?
33
29
  end
34
30
 
35
31
  violating_egresses = cfn_model.standalone_egress.select do |standalone_egress|
36
- if standalone_egress.ipProtocol.is_a?(Integer) || standalone_egress.ipProtocol.is_a?(String)
37
- standalone_egress.ipProtocol.to_i == -1
38
- else
39
- false
40
- end
32
+ violating_egress(standalone_egress)
41
33
  end
42
34
 
43
35
  violating_security_groups.map(&:logical_resource_id) + violating_egresses.map(&:logical_resource_id)
44
36
  end
37
+
38
+ private
39
+
40
+ def violating_egress(egress)
41
+ if egress.ipProtocol.is_a?(Integer) || egress.ipProtocol.is_a?(String)
42
+ egress.ipProtocol.to_i == -1
43
+ else
44
+ false
45
+ end
46
+ end
45
47
  end
@@ -22,24 +22,26 @@ class SecurityGroupIngressAllProtocolsRule < BaseRule
22
22
  def audit_impl(cfn_model)
23
23
  violating_security_groups = cfn_model.security_groups.select do |security_group|
24
24
  violating_ingresses = security_group.ingresses.select do |ingress|
25
- if ingress.ipProtocol.is_a?(Integer) || ingress.ipProtocol.is_a?(String)
26
- ingress.ipProtocol.to_i == -1
27
- else
28
- false
29
- end
25
+ violating_ingress(ingress)
30
26
  end
31
27
 
32
28
  !violating_ingresses.empty?
33
29
  end
34
30
 
35
31
  violating_ingresses = cfn_model.standalone_ingress.select do |standalone_ingress|
36
- if standalone_ingress.ipProtocol.is_a?(Integer) || standalone_ingress.ipProtocol.is_a?(String)
37
- standalone_ingress.ipProtocol.to_i == -1
38
- else
39
- false
40
- end
32
+ violating_ingress(standalone_ingress)
41
33
  end
42
34
 
43
35
  violating_security_groups.map(&:logical_resource_id) + violating_ingresses.map(&:logical_resource_id)
44
36
  end
37
+
38
+ private
39
+
40
+ def violating_ingress(ingress)
41
+ if ingress.ipProtocol.is_a?(Integer) || ingress.ipProtocol.is_a?(String)
42
+ ingress.ipProtocol.to_i == -1
43
+ else
44
+ false
45
+ end
46
+ end
45
47
  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.41
4
+ version: 0.4.42
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-10-26 00:00:00.000000000 Z
11
+ date: 2019-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -171,6 +171,7 @@ files:
171
171
  - lib/cfn-nag/cli_options.rb
172
172
  - lib/cfn-nag/custom_rule_loader.rb
173
173
  - lib/cfn-nag/custom_rules/AmplifyAppBasicAuthConfigPasswordRule.rb
174
+ - lib/cfn-nag/custom_rules/ApiGatewayAccessLoggingRule.rb
174
175
  - lib/cfn-nag/custom_rules/BatchJobDefinitionContainerPropertiesPrivilegedRule.rb
175
176
  - lib/cfn-nag/custom_rules/CloudFormationAuthenticationRule.rb
176
177
  - lib/cfn-nag/custom_rules/CloudFrontDistributionAccessLoggingRule.rb
@@ -196,6 +197,7 @@ files:
196
197
  - lib/cfn-nag/custom_rules/IamPolicyWildcardActionRule.rb
197
198
  - lib/cfn-nag/custom_rules/IamPolicyWildcardResourceRule.rb
198
199
  - lib/cfn-nag/custom_rules/IamRoleAdministratorAccessPolicyRule.rb
200
+ - lib/cfn-nag/custom_rules/IamRoleElevatedManagedPolicyRule.rb
199
201
  - lib/cfn-nag/custom_rules/IamRoleNotActionOnPermissionsPolicyRule.rb
200
202
  - lib/cfn-nag/custom_rules/IamRoleNotActionOnTrustPolicyRule.rb
201
203
  - lib/cfn-nag/custom_rules/IamRoleNotPrincipalOnTrustPolicyRule.rb