-
Notifications
You must be signed in to change notification settings - Fork 116
Open
Description
Hi there; We're just hitting warning with a newer version of rexml with the WinRM gem:
> REXML::VERSION
=> "3.4.4"
> WinRM::VERSION
=> "2.3.9"
Warning:
.rvm/gems/ruby-3.3.8@metasploit-framework/gems/rexml-3.4.4/lib/rexml/xpath.rb:67: warning: REXML::XPath.each, REXML::XPath.first, REXML::XPath.match dropped support for nodeset...
I tracked this down to this line of code:
62: def raise_if_wsman_fault
63: soap_errors = REXML::XPath.match(
64: response_xml,
65: "//*[local-name() = 'Envelope']/*[local-name() = 'Body']/*[local-name() = 'Fault']/*"
66: )
67: return if soap_errors.empty?
68:
=> 69: fault = REXML::XPath.first(
70: soap_errors,
71: "//*[local-name() = 'WSManFault']"
72: )
73: raise WinRMWSManFault.new(fault.to_s, fault.attributes['Code']) unless fault.nil?
74: endIt looks like soap_errors is an array which REXML::XPath.first no longer supports:
[3] pry(#<WinRM::ResponseHandler>)> soap_errors
=> [<s:Code> ... </>, <s:Reason> ... </>, <s:Detail> ... </>]It looks like this should be an equivalent implementation:
- fault = REXML::XPath.first(
- soap_errors,
- "//*[local-name() = 'WSManFault']"
- )
+ fault = soap_errors.find { |soap_error| REXML::XPath.first(soap_error, "//*[local-name() = 'WSManFault']") }Example:
[10] pry(#<WinRM::ResponseHandler>)> soap_errors.find { |soap_error| REXML::XPath.first(soap_error, "//*[local-name() = 'WSManFault']") }.to_s
=> "<s:Code><s:Value>s:Receiver</s:Value><s:Subcode><s:Value>w:TimedOut</s:Value></s:Subcode></s:Code>"Let me know if the code change makes sense and I can put up a PR π―
bdwyertech and norajbdwyertech
Metadata
Metadata
Assignees
Labels
No labels