GitLab Container Registry

Scan the images in the container registry of a self-managed GitLab instance with a non-administrator access token, including GitLab instances that are not reachable from the internet

Ensure you update the Sysdig Helm chart before installation. This lets you access the latest features and fixes.

Overview

The gitlab registry type scans the container registry of a self-managed GitLab instance. The Registry Scanner finds repositories through the GitLab REST API. It then lists tags and pulls images from the GitLab container registry with the same token.

All calls to GitLab start from the Registry Scanner in your Kubernetes cluster. GitLab does not need to be reachable from the internet or from the Sysdig backend, so this type works for air-gapped and private-network GitLab instances.

Prerequisites

  • A self-managed GitLab instance, version 15.5 or later, with the container registry enabled.
  • A GitLab access token of a supported type, with:
    • The read_api and read_registry scopes.
    • The Reporter role or higher on every project to scan, direct or inherited. The Guest and Planner roles are not enough.
  • Network access from the cluster to the GitLab URL and the Registry URL. See Network and TLS Requirements.
  • The common Registry Scanner prerequisites.

Compatibility

ItemSupported
GitLab version15.5 and later
GitLab editionCommunity Edition (CE), and Enterprise Edition (EE) Free, Premium, and Ultimate
DeploymentSelf-managed GitLab only. GitLab.com is not supported.

Supported Tokens

Token typeSupportNotes
Group access tokenRecommendedCovers one group and its subgroups.
Service account personal access tokenSupportedUse it when one token must cover several top-level groups. Add the service account as a Reporter member of each group. Available on Premium and Ultimate, on EE Free 18.11 and later, and on CE 19.0 and later.
Project access tokenSupportedCovers one project only.
Personal access token of a userSupportedTied to a person. Use it for trials.
Administrator tokens, deploy tokens, CI/CD job tokens, OAuth tokens (including client_credentials), and granular personal access tokensNot supportedDeploy tokens can pull images but cannot list repositories.

Broader scopes, such as api, also work, but the Registry Scanner needs only read_api and read_registry.

Create the Access Token

These steps create the recommended group access token. Other token types need the same role, scopes, and expiration settings.

  1. Open the top-level group in GitLab that contains the projects to scan.
  2. Go to Settings > Access tokens.
  3. Add a new token.
  4. Set Role to Reporter.
  5. Select the read_api and read_registry scopes.
  6. Set an expiration date. GitLab allows at most 365 days by default.
  7. Create the token.
  8. Copy the token value.

To scan several top-level groups with one Registry Scanner, use a service account personal access token instead. Otherwise, install one Registry Scanner per group access token.

Install the Registry Scanner

The gitlab type needs two URLs, because the GitLab instance and its container registry usually have different addresses:

  • Registry URL (config.registryURL): The address you use with docker pull, for example registry.example.com or gitlab.example.com:5050. The Registry Scanner lists tags and pulls images from it, and reports image names under it.
  • GitLab URL (config.registryApiUrl): The base address of the GitLab instance, for example https://gitlab.example.com. A sub-path such as https://example.com/gitlab is allowed. The Registry Scanner adds /api/v4 itself, and uses https:// when you omit the scheme.

Run:

helm upgrade --install registry-scanner sysdig/registry-scanner --version=1 \
--set config.secureBaseURL=<SYSDIG_SECURE_URL> \
--set config.secureAPIToken=<SYSDIG_SECURE_API_TOKEN> \
--set config.registryType=gitlab \
--set config.registryURL=<GITLAB_REGISTRY_URL> \
--set config.registryApiUrl=<GITLAB_URL> \
--set config.registryPassword=<GITLAB_ACCESS_TOKEN>
  • <GITLAB_REGISTRY_URL>: The Registry URL, for example registry.example.com
  • <GITLAB_URL>: The GitLab URL, for example https://gitlab.example.com
  • <GITLAB_ACCESS_TOKEN>: The access token

config.registryUser is optional. When it is empty, the Registry Scanner sends the placeholder username registry-scanner with the token.

