Skip to content

Integrate SystemDetailTable component into Host Details CVEs tab - #1025

Closed
nofaralfasi wants to merge 9 commits into
theforeman:developfrom
nofaralfasi:new_cve_tab
Closed

Integrate SystemDetailTable component into Host Details CVEs tab#1025
nofaralfasi wants to merge 9 commits into
theforeman:developfrom
nofaralfasi:new_cve_tab

Conversation

@nofaralfasi

@nofaralfasi nofaralfasi commented Jul 15, 2025

Copy link
Copy Markdown
Collaborator

Tests still need to be fixed.

Summary by Sourcery

Add new CVEs tab and host-filtering capabilities, enhance obfuscation and cloud forwarding logic, inject package profile upload hooks, and bump version and dependencies

New Features:

  • Add CVEsHostDetailsTab and InsightsVulnerability pages using Scalprum integration and placeholder layout
  • Support host-level filtering in inventory report generation via hosts_filter parameter across jobs, rake tasks, archive naming, and queries
  • Introduce a package_profile upload extension to trigger asynchronous host-specific report generation after package profile uploads in InsightsCloud
  • Enhance CloudRequestForwarder to accept host context and include a Forwarded header with subscription uuid for telemetry requests
  • Enable dynamic certificate source selection (manifest vs local advisor engine) in upload_report_job and cert_auth

Enhancements:

  • Refactor fact_helpers to support hierarchical hostname and IPv4/IPv6 obfuscation using global settings and insights-client facts with JSON parsing and SHA1/IP sequencing fallbacks
  • Skip inventory_hosts_sync execution for local advisor engine
  • Remove obsolete katello_agent_running field from slice generator

Build:

  • Bump foreman_rh_cloud package version to 12.1.3 and add @scalprum/react-core and @scalprum/core dependencies

Documentation:

  • Update README with DeepWiki badge and project overview link

Tests:

  • Extend and update unit tests for obfuscation logic, hosts_filter support, CloudRequestForwarder, certificate handling, and new page components

