Skip to content

Return comments for hosts over RPC#21289

Merged
adfoster-r7 merged 1 commit intorapid7:masterfrom
sjanusz-r7:rpc-hosts-returns-comments
Apr 15, 2026
Merged

Return comments for hosts over RPC#21289
adfoster-r7 merged 1 commit intorapid7:masterfrom
sjanusz-r7:rpc-hosts-returns-comments

Conversation

@sjanusz-r7
Copy link
Copy Markdown
Contributor

@sjanusz-r7 sjanusz-r7 commented Apr 14, 2026

Closes #21247

Tested in Pro. No impact, everything works. We don't display host comments anywhere in Pro's UI.

Before

No comment

>> rpc.call("db.hosts", {})
=> 
{"hosts"=>
  [{"created_at"=>1776160363,
    "address"=>"127.0.0.1",
    "mac"=>"",
    "name"=>"caea2eea7ecb",
    "state"=>"alive",
    "os_name"=>"Debian 9.6 (Linux 6.12.76-linuxkit)",
    "os_flavor"=>"",
    "os_sp"=>"",
    "os_lang"=>"",
    "updated_at"=>1776160491,
    "purpose"=>"server",
    "info"=>""}]}

After

With a comment

>> rpc.call("db.hosts", {})
=> 
{"hosts"=>
  [{"created_at"=>1776160363,
    "address"=>"127.0.0.1",
    "mac"=>"",
    "name"=>"caea2eea7ecb",
    "state"=>"alive",
    "os_name"=>"Debian 9.6 (Linux 6.12.76-linuxkit)",
    "os_flavor"=>"",
    "os_sp"=>"",
    "os_lang"=>"",
    "updated_at"=>1776160491,
    "purpose"=>"server",
    "info"=>"",
    "comments"=>"hello world, this is a comment"}]}

Verification

List the steps needed to make sure this thing works

  • Have a host in the database (you can run a module, or hosts -a x.x.x.x
  • Add comment to host using the IP hosts -m "this is an example comment" x.x.x.x
  • Boot RPC server using load msgrpc
  • Connect to RPC with msfrpc
  • run `rpc.call("db.hosts", {})
  • Confirm comment is visible
  • Verify that a host without a comment in msfconsole does not crash. Instead it returns "comments"=>""

host[:updated_at] = h.updated_at.to_i
host[:purpose] = h.purpose.to_s
host[:info] = h.info.to_s
host[:comments] = h.comments.to_s
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other lines here use .to_s as well, resulting in an empty string instead of a nil value. This follows a pattern, but unsure if the .to_s should be dropped (nil vs. empty string).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the db.hosts RPC response so host records include their comments field, aligning RPC output with what hosts shows in msfconsole and addressing issue #21247.

Changes:

  • Add comments to each host entry returned by rpc_hosts in the RPC DB API.

Comment thread lib/msf/core/rpc/v10/rpc_db.rb
@sjanusz-r7 sjanusz-r7 force-pushed the rpc-hosts-returns-comments branch from 20b6239 to 4383ad6 Compare April 14, 2026 16:25
@github-project-automation github-project-automation Bot moved this from Todo to In Progress in Metasploit Kanban Apr 15, 2026
@adfoster-r7 adfoster-r7 added the rn-enhancement release notes enhancement label Apr 15, 2026
@adfoster-r7 adfoster-r7 merged commit c3cc091 into rapid7:master Apr 15, 2026
49 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Metasploit Kanban Apr 15, 2026
@adfoster-r7
Copy link
Copy Markdown
Contributor

Release Notes

Updates the db.hosts RPC call to now additionally include the comments associated with the host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rn-enhancement release notes enhancement

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Add comments field top the db.hosts RPC endpoint

4 participants