stelligent / cfn_nag

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

cfn_nag support for lastest Ruby version: Psych::DisallowedClass error #617

Open puzzler7 opened 1 year ago

puzzler7 commented 1 year ago

It seems that cfn_nag doesn't support Ruby 3.x - when trying to run cfn_nag_scan --input-path . with Ruby 3.2.0, I get the stack trace below, but it runs with Ruby 2.7.2. It looks like the Psych library updated the yaml loader to be more secure, and it now errors on trying to parse a date, as it's not one of the whitelisted classes.

Are there plans to update cfn_nag to support this?

$ ~/.gem/bin/cfn_nag_scan --input-path .
/snap/ruby/299/lib/ruby/3.2.0/psych/class_loader.rb:99:in `find': Tried to load unspecified class: Date (Psych::DisallowedClass)
        from /snap/ruby/299/lib/ruby/3.2.0/psych/class_loader.rb:28:in `load'
        from (eval):2:in `date'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/scalar_scanner.rb:66:in `tokenize'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:65:in `deserialize'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:130:in `visit_Psych_Nodes_Scalar'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:30:in `visit'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:6:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:347:in `block in revive_hash'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:345:in `each'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:345:in `each_slice'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:345:in `revive_hash'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:169:in `visit_Psych_Nodes_Mapping'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:30:in `visit'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:6:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:320:in `visit_Psych_Nodes_Document'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:30:in `visit'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/visitor.rb:6:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /snap/ruby/299/lib/ruby/3.2.0/psych.rb:334:in `safe_load'
        from /snap/ruby/299/lib/ruby/3.2.0/psych.rb:369:in `load'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/validator/resource_type_validator.rb:8:in `validate'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/validator/schema_generator.rb:17:in `generate'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/validator/cloudformation_validator.rb:13:in `validate'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:220:in `pre_validate_model'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:62:in `parse_without_parameters'
        from /home/maverick/.gem/gems/cfn-model-0.6.6/lib/cfn-model/parser/cfn_parser.rb:43:in `parse'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag.rb:87:in `audit'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag.rb:68:in `block in audit_aggregate_across_files'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag.rb:65:in `each'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag.rb:65:in `audit_aggregate_across_files'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag.rb:35:in `audit_aggregate_across_files_and_render_results'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag_executor.rb:50:in `execute_aggregate_scan'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/lib/cfn-nag/cfn_nag_executor.rb:30:in `scan'
        from /home/maverick/.gem/gems/cfn-nag-0.8.10/bin/cfn_nag_scan:11:in `<top (required)>'
        from /home/maverick/.gem/bin/cfn_nag_scan:23:in `load'
        from /home/maverick/.gem/bin/cfn_nag_scan:23:in `<main>'