MariaAga and others added 8 commits July 7, 2025 08:17
Requests that are generated by a host, as opposed to a user will receive a forwarded header with host uuid.
… host (theforeman#1011)

* Enable hosts filter in report
* Observe package upload actions in Katello
* Switch to foreman cert when in IoP mode
* Make rubocop happy
* Fix filtering errors
@sourcery-ai

sourcery-ai Bot commented Jul 15, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR integrates a new CVE tab into the UI via Scalprum modules, significantly refactors inventory upload by adding robust hostname and IP obfuscation controlled by global and per-host settings with JSON resilience, introduces a hosts_filter parameter throughout the report-generation pipeline, enhances cloud telemetry forwarding by including host context and dynamic certificate selection, and aligns supporting tests, versioning, and documentation accordingly.

Sequence diagram for cloud telemetry request forwarding with host context and dynamic certificate selection

sequenceDiagram
  participant Controller as MachineTelemetriesController
  participant Forwarder as CloudRequestForwarder
  participant CertAuth as CertAuth
  participant Cloud as Cloud API
  Controller->>Forwarder: forward_request(request, controller_name, branch_id, certs, host)
  Forwarder->>Forwarder: prepare_forward_params()
  Forwarder->>Forwarder: prepare_request_opts(..., certs, host)
  Forwarder->>Forwarder: prepare_forwarded_header(host)
  Forwarder->>Cloud: execute_cloud_request(request_opts)
  Note over Forwarder,Cloud: request includes Forwarded header and correct certs
  Cloud-->>Forwarder: response
  Forwarder-->>Controller: response
Loading

Class diagram for obfuscation logic and report generation changes

classDiagram
  class FactHelpers {
    +obfuscate_hostname?(host)
    +fqdn(host)
    +obfuscate_ips?(host)
    +host_ips(host)
    +obfuscated_ips(host)
    +obfuscate_ip(ip, ips_dict)
  }
  class ArchivedReport {
    +render(organization, filter)
  }
  class Queries {
    +for_org(organization_id, use_batches, hosts_query)
  }
  class GenerateReportJob {
    +plan(base_folder, organization_id, disconnected, hosts_filter)
    +hosts_filter
  }
  FactHelpers <|-- ArchivedReport
  ArchivedReport <|-- Queries
  Queries <|-- GenerateReportJob
Loading

Class diagram for Scalprum context and CVE tab components

classDiagram
  class ScalprumContextWrapper {
    +config
    +mockUser
    +children
  }
  class CVEsHostDetailsTab {
    +ScalprumComponent
    +PageLayout
  }
  class CVEsHostDetailsTabWrapper {
    +ScalprumContextWrapper
    +CVEsHostDetailsTab
  }
  ScalprumContextWrapper <|-- CVEsHostDetailsTabWrapper
  CVEsHostDetailsTabWrapper *-- CVEsHostDetailsTab
Loading

Class diagram for InsightsCloud::PackageProfileUploadExtensions concern

classDiagram
  class PackageProfileUploadExtensions {
    +generate_host_report()
  }
  class CandlepinDynflowProxyController
  CandlepinDynflowProxyController <|.. PackageProfileUploadExtensions
Loading

File-Level Changes

Change Details Files
Refactor hostname and IP obfuscation: support global and per-host settings, resilient JSON parsing, and dynamic allocation of obfuscated IPs
  • Implement obfuscate_hostname? and obfuscate_ips? honoring Setting and insights_client facts
  • Update fqdn to parse 'insights_client::obfuscated_hostname' JSON and fallback to SHA1-based obfuscation
  • Enhance obfuscated_ips to parse 'insights_client::obfuscated_ipv4' and auto-generate missing IPs via default_proc
  • Add comprehensive tests covering hostname and IP obfuscation scenarios
lib/foreman_inventory_upload/generators/fact_helpers.rb
test/unit/fact_helpers_test.rb
Add hosts_filter support to inventory report generation and slicing
  • Extend GenerateReportJob plan signature to accept and propagate hosts_filter
  • Update Queries.for_org, rake task, and archived_report to handle hosts_query parameter
  • Modify facts_archive_name to include optional filter suffix
  • Adjust Slice generator and related tests to expect hosts_filter in query and output naming
lib/foreman_inventory_upload/async/generate_report_job.rb
lib/tasks/rh_cloud_inventory.rake
lib/foreman_inventory_upload/generators/queries.rb
lib/foreman_inventory_upload/generators/archived_report.rb
lib/foreman_inventory_upload.rb
Enhance cloud request forwarding to include host context and dynamic certificate selection
  • ForwardRequest and prepare_request_opts now accept host argument to compute Forwarded header
  • Extract certificate retrieval into certificate, manifest_certificate and foreman_certificate methods
  • Apply ForemanRhCloud.with_local_advisor_engine? to choose between manifest and local certificates
  • Include KatelloCVEHelper in forwarder tests and update tests to pass host context
app/services/foreman_rh_cloud/cloud_request_forwarder.rb
app/services/foreman_rh_cloud/cert_auth.rb
test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb
lib/foreman_inventory_upload/async/upload_report_job.rb
Implement new CVE tab and vulnerability pages using Scalprum modules with context provider
  • Rework CVEsHostDetailsTab and InsightsVulnerability to use ScalprumComponent within PageLayout
  • Wrap components with ScalprumContextWrapper providing mock ScalprumProvider configuration
  • Update fills and routes to render wrapper components
  • Add @scalprum/react-core/core dependencies in package.json and scaffold ScalprumContext
webpack/CVEsHostDetailsTab/CVEsHostDetailsTab.js
webpack/InsightsVulnerability/InsightsVulnerability.js
webpack/common/ScalprumModule/ScalprumContext.js
webpack/ForemanRhCloudFills.js
webpack/ForemanRhCloudPages.js
package.json
webpack/CVEsHostDetailsTab/index.js
Miscellaneous: bump version, update README, remove deprecated fields, and adjust engine and tests
  • Bump version to 12.1.3 in lib/foreman_rh_cloud/version.rb and package.json
  • Add DeepWiki badge and project overview section in README
  • Remove deprecated katello_agent_running field and adapt slice generator tests
  • Update engine to include PackageProfileUploadExtensions and skip InventorySync for local advisor
  • Add package_profile_upload_extensions concern and adjust archived_report_generator_test
lib/foreman_rh_cloud/version.rb
README.md
lib/foreman_inventory_upload/generators/slice.rb
lib/inventory_sync/async/inventory_hosts_sync.rb
lib/foreman_rh_cloud/engine.rb
app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb
test/unit/archived_report_generator_test.rb

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@nofaralfasi nofaralfasi changed the title New CVE tab Integrate CVE Detail component in Host Details CVEs tab Jul 15, 2025
@nofaralfasi
nofaralfasi force-pushed the new_cve_tab branch 2 times, most recently from eb47aa5 to 26890c1 Compare July 15, 2025 14:20
@nofaralfasi nofaralfasi changed the title Integrate CVE Detail component in Host Details CVEs tab Integrate SystemDetailTable component in Host Details CVEs tab Jul 15, 2025
@nofaralfasi nofaralfasi changed the title Integrate SystemDetailTable component in Host Details CVEs tab Integrate SystemDetailTable component into Host Details CVEs tab Jul 15, 2025
const module = './SystemDetailTable';
return (
<div className="rh-cloud-insights-vulnerability-page">
<ScalprumComponent scope={scope} module={module} />

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.

This is likely missing systemId. cc @leSamo

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I need to add it.

@@ -31,7 +32,7 @@ const fills = [
{
slot: 'host-details-page-tabs',
name: 'CVEs',

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.

Tab name should be "Vulnerabilities"

component: props => <CVEsHostDetailsTabWrapper {...props} />,
weight: 300,
metadata: {
hideTab: vulnerabilityDisabled,

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.

What are the conditions for hiding the Vulnerabilities tab?

@nofaralfasi nofaralfasi Jul 16, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The vulnerabilityDisabled function determines whether the vulnerability feature should be considered disabled, either because:

  • the host is not running RHEL, or
  • the feature is not explicitly enabled on the host, which depends on whether the Red Hat Insights Advisor engine is active locally (here).

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've got some issues with it when it got hidden, eventough I had the feature enabled. Could it be an issue with the RHEL check?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not sure, it's working fine for me. Maybe try debugging and see what's going on?

@nofaralfasi

Copy link
Copy Markdown
Collaborator Author

Closing this PR in favor of #1031, where the work will continue.

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.

5 participants