Repository navigation
Fix RPC response validation with string keys - #22142
Yeagerist0 wants to merge 1 commit into
Conversation
Signed-off-by: Yeagerist0 <180412661+Yeagerist0@users.noreply.github.com>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Description
Msf::RPC::JSON::Requestsupportssymbolize_names: false, but its JSON-RPC version check always looks up:jsonrpc.JSON.parsereturns"jsonrpc"in that mode, so every otherwise valid response is rejected asInvalidResponse.Use the selected key format for the version check and add focused response-processing specs. This also contributes request coverage toward #21518. No API or default-behavior change is intended.
AI tools used: Codex helped identify the mismatch, write the fix and regression specs, and run verification. I reviewed the resulting diff and test output.
Setup and Reproduction
On Ruby 3.3.8, instantiate
Msf::RPC::JSON::Requestwithmethod: 'core.version'andsymbolize_names: false, then process{"jsonrpc":"2.0","id":1,"result":{"version":"6"}}. Before the change, the request fires anInvalidResponseerrback despite the valid version. After the change, it fires aResponsecallback with string keys in the result.Verification
bundle exec rspec spec/lib/msf/core/rpc/json/request_spec.rbwith the repository's locked dependencies and confirm all 3 examples pass.1.0and confirmInvalidResponseis returned.Results and evidence
The 3 new RSpec examples passed with an isolated bootstrap using the vendored
em-http-requestand RSpec gems (3 examples, 0 failures). A separate direct response-processing check passed 4 valid/invalid combinations across both key formats.ruby -cpassed on both changed files, and RuboCop reported no offenses in the new spec.The full
bundle exec rspeccommand could not run in this checkout: its current Gemfile.lock references gem versions unavailable in the local vendor bundle. The existing request file has pre-existing RuboCop offenses; the changed line adds none. No network service or credentials are needed for these specs.