Skip to content

feat(controller): reject ScanJob creation when referenced Registry does not exist#1184

Open
fabriziosestito wants to merge 2 commits into
kubewarden:mainfrom
fabriziosestito:feat/reject-scanjob-if-registry-does-not-exist
Open

feat(controller): reject ScanJob creation when referenced Registry does not exist#1184
fabriziosestito wants to merge 2 commits into
kubewarden:mainfrom
fabriziosestito:feat/reject-scanjob-if-registry-does-not-exist

Conversation

@fabriziosestito
Copy link
Copy Markdown
Collaborator

Description

Fixes #1180

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
…not exist

Signed-off-by: Fabrizio Sestito <fabrizio.sestito@suse.com>
Copilot AI review requested due to automatic review settings May 28, 2026 12:02
@fabriziosestito fabriziosestito requested a review from a team as a code owner May 28, 2026 12:02
@github-project-automation github-project-automation Bot moved this to Pending Review in SBOMscanner May 28, 2026
@fabriziosestito fabriziosestito self-assigned this May 28, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 28, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.47%. Comparing base (4395da6) to head (fcf6fe9).
⚠️ Report is 31 commits behind head on main.

Files with missing lines Patch % Lines
internal/webhook/v1alpha1/scanjob_webhook.go 75.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1184      +/-   ##
==========================================
+ Coverage   53.41%   53.47%   +0.05%     
==========================================
  Files          61       61              
  Lines        5328     5339      +11     
==========================================
+ Hits         2846     2855       +9     
- Misses       2086     2087       +1     
- Partials      396      397       +1     
Flag Coverage Δ
unit-tests 53.47% <75.00%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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 improves the ScanJob admission experience by rejecting ScanJob creation when the referenced Registry resource does not exist (while still leaving the controller-side guard in place to avoid TOCTOU issues), addressing #1180.

Changes:

  • Switch the ScanJob webhook validator to use the manager’s API reader for read-only access.
  • Add validation on ScanJob create to verify the referenced Registry exists in the same namespace and return a spec.registry “Not found” validation error otherwise.
  • Extend webhook unit tests to cover the missing-Registry denial case and to create a Registry for existing “admit/deny by running job” scenarios.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/webhook/v1alpha1/scanjob_webhook.go Adds Registry existence validation during ScanJob creation and uses a read-only API reader.
internal/webhook/v1alpha1/scanjob_webhook_test.go Updates/extends tests to account for the new Registry existence requirement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

Reject ScanJob creation in the webhook when the referenced Registry does not exist.

2 participants