@@ -38,6 +38,8 @@ Sheriff is a tool to scan repositories and generate security reports.
3838 - [ Source code hosting services] ( #source-code-hosting-services )
3939 - [ Messaging services] ( #messaging-services )
4040 - [ Scanners] ( #scanners )
41+ - [ Usage in CI] ( #usage-in-ci )
42+ - [ In Gitlab] ( #in-gitlab )
4143- [ Contributors ✨] ( #contributors- )
4244
4345## Quick Usage
@@ -239,6 +241,34 @@ Sets the token to be used when reporting the security report on slack
239241- [x] [ OSV-Scanner] ( https://github.com/google/osv-scanner )
240242- [ ] [ Trivy] ( https://github.com/aquasecurity/trivy )
241243
244+ ## Usage in CI
245+
246+ Sheriff was designed so it could be run as part of a CI pipeline.
247+
248+ ### In Gitlab
249+
250+ To run sheriff on Gitlab, we suggest the following set-up:
251+ 1 . Create a repostory which will contain your CI runner, you can call it ` sheriff-runner ` for example
252+ 2 . Create a CI file in this repository which extends from our template
253+ ``` yaml
254+ include :
255+ - remote : ' https://raw.githubusercontent.com/elementsinteractive/sheriff/refs/tags/v0.22.2/gitlab/templates/sheriff.gitlab-ci.yml'
256+
257+ sheriff :
258+ extends : .sheriff
259+ ` ` `
260+ 3. Go to **Build** -> **Pipeline schedules** -> **New schedule**
261+ a. Add a name & a preferred cron interval. We prefer a weekly scan such as ` 0 7 * * 1` (every Monday at 7am)
262+ b. Add a **Variable** Variable named `SHERIFF_CLI_ARGS` which extra CLI arguments you wish to add (see CLI configuration section)
263+ c. Add a **File** Variable named `SHERIFF_CONFIG` containing your sheriff configuration (see file configuration section)
264+ 4. Go to **Settings** -> **CI/CD** -> **Variables**
265+ a. If scanning gitlab projects, add your gitlab token in **GITLAB_TOKEN** with *Protected*, *Masked*, *Hidden*
266+ b. If publishing reports to slack, add your slack token in **SLACK_TOKEN** with *Protected*, *Masked*
267+ 5. Test your pipeline by going to **Build** -> **Pipeline schedules** & clicking the play button on your pipline
268+ 5. Enjoy! Your pipeline should now run & scan your projects on a weekly basis 😀
269+
270+ We have a gitlab template set up for convenience, which runs sheriff with a set of configurable options.
271+
242272# # Contributors ✨
243273
244274Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)) :
0 commit comments