lib/cfn-nag/cfn_nag.rb
##
# Given cloudformation json/yml, run all the rules against it
#
# Optionally include JSON with Parameters key to substitute into
# cfn_model.parameters
#
# Return a hash with failure count
#
Given cloudformation json/yml, run all the rules against it
Optionally include JSON with Parameters key to substitute into
cfn_model.parameters

Return a hash with failure count
Given cloudformation json / yml run all the rules against it Optionally include JSON with Parameters key to substitute into cfn_model . parameters Return a hash with failure count
def audit(cloudformation_string:, parameter_values_string: nil)
    violations = []
    cfn_model = CfnParser.new.parse cloudformation_string,
                                    parameter_values_string
    violations += @custom_rule_loader.execute_custom_rules(cfn_model)
    violations = filter_violations_by_profile violations
    { failure_count: Violation.count_failures(violations),
      violations: violations }
  rescue Psych::SyntaxError, ParserError => parser_error
    violations << Violation.new(id: 'FATAL',
                                type: Violation::FAILING_VIOLATION,
                                message: parser_error.to_s)
    { failure_count: Violation.count_failures(violations),
      violations: violations }
  end
def audit ( cloudformation_string : , parameter_values_string : nil ) violations = [ ] cfn_model = CfnParser . new . parse cloudformation_string , parameter_values_string violations += @custom_rule_loader . execute_custom_rules ( cfn_model ) violations = filter_violations_by_profile violations { failure_count : Violation . count_failures ( violations ) , violations : violations } rescue Psych :: SyntaxError , ParserError => parser_error violations << Violation . new ( id : 'FATAL' , type : Violation :: FAILING_VIOLATION , message : parser_error . to_s ) { failure_count : Violation . count_failures ( violations ) , violations : violations } end
Given cloudformation json/yml, run all the rules against it
Optionally include JSON with Parameters key to substitute into
cfn_model.parameters
Given cloudformation json / yml run all the rules against it Optionally include JSON with Parameters key to substitute into cfn_model . parameters
cloudformation_string
parameter_values_string