cfn-nag 0.7.15 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/bin/cfn_nag_rules +3 -3
  3. data/bin/spcm_scan +1 -1
  4. data/lib/cfn-nag/base_rule.rb +7 -1
  5. data/lib/cfn-nag/cfn_nag.rb +16 -20
  6. data/lib/cfn-nag/cfn_nag_config.rb +3 -3
  7. data/lib/cfn-nag/cfn_nag_executor.rb +7 -7
  8. data/lib/cfn-nag/cli_options.rb +19 -8
  9. data/lib/cfn-nag/custom_rules/AlexaASKSkillAuthenticationConfigurationClientSecretRule.rb +1 -1
  10. data/lib/cfn-nag/custom_rules/AlexaASKSkillAuthenticationConfigurationRefreshTokenRule.rb +1 -1
  11. data/lib/cfn-nag/custom_rules/AmazonMQBrokerUsersPasswordRule.rb +1 -1
  12. data/lib/cfn-nag/custom_rules/AmplifyAppAccessTokenRule.rb +2 -2
  13. data/lib/cfn-nag/custom_rules/AmplifyAppBasicAuthConfigPasswordRule.rb +2 -2
  14. data/lib/cfn-nag/custom_rules/AmplifyAppOauthTokenRule.rb +2 -2
  15. data/lib/cfn-nag/custom_rules/AmplifyBranchBasicAuthConfigPasswordRule.rb +2 -2
  16. data/lib/cfn-nag/custom_rules/ApiGatewayAccessLoggingRule.rb +1 -1
  17. data/lib/cfn-nag/custom_rules/ApiGatewayCacheEncryptedRule.rb +1 -1
  18. data/lib/cfn-nag/custom_rules/ApiGatewayMethodAuthorizationTypeRule.rb +1 -1
  19. data/lib/cfn-nag/custom_rules/AppStreamDirectoryConfigServiceAccountCredentialsAccountPasswordRule.rb +3 -3
  20. data/lib/cfn-nag/custom_rules/CodePipelineWebhookAuthenticationConfigurationSecretTokenRule.rb +2 -2
  21. data/lib/cfn-nag/custom_rules/CognitoIdentityPoolAllowUnauthenticatedIdentitiesRule.rb +1 -1
  22. data/lib/cfn-nag/custom_rules/DMSEndpointMongoDbSettingsPasswordRule.rb +2 -2
  23. data/lib/cfn-nag/custom_rules/DMSEndpointPasswordRule.rb +2 -2
  24. data/lib/cfn-nag/custom_rules/DirectoryServiceMicrosoftADPasswordRule.rb +2 -2
  25. data/lib/cfn-nag/custom_rules/DirectoryServiceSimpleADPasswordRule.rb +2 -2
  26. data/lib/cfn-nag/custom_rules/DocDBDBClusterMasterUserPasswordRule.rb +2 -2
  27. data/lib/cfn-nag/custom_rules/EC2NetworkAclEntryProtocolRule.rb +3 -7
  28. data/lib/cfn-nag/custom_rules/EKSClusterEncryptionRule.rb +1 -3
  29. data/lib/cfn-nag/custom_rules/EMRClusterKerberosAttributesADDomainJoinPasswordRule.rb +2 -2
  30. data/lib/cfn-nag/custom_rules/EMRClusterKerberosAttributesCrossRealmTrustPrincipalPasswordRule.rb +3 -3
  31. data/lib/cfn-nag/custom_rules/EMRClusterKerberosAttributesKdcAdminPasswordRule.rb +2 -2
  32. data/lib/cfn-nag/custom_rules/ElastiCacheReplicationGroupAuthTokenRule.rb +2 -2
  33. data/lib/cfn-nag/custom_rules/GameLiftFleetInboundPortRangeRule.rb +2 -0
  34. data/lib/cfn-nag/custom_rules/IAMUserLoginProfilePasswordRule.rb +2 -2
  35. data/lib/cfn-nag/custom_rules/IamUserLoginProfilePasswordResetRule.rb +4 -6
  36. data/lib/cfn-nag/custom_rules/KMSKeyWildcardPrincipalRule.rb +1 -1
  37. data/lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamRedshiftDestinationConfigurationPasswordRule.rb +3 -3
  38. data/lib/cfn-nag/custom_rules/KinesisFirehoseDeliveryStreamSplunkDestinationConfigurationHECTokenRule.rb +3 -3
  39. data/lib/cfn-nag/custom_rules/KinesisStreamStreamEncryptionRule.rb +3 -5
  40. data/lib/cfn-nag/custom_rules/LambdaPermissionEventSourceTokenRule.rb +2 -2
  41. data/lib/cfn-nag/custom_rules/LambdaPermissionInvokeFunctionActionRule.rb +1 -1
  42. data/lib/cfn-nag/custom_rules/ManagedBlockchainMemberMemberFabricConfigurationAdminPasswordRule.rb +4 -7
  43. data/lib/cfn-nag/custom_rules/OpsWorksAppAppSourcePasswordRule.rb +2 -2
  44. data/lib/cfn-nag/custom_rules/OpsWorksAppSslConfigurationPrivateKeyRule.rb +2 -2
  45. data/lib/cfn-nag/custom_rules/OpsWorksStackCustomCookbooksSourcePasswordRule.rb +2 -2
  46. data/lib/cfn-nag/custom_rules/OpsWorksStackRdsDbInstancesDbPasswordRule.rb +2 -2
  47. data/lib/cfn-nag/custom_rules/PinpointAPNSChannelPrivateKeyRule.rb +2 -2
  48. data/lib/cfn-nag/custom_rules/PinpointAPNSChannelTokenKeyRule.rb +2 -2
  49. data/lib/cfn-nag/custom_rules/PinpointAPNSSandboxChannelPrivateKeyRule.rb +2 -2
  50. data/lib/cfn-nag/custom_rules/PinpointAPNSSandboxChannelTokenKeyRule.rb +2 -2
  51. data/lib/cfn-nag/custom_rules/PinpointAPNSVoipChannelPrivateKeyRule.rb +2 -2
  52. data/lib/cfn-nag/custom_rules/PinpointAPNSVoipChannelTokenKeyRule.rb +2 -2
  53. data/lib/cfn-nag/custom_rules/PinpointAPNSVoipSandboxChannelPrivateKeyRule.rb +2 -2
  54. data/lib/cfn-nag/custom_rules/PinpointAPNSVoipSandboxChannelTokenKeyRule.rb +2 -2
  55. data/lib/cfn-nag/custom_rules/RDSDBClusterMasterUserPasswordRule.rb +2 -2
  56. data/lib/cfn-nag/custom_rules/RDSDBInstanceMasterUserPasswordRule.rb +2 -2
  57. data/lib/cfn-nag/custom_rules/RDSDBInstanceMasterUsernameRule.rb +2 -2
  58. data/lib/cfn-nag/custom_rules/RedshiftClusterMasterUserPasswordRule.rb +2 -2
  59. data/lib/cfn-nag/custom_rules/ResourceWithExplicitNameRule.rb +1 -1
  60. data/lib/cfn-nag/custom_rules/SecretsManagerSecretKmsKeyIdRule.rb +1 -1
  61. data/lib/cfn-nag/custom_rules/SecurityGroupIngressOpenToWorldRule.rb +1 -1
  62. data/lib/cfn-nag/custom_rules/SecurityGroupIngressPortRangeRule.rb +1 -1
  63. data/lib/cfn-nag/custom_rules/SecurityGroupMissingEgressRule.rb +1 -1
  64. data/lib/cfn-nag/custom_rules/SecurityGroupRuleDescriptionRule.rb +2 -2
  65. data/lib/cfn-nag/custom_rules/base.rb +7 -1
  66. data/lib/cfn-nag/deny_list_loader.rb +43 -0
  67. data/lib/cfn-nag/iam_complexity_metric/spcm.rb +3 -3
  68. data/lib/cfn-nag/result_view/json_results.rb +1 -1
  69. data/lib/cfn-nag/result_view/sarif_results.rb +103 -0
  70. data/lib/cfn-nag/result_view/stdout_results.rb +1 -1
  71. data/lib/cfn-nag/rule_definition.rb +6 -3
  72. data/lib/cfn-nag/rule_registry.rb +1 -0
  73. data/lib/cfn-nag/util/enforce_reference_parameter.rb +1 -1
  74. data/lib/cfn-nag/version.rb +6 -0
  75. data/lib/cfn-nag/violation.rb +11 -0
  76. data/lib/cfn-nag/violation_filtering.rb +9 -9
  77. metadata +7 -5
  78. data/lib/cfn-nag/blacklist_loader.rb +0 -43
