Class: RDSInstanceMasterUsernameRule

Inherits:
BaseRule
  • Object
show all
Defined in:
lib/cfn-nag/custom_rules/RDSInstanceMasterUsernameRule.rb

Overview

cfn_nag rules related to RDS Instance master username

Instance Method Summary collapse

Methods inherited from BaseRule

#audit

Instance Method Details

#audit_impl(cfn_model) ⇒ Object

Warning: if somebody applies parameter values via JSON, this will compare that.… probably shouldn’t be doing that though - if it’s NoEcho there’s a good reason bother checking synthesized_value? that would be the indicator.….



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/cfn-nag/custom_rules/RDSInstanceMasterUsernameRule.rb', line 26

def audit_impl(cfn_model)
  violating_rdsinstances = cfn_model.resources_by_type('AWS::RDS::DBInstance')
                                    .select do |instance|
    if instance.masterUsername.nil?
      false
    else
      !references_no_echo_parameter_without_default?(cfn_model,
                                                     instance.masterUsername)
    end
  end

  violating_rdsinstances.map(&:logical_resource_id)
end

#rule_idObject



17
18
19
# File 'lib/cfn-nag/custom_rules/RDSInstanceMasterUsernameRule.rb', line 17

def rule_id
  'F24'
end

#rule_textObject



8
9
10
11
# File 'lib/cfn-nag/custom_rules/RDSInstanceMasterUsernameRule.rb', line 8

def rule_text
  'RDS instance master username must be Ref to NoEcho Parameter. Default ' \
  'credentials are not recommended'
end

#rule_typeObject



13
14
15
# File 'lib/cfn-nag/custom_rules/RDSInstanceMasterUsernameRule.rb', line 13

def rule_type
  Violation::FAILING_VIOLATION
end