Skip to content

feat(shield): add GitLab Personal Access Token detection#57

Merged
PythonWoods-Dev merged 1 commit intoPythonWoods:mainfrom
gtanb4l:feat/gitlab-pat-detection
Apr 16, 2026
Merged

feat(shield): add GitLab Personal Access Token detection#57
PythonWoods-Dev merged 1 commit intoPythonWoods:mainfrom
gtanb4l:feat/gitlab-pat-detection

Conversation

@gtanb4l
Copy link
Copy Markdown
Contributor

@gtanb4l gtanb4l commented Apr 15, 2026

Summary

Adds GitLab Personal Access Token (glpat-) detection to the Shield credential scanner.

Changes

  • Added gitlab-pat pattern: glpat-[A-Za-z0-9\-_]{20,} to _SECRETS list
  • Updated module docstring to document the new pattern
  • Added 4 test cases:
    • Basic PAT detection
    • PAT embedded in URL
    • False positive guard (short strings)
    • Clean line verification

Pattern Details

  • Format: glpat- followed by 20+ alphanumeric/underscore/hyphen characters
  • Minimum length ensures low false positive rate

Testing

All regex patterns verified manually (project requires Python 3.10+ for full test suite).

Closes #53

Add regex pattern for GitLab PATs (glpat-[A-Za-z0-9\-_]{20,}) to the
Shield credential scanner.

- Added gitlab-pat pattern to _SECRETS list in shield.py
- Updated docstring to document the new pattern
- Added 4 test cases: detection, URL embedding, false positive guard,
  and clean line verification

Closes PythonWoods#53
Copy link
Copy Markdown
Contributor

@PythonWoods-Dev PythonWoods-Dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean, well-scoped contribution — thanks @gtanb4l! 🛡️

Pattern, tests, and placement all look good. 963 tests pass with the change.

One minor issue I'll fix in a follow-up commit: the docstring at line 19 of shield.py uses \- which triggers a SyntaxWarning: invalid escape sequence on Python 3.12+. It needs to be \\- in the docstring. The regex itself (line 84) is correct.

Merging now.

@PythonWoods-Dev PythonWoods-Dev merged commit a1f612f into PythonWoods:main Apr 16, 2026
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
- Fix SyntaxWarning in Shield docstring (\- → \\-), follow-up to PR #57
- Add PR #55 (--format json individual commands) to [Unreleased] (EN+IT)
- Add PR #57 (GitLab PAT detection) to [Unreleased] (EN+IT)
PythonWoods-Dev added a commit that referenced this pull request Apr 16, 2026
…gelog

fix: escape docstring + update [Unreleased] changelog (PR #55, #57)
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.

Shield: detect GitLab Personal Access Tokens

2 participants