@@ -29,5 +29,5 @@ end
29
29
  # is not present; otherwise returns true
30
30
  def no_echo_and_no_default_parameter_check(cfn_model, key_to_check)
31
31
  parameter = cfn_model.parameters[key_to_check['Ref']]
32
- truthy?(parameter.noEcho) && parameter.default.nil? ? false : true
32
+ !(truthy?(parameter.noEcho) && parameter.default.nil?)
33
33
  end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CfnNagVersion
4
+ # This is managed at release time via scripts/publish.sh
5
+ VERSION = '0.8.2'
6
+ end
@@ -6,18 +6,22 @@ require_relative 'rule_definition'
6
6
  class Violation < RuleDefinition
7
7
  attr_reader :logical_resource_ids, :line_numbers
8
8
 
9
+ # rubocop:disable Metrics/ParameterLists
9
10
  def initialize(id:,
11
+ name:,
10
12
  type:,
11
13
  message:,
12
14
  logical_resource_ids: [],
13
15
  line_numbers: [])
14
16
  super id: id,
17
+ name: name,
15
18
  type: type,
16
19
  message: message
17
20
 
18
21
  @logical_resource_ids = logical_resource_ids
19
22
  @line_numbers = line_numbers
20
23
  end
24
+ # rubocop:enable Metrics/ParameterLists
21
25
 
