-
Notifications
You must be signed in to change notification settings - Fork 30
Add CSAF GC test and simplify SBOM GC test #1980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Also deleted some superfluous code, i.e. no advisories ingested so none need to be deleted in the now-renamed gc_purls_from_sbom test.
Reviewer's GuideRenamed the existing garbage-collection test to focus on SBOMs, removed unnecessary advisory-deletion logic, and added a new test to reproduce issue #1977 by verifying purl GC behavior after ingesting a single CSAF document. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `modules/fundamental/src/purl/service/test.rs:820` </location>
<code_context>
+ );
+
+ // should any packages be garbage collected? I honestly don't know.
+ assert_eq!(0, purl_service.gc_purls(&ctx.db).await?);
+
+ Ok(())
</code_context>
<issue_to_address>
**question (testing):** Clarify the expected behavior for garbage collection after CSAF ingestion.
Please update the test description or comments to clearly state the expected outcome. If there are cases where packages should be garbage collected after CSAF ingestion, consider adding a corresponding test.
</issue_to_address>
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
this change makes the test to pass: ➜ trustify git:(1977) ✗ git diff
diff --git a/modules/fundamental/src/purl/service/gc_purls.sql b/modules/fundamental/src/purl/service/gc_purls.sql
index 4a8703a2..7bc6d692 100644
--- a/modules/fundamental/src/purl/service/gc_purls.sql
+++ b/modules/fundamental/src/purl/service/gc_purls.sql
@@ -1,9 +1,18 @@
WITH
alive_qualified_purl AS (
+ (
SELECT DISTINCT t2.id, t2.versioned_purl_id
FROM sbom_package_purl_ref AS t1
INNER JOIN qualified_purl AS t2
ON t2.id = t1.qualified_purl_id
+ )
+ UNION
+ (
+ SELECT t1.id, t1.versioned_purl_id
+ FROM qualified_purl AS t1
+ INNER JOIN versioned_purl AS t2 ON t2.id = t1.versioned_purl_id
+ INNER JOIN purl_status AS t3 ON t2.base_purl_id = t3.base_purl_id
+ )
),
alive_versioned_purl AS (
SELECT DISTINCT t2.id, t2.base_purl_id ➜ trustify git:(1977) ✗ cargo nextest run gc_purls_from_single_csaf
Compiling trustify-module-fundamental v0.3.6 (/home/heliofrota/Desktop/tc/trustify/modules/fundamental)
Finished `test` profile [unoptimized + debuginfo] target(s) in 21.85s
────────────
Nextest run ID a38d5869-c649-4f1a-9a64-609f0a3845f0 with nextest profile: default
Starting 1 test across 35 binaries (478 tests skipped)
PASS [ 2.891s] trustify-module-fundamental purl::service::test::gc_purls_from_single_csaf
────────────
Summary [ 2.923s] 1 test run: 1 passed, 478 skipped it works fine for an empty / small database , unfortunately we can not merge the PR atm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Please add a call to PurlService::gc_purls()
in https://github.com/guacsec/trustify-scale-testing so we can get a sense of the perf impact triggered by a /scale-test
comment.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1980 +/- ##
==========================================
- Coverage 67.84% 67.72% -0.12%
==========================================
Files 353 355 +2
Lines 19683 19801 +118
Branches 19683 19801 +118
==========================================
+ Hits 13354 13411 +57
- Misses 5551 5614 +63
+ Partials 778 776 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
trustify-scale-testing calls trustify endpoints, I'm not sure if I understood well, for this we would need to create a new endpoint in trustify just to call Also the impact is based on the database size, please see some comments here Then may end up with an illusion that the performance good or acceptable 👍 |
Good idea. Let's add an endpoint, |
/scale-test |
🛠️ Scale test has started! Follow the progress here: Workflow Run |
Goose ReportGoose Attack ReportPlan Overview
Request Metrics
Response Time Metrics
Status Code Metrics
Transaction Metrics
Scenario Metrics
Error Metrics
📄 Full Report (Go to "Artifacts" and download report) |
/scale-test |
🛠️ Scale test has started! Follow the progress here: Workflow Run |
That might actually be dangerous. As we know it has side effects. This might be good way for a DoS. |
scale test is failing with
|
➕
let's revert then? |
Having tests is fine. Exposing the GC on an HTTP endpoint I think is not. |
yeah sorry I forgot to add the link #1996 👍 |
/scale-test |
🛠️ Scale test has started! Follow the progress here: Workflow Run |
Goose ReportGoose Attack ReportPlan Overview
Request Metrics
Response Time Metrics
Status Code Metrics
Transaction Metrics
Scenario Metrics
Error Metrics
📄 Full Report (Go to "Artifacts" and download report) |
Also deleted some superfluous code, i.e. no advisories ingested so none need to be deleted in the now-renamed
gc_purls_from_sbom
test.Summary by Sourcery
Add a new test for reproducing garbage collection behavior with a single CSAF document and clean up the existing SBOM-based GC test.
Enhancements:
Tests: