Skip to content

Refactor GitLab access levels to log human-readable names#567

Merged
frjcomp merged 3 commits intomainfrom
copilot/refactor-gitlab-access-levels-logging
Mar 18, 2026
Merged

Refactor GitLab access levels to log human-readable names#567
frjcomp merged 3 commits intomainfrom
copilot/refactor-gitlab-access-levels-logging

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 18, 2026

GitLab access levels were logged as raw integers (e.g., accessLevel=30). This replaces them with human-readable names (e.g., accessLevel=Developer).

Changes

  • pkg/gitlab/util/util.go: Added AccessLevelName(gitlab.AccessLevelValue) string helper mapping SDK constants to names (No access, Guest, Developer, Maintainer, etc.), with Unknown (N) fallback
  • pkg/gitlab/enum/enum.go: Converted Int() log calls to Str() with AccessLevelName() for group and project access levels
  • pkg/gitlab/renovate/privesc/privesc.go: Converted Any() log calls to Str() with AccessLevelName() across all 6 access level log sites
  • pkg/gitlab/util/util_test.go: Table-driven tests for all 9 known levels + unknown fallback

Example

Before:

warn Project groupAccessLevel=30 projectAccessLevel=40

After:

warn Project groupAccessLevel=Developer projectAccessLevel=Maintainer

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • gitlab.com
    • Triggering command: /tmp/go-build1208580892/b2280/engine.test /tmp/go-build1208580892/b2280/engine.test -test.testlogfile=/tmp/go-build1208580892/b2280/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true 8580892/b2017/_p-errorsas t ux-amd64/pkg/tool/linux_amd64/vet -errorsas ssSecurity/pipel-o t ux-amd64/pkg/too-trimpath -ato�� -bool t ux-amd64/pkg/tool/linux_amd64/compile -errorsas -ifaceassert t ux-amd64/pkg/too-buildtags (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Refactor Gitlab Access Levels In Logs</issue_title>
<issue_description>In some of the GitLab related commands we are logging the gitlab access levels as their respective number. For readability we should refactor all those instances into logging the access level human readable names.

Example:
0 (No access), 5 (Minimal access), 10 (Guest), 15 (Planner), 20 (Reporter), 30 (Developer), 40 (Maintainer), 50 (Owner)

Refactor all instances in the code to log the human readable access level name. Retrieve the names from the official gitlab sdk already in use, do not create theses constants yourself.</issue_description>

Comments on the Issue (you are @copilot in this section)


📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

…numbers

Add AccessLevelName helper function in pkg/gitlab/util that maps
gitlab.AccessLevelValue to human-readable names using the official
GitLab SDK constants. Update all log statements in enum and renovate
privesc packages to use Str() with the helper instead of Int()/Any()
with raw numeric values.

Co-authored-by: frjcomp <107982661+frjcomp@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor GitLab access levels in logs for readability Refactor GitLab access levels to log human-readable names Mar 18, 2026
Copilot AI requested a review from frjcomp March 18, 2026 15:50
@frjcomp frjcomp marked this pull request as ready for review March 18, 2026 15:51
Copilot AI review requested due to automatic review settings March 18, 2026 15:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves GitLab-related log readability by replacing raw numeric access level values with human-readable names, making output easier to interpret during enumeration and exploit workflows.

Changes:

  • Added a util.AccessLevelName(gitlab.AccessLevelValue) string helper with an unknown fallback.
  • Updated GitLab enum and renovate privesc logging to emit access levels as strings instead of integers/Any().
  • Added table-driven tests covering known access levels plus an unknown fallback.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
pkg/gitlab/util/util.go Introduces AccessLevelName helper to map GitLab SDK access-level constants to readable names.
pkg/gitlab/util/util_test.go Adds unit tests for known access levels and unknown fallback behavior.
pkg/gitlab/enum/enum.go Updates token association logs to output access levels as readable strings.
pkg/gitlab/renovate/privesc/privesc.go Updates privesc logs to output readable access level names across checks and fatal messages.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@frjcomp frjcomp enabled auto-merge (squash) March 18, 2026 15:56
@frjcomp frjcomp merged commit eecf23d into main Mar 18, 2026
12 checks passed
@frjcomp frjcomp deleted the copilot/refactor-gitlab-access-levels-logging branch March 18, 2026 16:05
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.

Refactor Gitlab Access Levels In Logs

3 participants