GitLab

GitLab Integration

Pensar Console supports integration with both GitLab.com and self-hosted GitLab instances. The integration uses a Personal Access Token to provide secure access to your repositories.

Prerequisites

Before connecting GitLab, you’ll need:

  1. A GitLab account with access to the repositories you want to scan
  2. A Personal Access Token with the required scopes

Creating a Personal Access Token

To create a Personal Access Token in GitLab:

  1. Log in to your GitLab instance (gitlab.com or your self-hosted instance)
  2. Click on your avatar in the top right corner and select Preferences
  3. Navigate to Access Tokens in the left sidebar
  4. Click Add new token
  5. Fill in the token details:
    • Token name: Pensar (or your preferred name)
    • Expiration date: Choose an appropriate date (or leave blank for no expiration)
  6. Select the following scopes:
    • api - Full API access
    • read_api - Read-only API access
    • read_user - Read user information
    • read_repository - Read repository contents
  7. Click Create personal access token
  8. Copy the token immediately - you won’t be able to see it again

Store your Personal Access Token securely. If you lose it, you’ll need to create a new one.

Connecting GitLab

From Workspace Settings

  1. Navigate to SettingsIntegrations in your Pensar Console workspace
  2. Expand the GitLab section
  3. Click Connect GitLab
  4. If using a self-hosted GitLab instance, enter your GitLab host (e.g., gitlab.yourcompany.com)
    • Leave this blank if you’re using gitlab.com
  5. Enter your Personal Access Token
  6. Click Connect GitLab

From Onboarding

When creating a new workspace, you can connect GitLab during the onboarding process by clicking Connect your Gitlab account and following the same steps.

The GitLab host should not include https:// - just enter the hostname (e.g., gitlab.yourcompany.com).

Permissions

The Personal Access Token requires the following scopes:

ScopePurpose
apiFull access to the API for creating merge requests and managing code
read_apiRead-only access to the API for fetching project information
read_userRead user information for attribution
read_repositoryRead repository contents for security scanning

Adding Repositories

After connecting GitLab:

  1. Go to ProjectsNew Project in Pensar Console
  2. Your GitLab projects will appear in the repository list
  3. Select a project and configure your settings
  4. Click Create Project to start scanning

Self-Hosted GitLab

Pensar supports self-hosted GitLab instances. When connecting:

  1. Enter your GitLab instance hostname (e.g., gitlab.yourcompany.com)
  2. Ensure your GitLab instance is accessible from the internet
  3. Use an access token from your self-hosted instance

If your GitLab instance is behind a firewall or VPN, contact Pensar support to discuss connectivity options.

Managing the Integration

Viewing Connection Status

  1. Navigate to SettingsIntegrations
  2. Expand the GitLab section
  3. If connected, you’ll see a confirmation and the option to disconnect

Updating the Token

To update your Personal Access Token (e.g., if it’s expiring):

  1. Create a new Personal Access Token in GitLab with the same scopes
  2. Navigate to SettingsIntegrations in Pensar Console
  3. Disconnect the current GitLab connection
  4. Reconnect with the new token

Disconnecting GitLab

To remove the GitLab integration:

  1. Navigate to SettingsIntegrations
  2. Expand the GitLab section
  3. Click Disconnect GitLab

Disconnecting GitLab will prevent Pensar from scanning GitLab repositories. Any projects using GitLab repositories will no longer be able to perform scans.

Troubleshooting

Invalid Token

If you see an error about an invalid token:

  1. Verify the token hasn’t expired
  2. Ensure the token has all required scopes
  3. Check that you copied the entire token without extra spaces

Repositories Not Appearing

If your repositories don’t appear in the project creation list:

  1. Verify you have at least Developer access to the repositories in GitLab
  2. Check that the token has the read_repository scope
  3. For self-hosted instances, ensure the hostname is correct

Connection Errors

For self-hosted GitLab instances:

  1. Verify the hostname is correct and accessible
  2. Ensure HTTPS is properly configured on your GitLab instance
  3. Check that there are no firewall rules blocking the connection

Need Help?

If you encounter issues setting up your GitLab integration, please contact our support team at team@pensarai.com.