22
26
  def to_s
23
27
  "#{super} #{@logical_resource_ids}"
@@ -57,6 +61,13 @@ class Violation < RuleDefinition
57
61
  end
58
62
  end
59
63
 
64
+ def fatal_violation(message)
65
+ Violation.new(id: 'FATAL',
66
+ name: 'system',
67
+ type: Violation::FAILING_VIOLATION,
68
+ message: message)
69
+ end
70
+
60
71
  private
61
72
 
62
73
  def empty?(array)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'cfn-nag/profile_loader'
4
- require 'cfn-nag/blacklist_loader'
4
+ require 'cfn-nag/deny_list_loader'
5
5
 
6
6
  module ViolationFiltering
7
7
  def filter_violations_by_profile(profile_definition:, rule_definitions:, violations:)
@@ -20,19 +20,19 @@ module ViolationFiltering
20
20
  end
21
21
  end
22
22
 
23
- def filter_violations_by_blacklist(blacklist_definition:, rule_definitions:, violations:)
24
- blacklist = nil
25
- unless blacklist_definition.nil?
23
+ def filter_violations_by_deny_list(deny_list_definition:, rule_definitions:, violations:)
24
+ deny_list = nil
25
+ unless deny_list_definition.nil?
26
26
  begin
27
- blacklist = BlackListLoader.new(rule_definitions)
28
- .load(blacklist_definition: blacklist_definition)
29
- rescue StandardError => blacklist_load_error
30
- raise "Blacklist loading error: #{blacklist_load_error}"
27
+ deny_list = DenyListLoader.new(rule_definitions)
28
+ .load(deny_list_definition: deny_list_definition)
29
+ rescue StandardError => deny_list_load_error
30
+ raise "Deny list loading error: #{deny_list_load_error}"
31
31
  end
32
32
  end
33
33
 
34
34
  violations.reject do |violation|
35
- !blacklist.nil? && blacklist.contains_rule?(violation.id)
35
+ !deny_list.nil? && deny_list.contains_rule?(violation.id)
36
36
  end
