Secure GitLab with Mondoo
Continuously scan GitLab groups for misconfigurations and vulnerabilities.
To connect GitLab to Mondoo, you create a GitLab personal access token and add it to a GitLab integration in your space. Mondoo scans the groups the token can see and keeps the assessment current as they change.
To scan Kubernetes manifests, Terraform configurations, or Docker containers inside a GitLab CI/CD pipeline, read Scan in GitLab CI/CD instead.
Before you begin
- Editor or Owner access to the Mondoo space, or another role with permission to add integrations. To see every role, read Roles and permissions.
- A GitLab user with the Owner role on the group you want to scan. The personal access token belongs to that user, so Mondoo sees only the groups and projects the user can see, and some group settings, such as group CI/CD variables, are visible only to group Owners.
- If you self-host GitLab, an HTTPS URL for the instance that Mondoo can reach from the internet. If inbound IP allowlists block Mondoo, scan from a GitLab CI/CD pipeline instead.
Create a GitLab personal access token
A personal access token gives Mondoo permission to read GitLab resources on your behalf. To learn more, see Create a personal access token in the GitLab documentation.
-
Log into GitLab. In the upper-left, select your profile photo, then Edit Profile.
-
In the left sidebar, select Access Tokens.
-
Select Add new token and enter a name (for example,
mondoo-frontend-repo). -
Choose an Expiration date. Note it so you can rotate the token before it lapses.
-
Under Select scopes, check:
read_apiread_userread_repositoryread_registry
-
Select Create a personal access token and copy the value. You need it in the next section.
Add a GitLab integration
In the Mondoo App, navigate to the space where you want to add the integration. Some integrations can also be added once at the organization level to cover every space with one connection. To see which ones, read Set up integrations once for your whole organization.
In the space's side navigation bar, select Integrations. In the top right, select INSTALL. On the Install Integration page, find the integration you want by browsing a category or searching by name:
-
Under SaaS Security, select GitLab.

-
In Integration Name, enter a name that identifies the GitLab group or instance.
-
If you self-host GitLab, enter your custom URL in GitLab Base URL (Optional). Otherwise leave it empty and Mondoo uses gitlab.com.
-
(Optional) In GitLab Group, enter the group name from the group's URL. For example, the group at
gitlab.com/lunalectricis namedlunalectric. Leave it empty to scan all projects the token can access. -
Paste your personal access token into Personal Access Token.
-
Under Discovery Options, check what you want Mondoo to scan:
- Groups the token can access
- Projects the token can access
- Terraform files
- Kubernetes manifests
-
(Optional) Under Enable security policies (optional), enable the policies you want Mondoo to score the GitLab assets against.
-
(Optional) Under Set Annotations (optional), select + ADD ANNOTATION to add key-value pairs that Mondoo applies to every asset this integration discovers. To learn more, read Annotate assets.
-
Select START SCANNING.
Verify the integration
When you select START SCANNING, Mondoo starts the first scan and opens the integration's page. Status shows Active once the scan is queued, and Most Recent Activity lists each scan and any errors it reports.

When the scan finishes, Mondoo adds GitLab Group and GitLab Project assets to the space, plus assets for any Terraform files and Kubernetes manifests you chose to discover. To review them, navigate to the space and select Inventory. To learn what each integration status means, read Integration status and troubleshooting.
Troubleshoot
| Message | Cause | Fix |
|---|---|---|
URL must use HTTPS or URL must be a valid URL under GitLab Base URL (Optional) | The base URL is missing https:// or isn't a URL. | Enter the instance's full HTTPS URL, such as https://gitlab.lunalectric.com. |
| GitLab rejected the credential. Check it and try again. when you create the integration | GitLab refused the token: it was mistyped, revoked, or expired. | Create a new token and try again. |
| GitLab integration created, but its first scan could not be started. | The integration exists, but Mondoo couldn't queue its first scan. | Don't add the integration again. Open it and select RUN. |
cannot find gitlab group in Most Recent Activity | The GitLab Group value doesn't match a group the token's user can see. | Check the group name in the group's URL, and that the token's user is a member of the group. |
tls: failed to verify certificate in Most Recent Activity | The self-hosted instance's TLS certificate is expired or not publicly trusted. | Renew the certificate or use one from a public certificate authority. |
| Scans are paused at the top of the integration page | The integration's token was rejected by GitLab or has expired. | Create a new token and rotate it in Mondoo. |
ended in a scan error, so their results are missing in Most Recent Activity | The token's user or scopes can't read some of the settings Mondoo checks. | The message names the most common error. Give the token's user the Owner role on the group and check the token's scopes. |
Manage your integration
To open the integration, navigate to the space, select Integrations > GitLab, and choose the integration. To change its settings, select the pencil icon.
Rotate the token
GitLab personal access tokens expire on the date you chose when you created them. Create a new token before then, with the same scopes, as described in Create a GitLab personal access token.
How you replace the token depends on how Mondoo stored it when the integration was created. Integrations added by someone with permission to create and view credentials store the GitLab instance and token as a credential. Older integrations, and integrations added by someone without that permission, keep the token on the integration.
-
If the integration uses a credential: The integration detail page shows a Credential section, and the edit form shows Managed by a credential under Authentication in place of the base URL and token boxes. Select the credential's name to open it, then select Rotate and enter the new token. Every integration that uses the credential switches to the new token. To learn more, read Manage Integration Credentials.

-
If the integration stores its own token: Select the pencil icon. In Personal access token (optional update), enter the new token, then select SAVE CHANGES. Leave the box empty to keep the existing token.
Scan from a GitLab CI/CD pipeline
If your GitLab instance has inbound IP allowlists that block Mondoo's hosted integration, you can run an equivalent scan from inside a GitLab pipeline.
-
Follow the steps above to create a personal access token.
-
Store the personal access token in GitLab as a variable named
GITLABTOKEN. -
Add a scheduled pipeline job to
.gitlab-ci.yml:.gitlab-ci.yml stages: [security] cnspec-gitlab-scan: stage: security image: name: mondoo/cnspec:latest-rootless entrypoint: [''] rules: - if: '$CI_PIPELINE_SOURCE == "schedule"' script: - set -euo pipefail - cnspec version - cnspec scan gitlab --group <GROUP_NAME> --discover groups,projects,terraform,k8s-manifests --detect-cicd=0 --token "$GITLABTOKEN" --url "$CI_SERVER_URL"Replace
<GROUP_NAME>with the full path of the group to scan. The--groupflag is required: without it, cnspec exits withError: required flag(s) "group" not set. Change the--discoverflag to control what's scanned.
Next steps
- Explore your asset inventory.
- Assess and improve your security to review and prioritize your findings.
- Mondoo GitLab Resource Pack Reference
Last updated on