To keep the token out of the Helm values, set existingSecretName to a Kubernetes Secret with the secureAPIToken and registryPassword keys. The registryUser key is optional for gitlab.

Limit Discovery to Groups

By default, the Registry Scanner discovers the repositories of every project the token can see. To scan only some groups, list their full paths in config.gitlab.groups:

config:
  registryType: gitlab
  registryURL: registry.example.com
  registryApiUrl: https://gitlab.example.com
  gitlab:
    groups:
      - acme
      - platform/team-a
  • Use full group paths, as they appear in the group URL. Numeric group IDs and user namespaces are not supported.
  • Each group includes its subgroups. The Registry Scanner skips a configured group that is a subgroup of another configured group.
  • The token must be a Reporter member of each configured group. If the Registry Scanner cannot list a configured group, the run stops before discovery starts.

On large GitLab instances, set config.gitlab.groups. Without it, the Registry Scanner makes one extra GitLab API call per project, for example about 5,000 extra calls for 5,000 projects.

config.filter.maxRepositoriesPerRegistry defaults to 500. If the token can see more repositories, discovery stops at 500 and logs reached maximum maxRepositoriesPerRegistry. Raise the limit to cover your instance, up to 20000.

Network and TLS Requirements

PodGitLab URLRegistry URLSysdig backend
Registry Scanner CronJob podRepository discovery and token checksTag and manifest listingRequired
Scan job podsRegistry token endpoint (/jwt/auth)Image pullsRequired
  • Custom certificate authorities: Add the CA certificates of both hosts to ssl.ca.certs. The chart passes them to the CronJob pod and to scan jobs. If the GitLab URL and the Registry URL use different CAs, list both.
  • Skip TLS verification: config.registrySkipTLS: true skips certificate verification for both hosts. Use it for testing only.
  • Proxy: If you set proxy.httpsProxy, add both hosts to proxy.noProxy, or ensure the proxy can reach them.
  • OpenShift: Provide CAs through ssl.ca.certs. The OpenShift trusted CA bundle injection is not supported.

The Registry Scanner sends GitLab API requests only to the scheme and host of the GitLab URL. It refuses GitLab API redirects to another host or from HTTPS to HTTP.

How Discovery Works

At the start of each run, the Registry Scanner checks the token against the GitLab URL. Any authentication or TLS error at this point stops the run.

Without config.gitlab.groups, the Registry Scanner:

  1. Lists every project on which the token has the Reporter role or higher, including projects shared with the token’s groups.
  2. Skips projects with the container registry disabled.
  3. Lists the registry repositories of the remaining projects, 10 projects at a time.

With config.gitlab.groups, the Registry Scanner lists the registry repositories of each configured group, in the configured order. Projects shared into a group from outside it are not included.

In both cases:

  • Image names are the Registry URL followed by the repository path, for example registry.example.com/acme/team-a/api.
  • Discovery includes the repositories of archived projects and of projects pending deletion. To skip them, add their image name patterns to config.filter.exclude.
  • Repositories without tags are discovered but produce no scans.
  • config.filter.include and config.filter.exclude apply to the full image name after discovery.
  • config.filter.maxRepositoriesPerRegistry stops discovery at the limit and logs a warning. The order is stable between runs: configured group order, or project ID order without groups.

Each run logs one summary line. Without groups, it looks like:

GitLab Discovery done: outcome=ok projects_walked=1250 repositories_found=3400 projects_skipped_registry_disabled=310 projects_skipped_call_failed=0 projects_listed_partially=0 api_calls=1194 elapsed=48.2s

With config.gitlab.groups, it looks like:

GitLab Discovery done: outcome=ok groups_listed=2 repositories_found=3400 api_calls=38 elapsed=6.1s

To change the number of projects listed at a time, for example on a rate-limited GitLab instance, set an environment variable:

extraEnvVars:
  - name: REGISTRYSCANNER_REGISTRY_GITLABPARALLELPROJECTCALLS
    value: "5"

Rotate the Token

