cfn-nag 0.7.1 → 0.7.6
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/ApiGatewayCacheEncryptedRule.rb +34 -0
- data/lib/cfn-nag/custom_rules/CloudfrontMinimumProtocolVersionRule.rb +4 -3
- data/lib/cfn-nag/custom_rules/ECRRepositoryScanOnPushRule.rb +2 -2
- data/lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamEncryptionRule.rb +39 -0
- data/lib/cfn-nag/custom_rules/LambdaFunctionInsideVPCRule.rb +27 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 59c999774eab0a7ebd00d06aa55d9080218683d60a8a6a0eed160ffe5171617b
|
4
|
+
data.tar.gz: 4eb14549c72fe44b27941a90793c8a52271f5fcf4a9c7799b29c0800be2fd815
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff895bb892baaae4b1143daeac5c1dde170635e7c627ec3cd09249b28bfdc7b1eb37c71da271306552b03cfae080e4cf272d006536441531328a40c98f73f10c
|
7
|
+
data.tar.gz: 56289bf3957389c76477eb1b9fb32d44262b1bf98d711812f8f44bd078b93e5efe6d216cc519711a0a0303bc88bd90526f9e244a76f3e752af24d60ac8dee805
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
class ApiGatewayCacheEncryptedRule < BaseRule
|
7
|
+
def rule_text
|
8
|
+
'ApiGateway Deployment should have cache data encryption enabled when caching is enabled' \
|
9
|
+
' in StageDescription properties'
|
10
|
+
end
|
11
|
+
|
12
|
+
def rule_type
|
13
|
+
Violation::WARNING
|
14
|
+
end
|
15
|
+
|
16
|
+
def rule_id
|
17
|
+
'W87'
|
18
|
+
end
|
19
|
+
|
20
|
+
def audit_impl(cfn_model)
|
21
|
+
violating_deployments = cfn_model.resources_by_type('AWS::ApiGateway::Deployment').select do |deployment|
|
22
|
+
violating_deployment?(deployment)
|
23
|
+
end
|
24
|
+
|
25
|
+
violating_deployments.map(&:logical_resource_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def violating_deployment?(deployment)
|
31
|
+
!deployment.stageDescription.nil? && truthy?(deployment.stageDescription['CachingEnabled']) \
|
32
|
+
&& !truthy?(deployment.stageDescription['CacheDataEncrypted'])
|
33
|
+
end
|
34
|
+
end
|
@@ -28,11 +28,12 @@ class CloudfrontMinimumProtocolVersionRule < BaseRule
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def tls_version?(viewer_certificate)
|
31
|
-
cert_has_bad_tls_version?(viewer_certificate) || override_tls_config?(viewer_certificate)
|
31
|
+
cert_has_bad_tls_version?(viewer_certificate['MinimumProtocolVersion']) || override_tls_config?(viewer_certificate)
|
32
32
|
end
|
33
33
|
|
34
|
-
def cert_has_bad_tls_version?(
|
35
|
-
|
34
|
+
def cert_has_bad_tls_version?(min_protocol_version)
|
35
|
+
min_protocol_version.nil? ||
|
36
|
+
(min_protocol_version.is_a?(String) && !min_protocol_version.start_with?('TLSv1.2'))
|
36
37
|
end
|
37
38
|
|
38
39
|
def override_tls_config?(viewer_certificate)
|
@@ -6,7 +6,7 @@ require_relative 'base'
|
|
6
6
|
|
7
7
|
class ECRRepositoryScanOnPushRule < BaseRule
|
8
8
|
def rule_text
|
9
|
-
'ECR Repository should have
|
9
|
+
'ECR Repository should have ScanOnPush enabled'
|
10
10
|
end
|
11
11
|
|
12
12
|
def rule_type
|
@@ -20,7 +20,7 @@ class ECRRepositoryScanOnPushRule < BaseRule
|
|
20
20
|
def audit_impl(cfn_model)
|
21
21
|
violating_ecr_registries = cfn_model.resources_by_type('AWS::ECR::Repository').select do |registry|
|
22
22
|
registry.imageScanningConfiguration.nil? ||
|
23
|
-
!truthy?(registry.imageScanningConfiguration['
|
23
|
+
!truthy?(registry.imageScanningConfiguration['ScanOnPush'].to_s)
|
24
24
|
end
|
25
25
|
|
26
26
|
violating_ecr_registries.map(&:logical_resource_id)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
class KinesisFirehoseDeliveryStreamEncryptionRule < BaseRule
|
7
|
+
def rule_text
|
8
|
+
'Kinesis Firehose DeliveryStream of type DirectPut should specify SSE.'
|
9
|
+
end
|
10
|
+
|
11
|
+
def rule_type
|
12
|
+
Violation::WARNING
|
13
|
+
end
|
14
|
+
|
15
|
+
def rule_id
|
16
|
+
'W88'
|
17
|
+
end
|
18
|
+
|
19
|
+
def audit_impl(cfn_model)
|
20
|
+
violating_delivery_streams =
|
21
|
+
cfn_model.resources_by_type('AWS::KinesisFirehose::DeliveryStream').select do |delivery_stream|
|
22
|
+
violating_delivery_stream?(delivery_stream)
|
23
|
+
end
|
24
|
+
|
25
|
+
violating_delivery_streams.map(&:logical_resource_id)
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def violating_delivery_stream?(delivery_stream)
|
31
|
+
if delivery_stream.deliveryStreamType == 'KinesisStreamAsSource'
|
32
|
+
false
|
33
|
+
elsif delivery_stream.deliveryStreamEncryptionConfigurationInput.nil?
|
34
|
+
true
|
35
|
+
else
|
36
|
+
delivery_stream.deliveryStreamEncryptionConfigurationInput['KeyType'].nil?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'cfn-nag/violation'
|
4
|
+
require_relative 'base'
|
5
|
+
|
6
|
+
class LambdaFunctionInsideVPCRule < BaseRule
|
7
|
+
def rule_text
|
8
|
+
'Lambda functions should be deployed inside a VPC'
|
9
|
+
end
|
10
|
+
|
11
|
+
def rule_type
|
12
|
+
Violation::WARNING
|
13
|
+
end
|
14
|
+
|
15
|
+
def rule_id
|
16
|
+
'W89'
|
17
|
+
end
|
18
|
+
|
19
|
+
def audit_impl(cfn_model)
|
20
|
+
lambda_functions = cfn_model.resources_by_type('AWS::Lambda::Function')
|
21
|
+
violating_lambda_functions = lambda_functions.select do |lambda_function|
|
22
|
+
lambda_function.vpcConfig.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
violating_lambda_functions.map(&:logical_resource_id)
|
26
|
+
end
|
27
|
+
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.7.
|
4
|
+
version: 0.7.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Kascic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -165,7 +165,7 @@ dependencies:
|
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
167
|
description: Auditing tool for CloudFormation templates
|
168
|
-
email:
|
168
|
+
email:
|
169
169
|
executables:
|
170
170
|
- cfn_nag
|
171
171
|
- cfn_nag_rules
|
@@ -197,6 +197,7 @@ files:
|
|
197
197
|
- lib/cfn-nag/custom_rules/AmplifyAppOauthTokenRule.rb
|
198
198
|
- lib/cfn-nag/custom_rules/AmplifyBranchBasicAuthConfigPasswordRule.rb
|
199
199
|
- lib/cfn-nag/custom_rules/ApiGatewayAccessLoggingRule.rb
|
200
|
+
- lib/cfn-nag/custom_rules/ApiGatewayCacheEncryptedRule.rb
|
200
201
|
- lib/cfn-nag/custom_rules/ApiGatewayDeploymentUsagePlanRule.rb
|
201
202
|
- lib/cfn-nag/custom_rules/ApiGatewayMethodAuthorizationTypeRule.rb
|
202
203
|
- lib/cfn-nag/custom_rules/ApiGatewaySecurityPolicyRule.rb
|
@@ -275,10 +276,12 @@ files:
|
|
275
276
|
- lib/cfn-nag/custom_rules/KMSKeyRotationRule.rb
|
276
277
|
- lib/cfn-nag/custom_rules/KMSKeyWildcardPrincipalRule.rb
|
277
278
|
- lib/cfn-nag/custom_rules/KendraIndexServerSideEncryptionConfigurationKmsKeyIdRule.rb
|
279
|
+
- lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamEncryptionRule.rb
|
278
280
|
- lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamRedshiftDestinationConfigurationPasswordRule.rb
|
279
281
|
- lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamSplunkDestinationConfigurationHECTokenRule.rb
|
280
282
|
- lib/cfn-nag/custom_rules/KinesisStreamStreamEncryptionRule.rb
|
281
283
|
- lib/cfn-nag/custom_rules/LambdaFunctionCloudWatchLogsRule.rb
|
284
|
+
- lib/cfn-nag/custom_rules/LambdaFunctionInsideVPCRule.rb
|
282
285
|
- lib/cfn-nag/custom_rules/LambdaPermissionEventSourceTokenRule.rb
|
283
286
|
- lib/cfn-nag/custom_rules/LambdaPermissionInvokeFunctionActionRule.rb
|
284
287
|
- lib/cfn-nag/custom_rules/LambdaPermissionWildcardPrincipalRule.rb
|
@@ -388,7 +391,7 @@ homepage: https://github.com/stelligent/cfn_nag
|
|
388
391
|
licenses:
|
389
392
|
- MIT
|
390
393
|
metadata: {}
|
391
|
-
post_install_message:
|
394
|
+
post_install_message:
|
392
395
|
rdoc_options: []
|
393
396
|
require_paths:
|
394
397
|
- lib
|
@@ -404,9 +407,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
404
407
|
- !ruby/object:Gem::Version
|
405
408
|
version: '0'
|
406
409
|
requirements: []
|
407
|
-
|
408
|
-
|
409
|
-
signing_key:
|
410
|
+
rubygems_version: 3.1.2
|
411
|
+
signing_key:
|
410
412
|
specification_version: 4
|
411
413
|
summary: cfn-nag
|
412
414
|
test_files: []
|