CBOM Documentation

CBOM Secure

  • Administrative Guide
  • Login and Authentication
    • Overview
    • Dashboard Interface
    • Dashboard Operations
    • Data Visualization
    • Overview
    • Host
    • Template
      • Networked Deployments
      • Cloud Deployments
      • Off-Grid Deployments
      • Tags
      • Integrations
      • Cloud Servers
      • CycloneDX Export
    • Sensors Reference
    • Overview
    • Summary Report
    • PQC Report
    • AI Services
    • Source Code Visualizer
    • Key
    • Certificate
    • CipherSuites
    • Analysis
    • Policy Management
    • User Policy
    • Standard Policy
    • User Management
    • Roles & Permissions
    • System Configuration
    • Introduction
      • Components
      • Data Flows
      • Execution Models
      • Incremental Scanning
      • Security Model
      • Quick Start
      • Topologies
      • Sizing Guide
      • HA and Scaling
      • HA Runbooks
      • Ports and Firewall
      • Reverse Proxy
      • Prerequisites
      • Docker Compose
      • Native on Linux
      • Deployment Server
      • Install Troubleshooting
      • Validation Checklist
      • Managing Services
      • Logging
      • Certificates
      • Configuration
      • Database Administration
      • Backup and Recovery
      • Upgrade and Migration
      • Ops Troubleshooting
      • Methods
      • SAML 2.0 SSO
      • OIDC and Entra ID
      • Token Authentication
      • Password Policy
      • Sensor vs Connector
      • Sensor Guide Structure
      • Capability Matrix
        • AWS
        • Azure
        • Google Cloud
        • Active Directory
        • LDAP Directories
        • AD CS
        • EJBCA
        • CertSecure Manager
        • Thales Luna HSM
        • Entrust nShield HSM
        • SoftHSM2
        • HashiCorp Vault KMIP
        • MSSQL TDE
        • Oracle TDE
        • MySQL TDE
        • MariaDB TDE
        • HTTPS and TLS
        • SSH Servers
        • Windows Certificate Store
        • Linux Trust Store
        • Java Keystores
        • PKCS#12 Keystores
        • GnuPG Keyrings
        • Binaries and Libraries
        • Source Code Scanning
        • GitHub
        • GitLab
        • Bitbucket
        • Local Git
      • Roadmap
      • Integration Model
      • CrowdStrike
      • ServiceNow
      • ServiceNow and Jira Setup
      • Notification Engine
    • Glossary
    • Configuration Reference
    • Data Model Reference
    • API Reference
    • API Authentication
    • Running a Scan via API
    • Searching via API
    • CycloneDX Export Specification
    • Risk and PQC Scoring
    • Built-in Standards
    • Widget Catalogue
    • AI Services Data Handling

GitLab Setup Guide for CBOM Source Code Discovery Sensor

1. Purpose

This document describes the step-by-step procedure to configure GitLab so that the CBOM Source Code Discovery Sensor can successfully discover cryptographic material embedded in source code repositories, including:

  • Hardcoded private keys and certificates committed to source files

  • API tokens and secret strings stored in code or configuration files

  • SSH private key files tracked in repositories

  • Cryptographic configuration files (e.g., OpenSSL configs, key store references)

The procedure covers:

  • Creating a Personal Access Token (PAT) with least-privilege scopes

  • Creating a Project Access Token for single-project scoping

  • Configuring self-managed GitLab instance URLs

  • Configuring the CBOM sensor YAML

  • Validating the connection and reviewing common errors

2. Prerequisites

Before starting, ensure:

  • You have access to a GitLab account (GitLab SaaS at gitlab.com or a self-managed instance)

  • You are signed in as: A GitLab user with at least Reporter role on the target group or project, or An Administrator (for group-level tokens or self-managed configuration)

  • For self-managed instances: GitLab version 13.0 or later (Personal Access Tokens) or 14.1 or later (Project Access Tokens)

  • The CBOM Collector service has network access (HTTP/HTTPS) to the GitLab instance

3. Create a Personal Access Token