37
37
  end
38
38
  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.15
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Kascic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 0.6.3
75
+ version: 0.6.4
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 0.6.3
82
+ version: 0.6.4
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: logging
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +180,6 @@ files:
180
180
  - bin/spcm_scan
181
181
  - lib/cfn-nag.rb
182
182
  - lib/cfn-nag/base_rule.rb
183
- - lib/cfn-nag/blacklist_loader.rb
184
183
  - lib/cfn-nag/cfn_nag.rb
185
184
  - lib/cfn-nag/cfn_nag_config.rb
186
185
  - lib/cfn-nag/cfn_nag_executor.rb
@@ -359,6 +358,7 @@ files:
359
358
  - lib/cfn-nag/custom_rules/password_base_rule.rb
360
359
  - lib/cfn-nag/custom_rules/resource_base_rule.rb
361
360
  - lib/cfn-nag/custom_rules/sub_property_with_list_password_base_rule.rb
361
+ - lib/cfn-nag/deny_list_loader.rb
362
362
  - lib/cfn-nag/iam_complexity_metric/condition_metric.rb
363
363
  - lib/cfn-nag/iam_complexity_metric/html_results_renderer.rb
364
364
  - lib/cfn-nag/iam_complexity_metric/policy_document_metric.rb
@@ -371,6 +371,7 @@ files:
371
371
  - lib/cfn-nag/result_view/colored_stdout_results.rb
372
372
  - lib/cfn-nag/result_view/json_results.rb
373
373
  - lib/cfn-nag/result_view/rules_view.rb
374
+ - lib/cfn-nag/result_view/sarif_results.rb
374
375
  - lib/cfn-nag/result_view/simple_stdout_results.rb
375
376
  - lib/cfn-nag/result_view/stdout_results.rb
376
377
  - lib/cfn-nag/rule_definition.rb
@@ -388,6 +389,7 @@ files:
388
389
  - lib/cfn-nag/util/enforce_string_or_dynamic_reference.rb
389
390
  - lib/cfn-nag/util/truthy.rb
390
391
  - lib/cfn-nag/util/wildcard_patterns.rb
392
+ - lib/cfn-nag/version.rb
391
393
  - lib/cfn-nag/violation.rb
392
394
  - lib/cfn-nag/violation_filtering.rb
393
395
  homepage: https://github.com/stelligent/cfn_nag
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yaml'
4
-
5
- class BlackListLoader
6
- def initialize(rules_registry)
7
- @rules_registry = rules_registry
8
- end
9
-
10
- def load(blacklist_definition:)
11
- raise 'Empty profile' if blacklist_definition.strip == ''
12
-
13
- blacklist_ruleset = RuleIdSet.new
14
-
15
- blacklist_hash = load_blacklist_yaml(blacklist_definition)
16
- raise 'Blacklist is malformed' unless blacklist_hash.is_a? Hash
17
-
18
- rules_to_suppress = blacklist_hash.fetch('RulesToSuppress', {})
19
- raise 'Missing RulesToSuppress key in black list' if rules_to_suppress.empty?
20
-
21
- rule_ids_to_suppress = rules_to_suppress.map { |rule| rule['id'] }
22
- rule_ids_to_suppress.each do |rule_id|
23
- check_valid_rule_id rule_id
24
- blacklist_ruleset.add_rule rule_id
25
- end
26
-
27
- blacklist_ruleset
28
- end
29
-
30
- private
31
-
32
- def load_blacklist_yaml(blacklist_definition)
33
- YAML.safe_load(blacklist_definition)
34
- rescue StandardError => yaml_parse_error
35
- raise "YAML parse of blacklist failed: #{yaml_parse_error}"
36
- end
37
-
38
- def check_valid_rule_id(rule_id)
39
- return true unless @rules_registry.by_id(rule_id).nil?
40
-
41
- raise "#{rule_id} is not a legal rule identifier from: #{@rules_registry.ids}"
42
- end
43
- end