Skip to content

fix: make CSAF import resilient to CPE import order - #1958

Merged
jdobes merged 1 commit into
RedHatInsights:masterfrom
RostyslavKachan:add_cpe_sync_to_csaf
Sep 14, 2026
Merged

jdobes merged 1 commit into
RedHatInsights:masterfrom
RostyslavKachan:add_cpe_sync_to_csaf

Conversation

@RostyslavKachan

@RostyslavKachan RostyslavKachan commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

RHINENG-29933

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

Run CPE synchronization before CSAF synchronization to ensure imports work regardless of CPE import order.

Bug Fixes:

  • Make CSAF imports resilient to CPE import order by synchronizing CPE metadata before CSAF metadata.

Enhancements:

  • Consolidate CPE and CSAF synchronization into a single operation with stage-specific failure reporting.
  • Remove the standalone CPE sync endpoint and configuration toggle.

Documentation:

  • Update the sync API specification to expose CPE and CSAF synchronization through the CSAF endpoint.

@sourcery-ai

sourcery-ai Bot commented Sep 11, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR consolidates CPE and CSAF imports into a single CPE-first synchronization workflow, so CSAF processing always has the required CPE data regardless of import order, while retaining stage-specific failure reporting and removing the standalone CPE sync interface.

Sequence diagram for the consolidated CPE-first CSAF sync

sequenceDiagram
    participant Client
    participant CsafSyncHandler
    participant CpeController
    participant CsafController
    participant Database

    Client->>CsafSyncHandler: put(sync_all)
    CsafSyncHandler->>CpeController: store()
    CpeController->>Database: import CPE metadata
    CpeController-->>CsafSyncHandler: success
    CsafSyncHandler->>CsafController: store(sync_all)
    CsafController->>Database: import CSAF metadata
    CsafController-->>CsafSyncHandler: success
    CsafSyncHandler-->>Client: OK

    alt CPE import fails
        CpeController-->>CsafSyncHandler: exception
        CsafSyncHandler->>Database: rollback()
        CsafSyncHandler-->>Client: ERROR or DB_ERROR
    else CSAF import fails
        CsafController-->>CsafSyncHandler: exception
        CsafSyncHandler->>Database: rollback()
        CsafSyncHandler-->>Client: ERROR or DB_ERROR
    end
Loading

File-Level Changes

Change Details Files
Make the CSAF synchronization workflow import CPE metadata first, eliminating order-dependent failures.
  • Move CPE synchronization into the CSAF handler and run it before CSAF import.
  • Preserve separate error handling, rollback behavior, metrics, and database-error responses for CPE and CSAF stages.
  • Remove the standalone CPE sync handler, feature flag, and API endpoint.
vmaas/reposcan/reposcan.py
vmaas/reposcan/reposcan.spec.yaml
conf/reposcan.env

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@codecov-commenter

codecov-commenter commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.32%. Comparing base (5a56460) to head (1c9a2a4).
⚠️ Report is 844 commits behind head on master.

Files with missing lines Patch % Lines
vmaas/reposcan/reposcan.py 25.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1958      +/-   ##
==========================================
- Coverage   62.98%   54.32%   -8.67%     
==========================================
  Files          70       93      +23     
  Lines        6800     6338     -462     
==========================================
- Hits         4283     3443     -840     
- Misses       2517     2870     +353     
- Partials        0       25      +25     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread vmaas/reposcan/reposcan.py
@RostyslavKachan
RostyslavKachan force-pushed the add_cpe_sync_to_csaf branch 2 times, most recently from 70e12a2 to 1d042b4 Compare September 14, 2026 11:09
Comment thread vmaas/reposcan/reposcan.py Outdated
@staticmethod
def run_task(*args, **kwargs):
"""Function to start syncing CSAFs."""
def run_task(*args, **kwargs): # pylint: disable=too-many-return-statements

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

pylint disable no longer needed

@jdobes

jdobes commented Sep 14, 2026

Copy link
Copy Markdown
Member

Also

reposcan.py:915:55: E0601: Using variable 'stage' before assignment (used-before-assignment)

@jdobes
jdobes merged commit 562e0d1 into RedHatInsights:master Sep 14, 2026
8 of 9 checks passed
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.

3 participants