Skip to content

Add/get report hosts command#2861

Open
ozgen wants to merge 16 commits intomainfrom
add/get-report-hosts-command
Open

Add/get report hosts command#2861
ozgen wants to merge 16 commits intomainfrom
add/get-report-hosts-command

Conversation

@ozgen
Copy link
Copy Markdown
Member

@ozgen ozgen commented Apr 2, 2026

What

  • Move report host handling into separate files.
  • Add management support for host-only responses.
  • Add the get_report_hosts GMP command.
  • Add documentation for the new command.
  • Verify by build and manual gvm-cli testing.

Why

  • To separate host-specific logic from get_reports.
  • To improve maintainability and code organization.
  • To support fetching only report hosts when full report data is not needed.
  • To help reduce large GMP response sizes.

References

GEA-1692

ozgen added 4 commits April 2, 2026 10:02
Extract report host related SQL and XML generation logic from the
existing report handling code into dedicated report hosts modules.

Keep the existing behavior unchanged and prepare the codebase for a
separate get_report_hosts GMP command.
Add management-layer handling for sending report host XML separately
from get_reports.

Reuse the existing filtering and host selection logic, including
result_hosts_only and container scan handling, so host-only responses
can be generated without changing the existing report output.
Introduce the get_report_hosts GMP command for retrieving host data
from a single report.

Support report_id, filter parsing and lean mode, and route the command
through the new management-layer report hosts handling.
@ozgen ozgen requested review from a team as code owners April 2, 2026 08:09
@ozgen ozgen marked this pull request as draft April 2, 2026 08:09
@ozgen ozgen marked this pull request as ready for review April 2, 2026 08:28
@greenbonebot greenbonebot enabled auto-merge (rebase) April 2, 2026 09:37
Copy link
Copy Markdown
Contributor

@mattmundell mattmundell left a comment

Choose a reason for hiding this comment

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

The new command and the report host extraction look like great ideas.

@ozgen ozgen force-pushed the add/get-report-hosts-command branch from cd7e0c8 to eaa5ae3 Compare April 2, 2026 11:13
@ozgen ozgen requested a review from mattmundell April 2, 2026 11:28
@ozgen ozgen force-pushed the add/get-report-hosts-command branch from 4ce038c to 45d7914 Compare April 2, 2026 14:40
@ozgen ozgen requested a review from mattmundell April 2, 2026 14:42
@ozgen ozgen requested a review from mattmundell April 2, 2026 21:40
</summary>
</option>
<option>
<name>rows</name>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering about these options. From what I can see they still need to be implemented. I guess that will be quite complex (for one, due to result_hosts_only there may need to also be a result filter in GET_REPORT_HOSTS).

If it's going to be some time until they're implemented then maybe they should be hidden here.

Copy link
Copy Markdown
Member Author

@ozgen ozgen Apr 3, 2026

Choose a reason for hiding this comment

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

fixed: d3dc449

ozgen and others added 4 commits April 3, 2026 13:21
Co-authored-by: Matt Mundell <32057441+mattmundell@users.noreply.github.com>
Extract duplicated report filter control setup into a shared helper
and use it in manage_report_hosts and manage_sql_report_hosts.

Remove duplicate initialization in gmp_report_hosts.c and guard
temporary directory cleanup with a dedicated mkdtemp success flag.
Document the lean parameter for report hosts and remove options that are
not currently implemented to keep the GMP documentation aligned with
actual behavior.
@ozgen ozgen requested a review from mattmundell April 3, 2026 12:58
&term,
NULL,
NULL,
&sort_field,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Any reason for keeping this (and levels, compliance_levels, delta_stats, search_phrase and zone)?

Any arg to manage_report_filter_controls that comes after term is allowed to be NULL. And print_report_hosts_xml only needs f_host* in ctx.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed: 3bf13fa

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, looking at this again I think these are actually used, but they're used to filter the results instead of the hosts. I see that the get arg is passed to fill_filtered_results_hosts and then to the result iterator. Whereas the get arg is also passed to print_report_hosts_xml but is barely used there. Do you agree?

Perhaps it's better to make it clear here that this is filtering the results. We have a precedent in GET_REPORTS which has both filter and report_filter. The GET_REPORT doc just makes it clear what each is for.

In the future there could be a report_hosts_filter.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

fixed: d5df5b9

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I agree that the current behavior is result-driven rather than a pure host-level filter. I have adjusted the code accordingly, and I can follow up with a doc clarification as well.

@ozgen ozgen requested a review from mattmundell April 6, 2026 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants