Graphql query- fetch corpus
What does this MR do and why?
This MR adds a graphql query to fetch the Corpus
records associated to a project.
Describe in detail what your merge request does and why.
How to set up and validate locally
- Enable feature flag
corpus_management
- Create a Corpus like this. Package and project is required.
::AppSec::Fuzzing::Coverage::Corpus.create(package_id: Packages::Package.last.id, project_id: Packages::Package.last.project.id)
- Run the following Graphql query:
query Project {
project(fullPath:"gitlab-org/gitlab-test") {
corpuses{
nodes {
id,
package {
id
}
}
}
}
}
- Response from the query should look like this:
{
"data": {
"project": {
"corpuses": {
"nodes": [
{
"id": 10,
"package": {
"id": "gid://gitlab/Packages::Package/26"
}
}
]
}
}
}
}
- Should show null if a user is not logged in
{
"data": {
"project": null
}
}
Numbered steps to set up and validate the change are strongly suggested.
Database query analysis
- Query
joins(:package).where(package: {project_id: 1})
- Explain
explain SELECT "coverage_fuzzing_corpuses".* FROM "coverage_fuzzing_corpuses" INNER JOIN "packages_packages" "package" ON "package"."id" = "coverage_fuzzing_corpuses"."package_id" WHERE "package"."project_id" = 1
Nested Loop (cost=0.58..30.30 rows=1 width=56) (actual time=8.015..8.018 rows=0 loops=1)
Buffers: shared read=3
I/O Timings: read=7.955 write=0.000
-> Index Only Scan using idx_installable_helm_pkgs_on_project_id_id on public.packages_packages package (cost=0.43..4.02 rows=34 width=8) (actual time=8.012..8.013 rows=0 loops=1)
Index Cond: (package.project_id = 1)
Heap Fetches: 0
Buffers: shared read=3
I/O Timings: read=7.955 write=0.000
-> Index Scan using index_coverage_fuzzing_corpuses_on_package_id on public.coverage_fuzzing_corpuses (cost=0.15..0.72 rows=5 width=56) (actual time=0.000..0.000 rows=0 loops=0)
Index Cond: (coverage_fuzzing_corpuses.package_id = package.id)
I/O Timings: read=0.000 write=0.000
- Visualization
https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/7069/commands/24958
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #341486 (closed)
Edited by Aditya Tiwari