This closes #19450 by introducing changes to the #valid? and #normalize methods of the OptEnum class to make it case-insensitive. This should make it slightly easier for users to set opinions by not having to remember the exact casing of opinion values. As a good example, the ldap_query module has an OUTPUT_FORMAT with options of csv and json. Since those words are acronyms and common file extensions, either csv or CSV would make sense in the context. Now users don't need to remember that exact detail. The casing of the option is normalized to what the module author specified though, so the value can still be matched exactly in the module code.
Testing
[ ] Use the ldap_query module
[ ] Set the OUTPUT_FORMAT option to CSV and see it get normalized to csv
[ ] See the module still works, showing the normalized value was used
Demo
Old:
metasploit-framework (S:0 J:0) auxiliary(gather/ldap_query) > set OUTPUT_FORMAT CSV
[-] The following options failed to validate: Value 'CSV' is not valid for option 'OUTPUT_FORMAT'.
OUTPUT_FORMAT => table
metasploit-framework (S:0 J:0) auxiliary(gather/ldap_query) >
This closes #19450 by introducing changes to the
#valid?
and#normalize
methods of theOptEnum
class to make it case-insensitive. This should make it slightly easier for users to set opinions by not having to remember the exact casing of opinion values. As a good example, theldap_query
module has an OUTPUT_FORMAT with options of csv and json. Since those words are acronyms and common file extensions, either csv or CSV would make sense in the context. Now users don't need to remember that exact detail. The casing of the option is normalized to what the module author specified though, so the value can still be matched exactly in the module code.Testing
ldap_query
moduleCSV
and see it get normalized tocsv
Demo
Old:
New: