Skip to content
This repository was archived by the owner on Feb 11, 2025. It is now read-only.

Conversation

@grumpybozo
Copy link

@grumpybozo grumpybozo commented Dec 14, 2024

Under ruby 3.3, nicinfo fails if given an argument like "1=" with an error & stack trace citing line 190 in config.rb and missing classes/args to YAML::load. The apparent root cause is the adoption of "Psych.safe_load" in Ruby v3.1.1

This patch adds permitted_classes and 'aliases:true' to get past those errors. e.g.:

 # nicinfo 1=
 # NicInfo v.1.5.2
 /opt/local/lib/ruby3.3/3.3.0/psych/class_loader.rb:99:in `find': Tried to load unspecified class: NicInfo::DataTree (Psych::DisallowedClass)
        from /opt/local/lib/ruby3.3/3.3.0/psych/class_loader.rb:28:in `load'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/to_ruby.rb:426:in `resolve_class'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/to_ruby.rb:215:in `visit_Psych_Nodes_Mapping'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/visitor.rb:30:in `visit'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/visitor.rb:6:in `accept'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/to_ruby.rb:320:in `visit_Psych_Nodes_Document'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/visitor.rb:30:in `visit'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/visitor.rb:6:in `accept'
        from /opt/local/lib/ruby3.3/3.3.0/psych/visitors/to_ruby.rb:35:in `accept'
        from /opt/local/lib/ruby3.3/3.3.0/psych.rb:334:in `safe_load'
        from /opt/local/lib/ruby3.3/3.3.0/psych.rb:369:in `load'
        from /opt/local/lib/ruby3.3/gems/3.3.0/gems/nicinfo-1.5.2/lib/nicinfo/config.rb:190:in `load_as_yaml'
        from /opt/local/lib/ruby3.3/gems/3.3.0/gems/nicinfo-1.5.2/lib/nicinfo/nicinfo_main.rb:491:in `run'
        from /opt/local/lib/ruby3.3/gems/3.3.0/gems/nicinfo-1.5.2/bin/nicinfo:25:in `<top (required)>'
        from /opt/local/bin/nicinfo:25:in `load'
        from /opt/local/bin/nicinfo:25:in `<main>'`

The single changed line is developed from the errors I got, not derived from examining the existing code.

Under ruby3.3, nicinfo fails if given an argument like "1=" with an error & stack trace citing line 190 in config.rb and missing classes/args to YAML::load 
This adds permitted_classes and 'aliases:true' to get past that error
@grumpybozo grumpybozo changed the title Update config.rb to work on 3.3 Update config.rb to work on 3.1 and later Dec 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant