GitLab
Connect GitLab.com or a self-managed GitLab so Safeguard can check group security settings, branch protection and merge request reviews.
Connect GitLab
Safeguard reads your GitLab groups and projects with read-only access: two-factor and SSO enforcement, members and administrators, branch protection, merge request approvals, pipelines, and security scanning settings.
There are three cards:
- GitLab: GitLab.com, or a self-managed instance at your own address.
- GitLab Self-Managed: your own GitLab instance.
- GitLab Issues: GitLab used as a ticket tracker.
The token
Use a personal, group or project access token with only the read_api scope. Safeguard only reads with it.
Safeguard reads every top-level group the token's user is a member of. A user in no group is judged on the projects they own. Some reads need more than membership:
| Setting | Needs |
|---|---|
| Groups, projects, members, two-factor requirement, "pipelines must succeed" | The read_api scope and any membership |
| Pipelines and their jobs on private projects | read_api and the Reporter role on the project |
| Protected branches | read_api and the Developer role on the project (Maintainer on older GitLab versions) |
| Merge request approval rules | read_api and the Developer role on the project, on GitLab Premium |
| Secret push protection | GitLab Ultimate |
So give the token at least Reporter on the projects to read pipelines, and Developer to read protected branches and merge request approvals. On a plan without a feature, the setting does not exist, and the check says so instead of failing.
Connect
-
In GitLab, create the token:
- Personal access token: your avatar menu › Edit profile › Access tokens, then add a new token.
- Group or project access token: the group's or project's Settings › Access tokens. Pick the role the token gets there (Reporter or Developer, as above).
Select only the
read_apiscope, and set an expiry that fits your policy. For a personal token, create it as a user who is a member of the groups you want checked, with the roles above. GitLab's guide: Personal access tokens. -
In Safeguard, open Compliance › Connectors, search for GitLab and click Connect. Choose API token.
-
Answer Where does GitLab run?:
- GitLab.com (cloud): choose this if you sign in at gitlab.com. Nothing else to enter.
- Self-managed GitLab (your own URL): enter your instance's
https://address, for examplehttps://gitlab.example.com. It must be reachable from the internet: Safeguard refuses private and reserved addresses.
-
Paste the token in API token / PAT.
-
Optionally, choose the Projects to include (below), then click Connect with token.
Projects to include
By default Safeguard checks every project the token can read. To check only some, use Projects to include:
- While connecting: type project paths like
group/subgroup/project, one per line or separated by commas. - On the connected GitLab card: search the list of projects the token can read and select the ones you want, or type paths in the box beside it for anything the list does not show. Then click Save projects. If your workspace asks for a reason when scope changes, enter one.
The next run checks only the projects you chose. Clear the selection to go back to every project. A project you chose that the token cannot see is reported as an error on the project checks, never left out silently.
Archived projects, forks, projects pending deletion and projects with the repository feature turned off are not checked by the repository tests.
Several self-managed instances
GitLab Self-Managed can be connected more than once, one connection per instance. When multiple accounts are switched on for your workspace, open the connected card and choose Add another account. A second group on GitLab.com is not a separate account: one GitLab.com connection already covers every group its user belongs to.
What Safeguard checks
- Two-factor authentication required for the group, and SSO enforced
- Administrators and how many there are, outside collaborators, and whether admins are exempt from rules
- Default branch protection: no direct pushes and no force pushes
- Merge request approvals required, no self-approval, stale approvals dismissed, code owner review
- Required pipeline checks, and merged changes that were reviewed
- Secret detection and push protection, dependency scanning alerts and their age, code scanning, and fork restrictions
Choose what this connector collects
Each connector has a What this connector collects panel, on the connect sheet and on the connected card. It lists the tests and evidence checks that read from that connector, and each one has a switch. Switch one off to stop collecting it from this connector; another connector can still supply it. Only the person who connected it or an administrator can change these switches.
Troubleshooting
- Could not read, naming a scope or role: give the token
read_api, or give its user the role the message names on that project. - A group is missing: the token's user is not a member of that group.
- None of the selected projects is visible: check the paths under Projects to include, and that the token can read those projects.