OpenAI is partnering with Hacktron to find vulnerabilities in its systems. Read the announcement.

Skip to content Hacktron Sign in [S]
Hacktron Sign in [S] Customers Docs Contact Sign in

GitLab

6 min
, View, ChatGPT, Claude, Perplexity

Copy page

GitLab

View MarkdownOpen in ChatGPTOpen in ClaudeOpen in Perplexity

Choose an access level

Hacktron supports two GitLab access levels. Choose the service account’s role by who will manage webhooks and repository clone credentials.

Maintainer access is recommended and sets everything up automatically. GitLab requires Maintainer access to create project webhooks and read-only clone credentials, so with this role Hacktron manages both for the projects you select.

Developer access lets Hacktron read merge requests and post review comments. A GitLab Maintainer or Owner must add read-only deploy tokens and configure webhooks. You can use tokens from multiple groups or projects in one connection.

Prerequisites

You need to be a Hacktron organisation admin to connect GitLab and manage its settings.

A GitLab group Owner creates the service account. For Developer access, you also need someone with permission to create deploy tokens and webhooks: a group Owner for group-level setup, or a project Maintainer or Owner for project-level setup. The service account itself can keep Developer access.

Configure access

Open Service Accounts

In GitLab, open the group you want to connect to Hacktron, go to Settings, and select Service Accounts.

Service accounts in a GitLab group’s settingsService accounts in a GitLab group’s settings
Service accounts in a GitLab group’s settings

Create a service account

Give the service account a descriptive name, such as “Hacktron”.

Create service account in GitLab, with the name hacktron-botCreate service account in GitLab, with the name hacktron-bot
Create service account in GitLab, with the name hacktron-bot

Click Create.

Choose the service account’s access level

Grant the service account access to the group or projects you want Hacktron to scan.

Maintainer (recommended)

Grant Maintainer access. Hacktron creates project webhooks and repository clone credentials automatically.

Inviting the Hacktron service account to a GitLab group with the Maintainer roleInviting the Hacktron service account to a GitLab group with the Maintainer role
Inviting the Hacktron service account to a GitLab group with the Maintainer role
Developer

Grant Developer access. After you connect, save read-only deploy tokens and configure webhooks by hand.

Hacktron detects the account’s access level automatically.

Create a personal access token

On the service accounts page, select the service account and click Manage access tokens.

The menu of a GitLab service account, with Manage access tokensThe menu of a GitLab service account, with Manage access tokens
The menu of a GitLab service account, with Manage access tokens

Click Add new token and enable api, read_api, and read_user, the scopes listed in Hacktron’s setup instructions. Set an expiration date and click Generate token.

Why Hacktron needs each scope:

Scope What Hacktron uses it for
api Posting review comments and, with Maintainer access, managing webhooks and clone credentials
read_api Reading project and merge request information, diffs included
read_user Identifying the connected service account

Warning

Rotate the personal access token before it expires to avoid a service interruption.

Connect GitLab

In Hacktron, go to Integrations and click Connect under GitLab. Paste the personal access token and click Connect GitLab.

The GitLab connection panel in Hacktron, explaining Maintainer and Developer accessThe GitLab connection panel in Hacktron, explaining Maintainer and Developer access
The GitLab connection panel in Hacktron, explaining Maintainer and Developer access

Select projects

Go to Repositories and select the GitLab projects Hacktron can access.

With Maintainer access, webhook setup is automatic. With Developer access, complete the Developer access setup before you start scans.

Connecting GitLab does not turn on merge request reviews. Once access is ready, enable Review for the repositories and branches you want covered.

Developer access setup

Follow these steps when the service account has Developer access. Hacktron shows Needs setup until you save a deploy token.

Create a read-only deploy token in GitLab

Ask a GitLab group Owner or project Maintainer to open the group or project and go to Settings, then Repository, then Deploy tokens. There, they select Add token, give it a name, enable only read_repository, and click Create deploy token.

Copy both the username and the token before you leave the page. GitLab shows the token only once.

Note

Use a group deploy token for projects in the same group, or a project token for one project. Add tokens as needed to cover every selected private project.

Save deploy tokens in Hacktron

Open Integrations and click Manage GitLab. Under Webhooks and deploy tokens, click Add token and enter the Deploy token username and Deploy token. Repeat for each token, up to 50 per connection, then click Save.

The GitLab settings in Hacktron, with separate username and token rows and the Add token buttonThe GitLab settings in Hacktron, with separate username and token rows and the Add token button
The GitLab settings in Hacktron, with separate username and token rows and the Add token button

To replace a saved token, enter the new value in its row and click Save. Leave it blank to keep the current token. If you change its username, enter a new token too.

To remove a token, click Remove token, then Save. Make sure your remaining tokens cover all selected private projects.

If prompted to Reload settings, reload and reapply your changes. Reloading discards unsaved edits.

Configure the webhook in GitLab

In the same Hacktron panel, copy the webhook URL and Secret token.

In GitLab, open Settings, then Webhooks, on each selected project and click Add new webhook. Paste the full URL, query string included, and paste the secret into GitLab’s Secret token field.

Enable these triggers:

  • Push events
  • Merge request events
  • Comments

Keep Enable SSL verification selected and click Add webhook.

Tip

On GitLab Premium or Ultimate, a group Owner can create one group webhook instead of a webhook on each project. Configure the webhook at the group level or the project level, not both, to avoid duplicate deliveries.

Enable merge request reviews

Enable Review for the selected repositories. Open or update a merge request to trigger a review.

Note

If reviews do not run, check the webhook URL, secret and triggers. Needs setup clears after you save a token, even if the webhook is missing. For repository access errors, check that a token has read_repository, is still valid and can read the project.

Self-hosted GitLab and GitLab Enterprise

Maintainer and Developer setup both work with self-hosted GitLab and GitLab Enterprise. Follow the steps above on your own instance.

Note

On self-managed GitLab, service accounts require GitLab EE, and by default only an instance administrator can create them. Administrators can also allow top-level group Owners to create them. Instead of a service account, you can use a personal access token from an existing user with the chosen access level and the same scopes.

When you open the Connect GitLab modal in Hacktron, select Self-hosted / GitLab Enterprise and enter your instance’s base URL, such as https://gitlab.example.com, before you enter the token.

  • Your GitLab instance must be reachable from Hacktron over HTTPS with a valid TLS certificate.
  • GitLab installed under a URL subpath, such as https://example.com/gitlab, is not supported. Use the instance’s base URL.
  • For Developer access, use the webhook URL and secret that Hacktron shows for this connection.
[↓] [↑] [enter] to visit
Menu
[M]
Next in menu
[J]
Previous in menu
[K]
Find
[F]
Ask
[A]
Sign in
[S]
Copy page
[C]
Listen
[L]
Justification
[R]
Language
[G]
Dark mode
[D]
High contrast
[H]
Shortcuts
[I]
Close
[Esc]