Skip to content

Add corpus create mutation and service

Aditya Tiwari requested to merge 341485-corpus-create-mutation into master

What does this MR do and why?

This MR will allow the frontend to create the corpus record for a package. This MR is the part of the epic &5017 (closed)

FE will have to supply package_id and an associated corpus record will be created for the package. We are going to show the corpus packages in the next screen. Design can be viewed here.

Steps to test and screenshots of dev testing

  1. Enable flag ee/config/feature_flags/development/corpus_management.yml
  2. Run the following mutation with a valid project path and package. The package.project_id and packageID should be same.
Create Mutation
mutation CorpusCreate($input: CorpusCreateInput!) {
  corpusCreate(input: $input) {
    errors
  }
}

{
  "input": {
  	"packageId": "gid://gitlab/Packages::Package/2",
    "fullPath": "gitlab-org/gitlab-test"
  }
}
  1. Response should not contain an error and you can check in rails console the corpus record
[42] pry(main)> AppSec::Fuzzing::Coverage::Corpus.last
  AppSec::Fuzzing::Coverage::Corpus Load (0.4ms)  SELECT "coverage_fuzzing_corpuses".* FROM "coverage_fuzzing_corpuses" ORDER BY "coverage_fuzzing_corpuses"."id" DESC LIMIT 1 
=> #<AppSec::Fuzzing::Coverage::Corpus:0x00007fc6505cee78
 id: 9,
 project_id: 1,
 user_id: 1,
 package_id: 1,
 file_updated_at: Fri, 08 Oct 2021 11:12:36.685846000 UTC +00:00,
 created_at: Fri, 08 Oct 2021 11:12:36.693666000 UTC +00:00,
 updated_at: Fri, 08 Oct 2021 11:12:36.693666000 UTC +00:00>

These are strongly recommended to assist reviewers and reduce the time to merge your change.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #341485 (closed)

Edited by Aditya Tiwari

Merge request reports

Loading