Skip to content

feat(RHINENG-20187): Rule porting part 2 - #2625

Draft
LightOfHeaven1994 wants to merge 3 commits into
RedHatInsights:masterfrom
LightOfHeaven1994:RHINENG-20187-2
Draft

feat(RHINENG-20187): Rule porting part 2#2625
LightOfHeaven1994 wants to merge 3 commits into
RedHatInsights:masterfrom
LightOfHeaven1994:RHINENG-20187-2

Conversation

@LightOfHeaven1994

@LightOfHeaven1994 LightOfHeaven1994 commented Sep 22, 2025

Copy link
Copy Markdown
Contributor

Secure Coding Practices Checklist GitHub Link

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Support rule porting for policies by detecting new RHEL minor versions, fetching their rule IDs, and providing UI options to copy or generate tailored rules under a feature flag. Updated hooks and helpers to manage caching, skip logic, and notifications.

New Features:

  • Enable rule porting behind a 'compliance.rule_porting' feature flag in the PolicyDetails component
  • Add rule porting alerts and actions in the Tailorings component to import or create default rules for new RHEL minor versions
  • Implement createTailoring API integration with success/error notifications and automatic refresh on tailoring creation

Enhancements:

  • Fetch and compare existing tailorings and supported profiles to determine higher OS minor versions
  • Sort Tailorings tabs by descending minor version and display a loading spinner while fetching profile rule IDs

@sourcery-ai

sourcery-ai Bot commented Sep 22, 2025

Copy link
Copy Markdown

Reviewer's Guide

This PR introduces a feature-flagged rule porting workflow by extending PolicyDetails to fetch existing tailorings, supported profile versions, and profile rule IDs for higher minor versions, and enhances the Tailorings component to display porting alerts, creation actions, and a loading spinner; it also updates the useProfileRuleIds hook for efficient data caching and refines skip logic in the tailoring helpers.

File-Level Changes

Change Details Files
Integrate rule porting data fetches into PolicyDetails
  • Replace hardcoded import toggle with feature flag
  • Fetch existing tailorings and supported profiles based on policy
  • Compute higher minor versions and fetch profile rule IDs
  • Conditionally render spinner or Tailorings with new props
src/SmartComponents/PolicyDetails/PolicyDetails.js
Extend Tailorings component with porting UI and actions
  • Add rulePortingAlert, onTailoringCreated and enableImportRules props
  • Introduce createPolicyTailoring function with notifications
  • Sort tabs by descending minor version
  • Render warning alert with import and default rule buttons
src/PresentationalComponents/Tailorings/Tailorings.js
Optimize useProfileRuleIds hook data handling
  • Build new list by reusing cached entries or fetching missing ones
  • Remove deep clone and skip redundant fetch logic
  • Simplify skip condition to only rely on skip flag
src/SmartComponents/CreatePolicy/EditPolicyProfilesRules/useProfileRuleIds.js
Refine skipProfiles helper skip conditions
  • Make skipRules depend on profileId and open items
  • Adjust skipRuleTree to respect profile presence
src/PresentationalComponents/Tailorings/helpers/skips.js

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

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.

1 participant