8000
Skip to content

Add support to Gitlab v1 for older self hosted versions#4881

Open
jamesgol wants to merge 1 commit intotrufflesecurity:mainfrom
jamesgol:gitlab_selfhosted
Open

Add support to Gitlab v1 for older self hosted versions#4881
jamesgol wants to merge 1 commit intotrufflesecurity:mainfrom
jamesgol:gitlab_selfhosted

Conversation

@jamesgol
Copy link
Copy Markdown
Contributor
@jamesgol jamesgol commented Apr 9, 2026

Description:

Fixes the GitLab v1 detector not matching personal access tokens that use the dotted format ({base}.{version}.{checksum}) without a glpat- prefix. This format is generated by older self-hosted GitLab instances that adopted the new token structure before adding the prefix.

Problem: The three GitLab detectors have a gap:

  • v1 only matches 20-22 character tokens
  • v2/v3 require the glpat- prefix

Tokens in the dotted format without glpat- fall through all three.

Fix: Added a second regex pattern (keyPatDotted) to the v1 detector that matches the dotted token format without requiring glpat-. The existing glpat- skip logic ensures no overlap with v2/v3. Matches from both patterns are deduplicated before processing.

Tests: Added two test cases to TestGitLab_Pattern:

  • Dotted format without glpat- prefix is matched
  • Dotted format with glpat- prefix is still ignored (handled by v2/v3)

Closes #4880

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

Note

Medium Risk
Expands GitLab token detection via a new regex and match-deduping, which could slightly increase false positives/scan volume if the dotted pattern is overly permissive.

Overview
Extends the GitLab v1 detector to also match dotted-format PATs ({base}.{version}.{checksum}) that lack the glpat- prefix (seen in older self-hosted GitLab), while continuing to ignore glpat- tokens handled by v2/v3.

Updates FromData to aggregate matches from both the legacy short-token regex and the new dotted regex, deduplicating tokens before entropy checking and result generation, and adds test coverage for both dotted-token scenarios (match without glpat-, ignore with glpat-).

Reviewed by Cursor Bugbot for commit e8a70ce. Bugbot is set up for automated code reviews on this repo. Configure here.

@jamesgol jamesgol requested a review from a team April 9, 2026 05:35
@jamesgol jamesgol requested a review from a team as a code owner April 9, 2026 05:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GitLab detector misses tokens from older self hosted instances

1 participant

0