A Personal Access Token (PAT) grants the sensor read access to all projects visible to your GitLab account.

3.1 Open User Settings
  1. Sign in to GitLab

  2. Click your avatar in the top-right corner

  3. Select Edit profile

  4. In the left sidebar, click Access Tokens

3.2 Configure Token Details

Fill in the following fields:

  • Token name: cbom-source-discovery

  • Expiration date: Set an appropriate expiry (e.g., one year from today); leave blank for no expiry (not recommended)

  • Scopes: Select the following minimum required scopes: read_api — grants read-only access to the GitLab API (required to list projects and namespaces) read_repository — grants read-only access to repository contents (required to scan file trees)

Do not select write scopes (write_repository, api, etc.).

3.3 Create the Token
  1. Click Create personal access token

  2. The generated token value will be displayed once only — copy it immediately and store it in a secure vault or password manager

The token will appear in the format:

glpat-xxxxxxxxxxxxxxxxxxxx
3.4 CLI Alternative — Create Token via GitLab API

If scripted provisioning is required, an existing token with api scope can create a new PAT:

curl --request POST \
  --header "PRIVATE-TOKEN: <existing_admin_token>" \
  --header "Content-Type: application/json" \
  --data '{
    "name": "cbom-source-discovery",
    "scopes": ["read_api", "read_repository"],
    "expires_at": "2027-01-01"
  }' \
  "https://gitlab.com/api/v4/users/<user_id>/personal_access_tokens"

Replace <existing_admin_token> with a token that has api scope and <user_id> with the numeric GitLab user ID.

4. Create a Project Access Token (Single-Project Scoping)

If you want to restrict the sensor to a single project rather than all projects visible to a user, use a Project Access Token.

4.1 Open Project Settings
  1. Navigate to the target project in GitLab

  2. In the left sidebar, select Settings → Access Tokens

4.2 Configure Project Token Details

Fill in the following fields:

  • Token name: cbom-source-discovery

  • Expiration date: Set an appropriate expiry

  • Role: Select Reporter (minimum required role)

  • Scopes: Select: read_api read_repository

4.3 Create the Project Token
  1. Click Create project access token

  2. Copy the generated token value immediately — it is shown only once

5. Self-Managed GitLab — URL Configuration

For self-managed GitLab instances, you must provide the correct API base URL and handle any custom TLS certificates.

5.1 Confirm API Base URL

The GitLab API base URL follows this pattern:

https://<your-gitlab-hostname>/api/v4

Verify the API is reachable:

curl -s --header "PRIVATE-TOKEN: <your_token>" \
  "https://<your-gitlab-hostname>/api/v4/version"

A successful response returns JSON with version and revision fields.

5.2 TLS CA Certificate Handling

If your self-managed instance uses a private or internal certificate authority:

  1. Obtain the CA certificate in PEM format from your PKI team

  2. Save it to a path accessible by the CBOM Collector service, for example:

    /etc/cbom/certs/gitlab-ca.pem
  3. Reference the CA certificate path in the sensor configuration (see Section 6)

6. Configure the CBOM Sensor YAML

Use the token and instance URL in the CBOM source code discovery sensor configuration. Three common variants are shown below.

6.1 GitLab SaaS — Personal Access Token
sensor: Discover_SourceCode
platform: gitlab
gitlab_url: "https://gitlab.com"
private_token: "glpat-xxxxxxxxxxxxxxxxxxxx"
scan_groups:
  - "my-org-group"
scan_name: GitLabSourceCodeDiscovery
6.2 Self-Managed GitLab — Personal Access Token
sensor: Discover_SourceCode
platform: gitlab
gitlab_url: "https://gitlab.internal.example.com"
private_token: "glpat-xxxxxxxxxxxxxxxxxxxx"
ssl_ca_cert: "/etc/cbom/certs/gitlab-ca.pem"
scan_groups:
  - "engineering"
  - "security"