GitLab access tokens expire. The Registry Scanner does not rotate the token itself.

At the start of each run, the Registry Scanner logs the token expiration date:

GitLab auth OK: user=group_123_bot_abc token_expires_at=2027-11-30

token_expires_at is never for a token without an expiration date, and unknown when the expiration check fails. The warning below needs a known date. When the token expires in less than 30 days, every run also logs a warning:

GitLab token expires in 12 days (2026-12-13): rotate the token in registry_password

GitLab notifies different people depending on the token type:

Token typeGitLab expiration notification
Group access tokenEmail to the group Owners before expiration, and a webhook event
Project access tokenEmail to the project Maintainers and Owners before expiration, and a webhook event
Personal access token of a userEmail to the user
Service account personal access tokenNone. The Registry Scanner warning is the only signal. Set a calendar reminder, or alert on the warning in your log system.

To rotate the token:

  1. Create a new token with the same role and scopes. See Create the Access Token.
  2. Update registryPassword in the Registry Scanner Secret:
    • If the chart manages the Secret, run helm upgrade with --reuse-values --set config.registryPassword=<NEW_GITLAB_ACCESS_TOKEN>.
    • If you use existingSecretName, update the registryPassword key of that Secret.
  3. Wait for the next scheduled run, which reads the new token.
  4. Check that the run logs GitLab auth OK.
  5. Revoke the old token in GitLab.

Do not use the Rotate option or the token rotation API in GitLab. They revoke the old token immediately, so a run in progress cannot pull its remaining images. The next run recovers after you update the Secret.

Limitations

  • GitLab.com is not supported.
  • Scans run on the CronJob schedule. GitLab webhooks do not trigger scans.
  • The Registry Scanner does not rotate the token.
  • Discovery errors and token expiration warnings appear only in the Registry Scanner logs, not in Sysdig Secure.
  • config.gitlab.groups accepts groups only. Projects in user namespaces are discovered only without config.gitlab.groups.

Troubleshooting

Check the logs of the latest Registry Scanner run:

kubectl get jobs -n <NAMESPACE>
kubectl logs -n <NAMESPACE> job/<JOB_NAME>

An error in the following table stops the run, and the run reports no results.

Log messageCauseAction
registry.api is required when registry.type=gitlabThe GitLab URL is not set.Set config.registryApiUrl.
GitLab token expired or revokedThe token has expired or was revoked.Rotate the token.
GitLab token not recognisedThe GitLab instance at the GitLab URL does not know the token.Check config.registryApiUrl and the token value.
GitLab token is missing a scopeThe token does not have the read_api scope.Create a token with read_api and read_registry.
GitLab certificate signed by unknown authorityThe CA of the GitLab URL host is not trusted. The message names the host.Add the CA to ssl.ca.certs.
GitLab group "<GROUP>" cannot be listedThe group does not exist, is a user namespace, or the token is not a Reporter member of it.Fix the path in config.gitlab.groups, or add the token’s user to the group as a Reporter.
refusing to send the GitLab token to <HOST>GitLab redirected the request to another host or from HTTPS to HTTP.Set config.registryApiUrl to the address GitLab redirects to.
listing GitLab group "<GROUP>"A later page of a configured group could not be listed after retries.Check that GitLab is available from the cluster.
listing the registry repositories of every one of the <N> projects failedNo project could be listed. GitLab might be unavailable.Check that GitLab is available from the cluster.

The following messages are warnings. The run continues:

  • listing the registry repositories of project <PROJECT> (id <ID>) failed, skipping it: The Registry Scanner skips that project and scans the others. Check the token’s role on the project.
  • listing the registry repositories of project <PROJECT> (id <ID>) failed after <N> repositories, keeping those: The Registry Scanner scans the repositories it listed before the error and skips the rest of that project.
  • GitLab token expires in <N> days: Rotate the token before it expires.

If discovery succeeds but tag listing or image pulls fail with a certificate error, the Registry URL host uses a CA that is not in ssl.ca.certs. Add it to the list.