stelligent / cfn_nag

Linting tool for CloudFormation templates
MIT License
1.26k stars 212 forks source link

CI: Acceptance jobs are failing #631

Open phansys opened 1 month ago

phansys commented 1 month ago

Acceptance jobs are failing for different reasons between the 2 Ruby versions in the CI workflow.

Related to #80, #339.


Acceptance (2.5)

/opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/resource_type_validator.rb:20:in `block in validate': no implicit conversion of String into Integer (TypeError)

In this case, I think the problem is caused by the introduction of the Custom::GetFromJson resource type, which is not supported currently by cfn-model. See aws-cloudformation/aws-cloudformation-templates#439.

See stack trace ``` Linting sample templates.. /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/resource_type_validator.rb:20:in `block in validate': no implicit conversion of String into Integer (TypeError) from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/resource_type_validator.rb:19:in `each' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/resource_type_validator.rb:19:in `validate' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/schema_generator.rb:17:in `generate' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/validator/cloudformation_validator.rb:13:in `validate' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:220:in `pre_validate_model' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:62:in `parse_without_parameters' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:43:in `parse' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:87:in `audit' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:68:in `block in audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `each' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:35:in `audit_aggregate_across_files_and_render_results' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:50:in `execute_aggregate_scan' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:30:in `scan' from /opt/hostedtoolcache/Ruby/2.5.9/x64/lib/ruby/gems/2.5.0/gems/cfn-nag-0.0.0/bin/cfn_nag_scan:11:in `' from /opt/hostedtoolcache/Ruby/2.5.9/x64/bin/cfn_nag_scan:23:in `load' from /opt/hostedtoolcache/Ruby/2.5.9/x64/bin/cfn_nag_scan:23:in `
' Exception found in cfn_nag_scan, exiting.. ```

Example CI job: https://github.com/phansys/cfn_nag/actions/runs/11420528863/job/31776340749#step:4:156.

Acceptance (3.0)

/opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:319:in `const_set': wrong constant name Boto3CodeCommit.put_file (NameError)

Here, the issue seems related to the Boto3::CodeCommit.put_file macro: aws-cloudformation/aws-cloudformation-templates#105.

See stack trace ``` Linting sample templates.. /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:319:in `const_set': wrong constant name Boto3CodeCommit.put_file (NameError) from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:319:in `rescue in generate_resource_class_from_type' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:315:in `generate_resource_class_from_type' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:267:in `rescue in class_from_type_name' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:263:in `class_from_type_name' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:166:in `block in transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:165:in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:165:in `transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:86:in `parse_without_parameters' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:43:in `parse' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:87:in `audit' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:68:in `block in audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:35:in `audit_aggregate_across_files_and_render_results' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:50:in `execute_aggregate_scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:30:in `scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/bin/cfn_nag_scan:11:in `' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `load' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `
' /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:316:in `const_get': wrong constant name Boto3CodeCommit.put_file (NameError) from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:316:in `generate_resource_class_from_type' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:267:in `rescue in class_from_type_name' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:263:in `class_from_type_name' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:166:in `block in transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:[165](https://github.com/phansys/cfn_nag/actions/runs/11420528863/job/31776340963#step:4:166):in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:165:in `transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:86:in `parse_without_parameters' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:43:in `parse' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:87:in `audit' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:68:in `block in audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:35:in `audit_aggregate_across_files_and_render_results' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:50:in `execute_aggregate_scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:30:in `scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/bin/cfn_nag_scan:11:in `' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `load' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `
' /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:264:in `class_from_type_name': uninitialized constant Boto3 (NameError) from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:[166](https://github.com/phansys/cfn_nag/actions/runs/11420528863/job/31776340963#step:4:167):in `block in transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:165:in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:165:in `transform_hash_into_model_elements_with_numbers' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:86:in `parse_without_parameters' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:43:in `parse' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:87:in `audit' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:68:in `block in audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `each' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:65:in `audit_aggregate_across_files' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag.rb:35:in `audit_aggregate_across_files_and_render_results' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:50:in `execute_aggregate_scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/lib/cfn-nag/cfn_nag_executor.rb:30:in `scan' from /opt/hostedtoolcache/Ruby/3.0.7/x64/lib/ruby/gems/3.0.0/gems/cfn-nag-0.0.0/bin/cfn_nag_scan:11:in `' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `load' from /opt/hostedtoolcache/Ruby/3.0.7/x64/bin/cfn_nag_scan:25:in `
' Exception found in cfn_nag_scan, exiting.. ```

Example CI job: https://github.com/phansys/cfn_nag/actions/runs/11420528863/job/31776340963#step:4:143.