scan_name: GitLabSelfManagedDiscovery
6.3 Single Project — Project Access Token
sensor: Discover_SourceCode
platform: gitlab
gitlab_url: "https://gitlab.com"
private_token: "glpat-xxxxxxxxxxxxxxxxxxxx"
scan_projects:
  - "my-org-group/my-repository"
scan_name: GitLabProjectDiscovery

7. Validation

After configuring the sensor:

7.1 Check Task Logs
  1. Run the source code discovery task from the CBOM interface

  2. Open the task log and confirm: Task status shows completed or running without authentication errors Repository file trees are being enumerated * No 401 Unauthorized or 403 Forbidden errors appear

7.2 Verify Token Last-Used Timestamp in GitLab UI
  1. In GitLab, go to your avatar → Edit profile → Access Tokens

  2. Locate the cbom-source-discovery token

  3. Confirm the Last Used column shows a recent timestamp matching the discovery run

7.3 Direct API Verification via curl

Verify token access to the API:

curl -s --header "PRIVATE-TOKEN: glpat-xxxxxxxxxxxxxxxxxxxx" \
  "https://gitlab.com/api/v4/projects?membership=true&per_page=5"

Verify repository read access for a specific project:

curl -s --header "PRIVATE-TOKEN: glpat-xxxxxxxxxxxxxxxxxxxx" \
  "https://gitlab.com/api/v4/projects/<project_id>/repository/tree"

A successful response returns a JSON array of files and directories. A 401 or 403 response indicates a token or permission issue.

8. Common Errors and Resolution

Error: 401 Unauthorized
HTTP 401: {"message": "401 Unauthorized"}

Cause:

  • The token value is incorrect or has been revoked

  • The token has expired

Resolution:

  • Verify the token value in the sensor YAML matches the generated token exactly

  • Check the token's expiry date in GitLab → Settings → Access Tokens

  • Regenerate the token if necessary and update the sensor configuration

Error: 403 Forbidden
HTTP 403: {"message": "403 Forbidden"}

Cause:

  • The token has the correct value but lacks required scopes (read_api or read_repository)

  • For Project Access Tokens: the assigned role is below Reporter

  • The target group or project has additional access restrictions

Resolution:

  • Delete the existing token and create a new one with both read_api and read_repository scopes

  • For Project Access Tokens, ensure the Reporter role (or higher) is selected

  • Confirm the GitLab user or service account has at least Reporter access to the target namespace

Error: SSL Certificate Verify Failed
SSLError: certificate verify failed: unable to get local issuer certificate

Cause:

  • The self-managed GitLab instance uses a certificate signed by a private or internal CA

  • The CA certificate is not trusted by the CBOM Collector service

Resolution:

  • Obtain the CA certificate PEM file from your PKI or GitLab administrator

  • Set the ssl_ca_cert field in the sensor YAML to the absolute path of the CA PEM file

  • Ensure the Collector service process has read access to the CA certificate file

9. Security Recommendations

For production environments:

  • Use a dedicated service account: Create a dedicated GitLab user (e.g., cbom-scanner) rather than using a personal developer account; this isolates token revocation and audit trail

  • Restrict token scopes: Grant only read_api and read_repository — do not grant api (full access) or any write scopes

  • Rotate tokens periodically: Set a token expiry date and establish a rotation process; update the sensor YAML when tokens are rotated

  • Use IP allowlists: On self-managed GitLab instances, configure token IP restrictions (GitLab EE feature) to limit token use to the CBOM Collector's IP address

  • Review GitLab audit logs: Periodically review GitLab's audit event log (Admin → Monitoring → Audit Events) to confirm the service account activity matches expected discovery schedules

10. Conclusion

Following this guide ensures that the CBOM Source Code Discovery Sensor operates with:

  • Least-privilege access using only read_api and read_repository scopes

  • Read-only repository access with no ability to modify code or settings

  • Full compatibility with both GitLab SaaS and self-managed GitLab instances

  • Proper TLS trust configuration for internal certificate authorities

On this Page:
Support Privacy Policy Terms of Service

Copyright 2026 Encryption Consulting LLC. All rights reserved.