Resolve "Create X-Ray scanner uploader job"
What does this MR do and why?
Adds a CI/CD report and uploader for the Repository X-Ray project.
- Users can now scan and upload repository x-ray results with the
repository_xray
report type - The docker image for the xray repo is used to scan the source code, then the results are uploaded as a job artifact of
repository_xray
type - After that succeeds, the
StoreRepositoryXrayWorker
andStoreRepositoryXrayService
will parse and store the artifacts as a newProjects::XrayReport
model, which is a JSON payload - Currently the Xray report only has dependency library information, but will be updated over time to include more
- Repository Xray scanner only supports ruby, javascript and go right now
Screenshots or screen recordings
Example CI/CD
xray:
stage: build
image: registry.gitlab.com/gitlab-org/code-creation/repository-x-ray:latest
allow_failure: true
script:
- x-ray-scan -p "$CI_PROJECT_DIR"
artifacts:
reports:
repository_xray: reports/**/*.json
How to set up and validate locally
- Setup a new project (or use an existing one)
- Create a code suggestions service token in the rails console for cloud connection
FactoryBot.create(:service_access_token, :active)
- Create a code suggestions addon subscription for the namespace of the project in the rails console
GitlabSubscriptions::AddOnPurchase.for_code_suggestions.create(namespace_id: PROJECT_NAMESPACE_ID, quantity: 5, purchase_xid: "NOT REAL", expires_on: DateTime.now + 2.years)
- Add a job using the example template above
- Wait for the job to complete (may take a while on large repos)
- Check for the output via rails console (i.e.
Projects::XrayReport.where(project_id: PROJECT_ID
) - There should be results saved for supported languages (ruby, javascript and go)
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 #432235 (closed)
Edited by Allen Cook