Skip to content

Simplified Gitlab Enumeration #4283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Jul 9, 2025

Conversation

kashifkhan0771
Copy link
Contributor

@kashifkhan0771 kashifkhan0771 commented Jul 2, 2025

Description:

Currently, theGitLab source enumerates projects via a complicated, multi-stage system of user queries, group queries, and deduplication. This PR simplify the approach by using list-all-projects API Call.

Checklist:

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

@kashifkhan0771 kashifkhan0771 requested review from a team as code owners July 2, 2025 07:38
@kashifkhan0771
Copy link
Contributor Author

I performed the following testing after making the changes:

  • Created one private project within a group
  • Created one private project outside of any group
  • Created one public project

When scanning, all three projects were correctly listed, confirming that the scan includes public, group-based, and standalone private repositories.

If there's any other scenario you'd like me to test, please feel free to let me know.

@kashifkhan0771 kashifkhan0771 requested review from ahrav, rosecodym and abmussani and removed request for a team July 2, 2025 07:41
Copy link
Collaborator

@rosecodym rosecodym left a comment

Choose a reason for hiding this comment

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

requesting changes pending the outcome of an internal conversation about flagging this

@kashifkhan0771 kashifkhan0771 requested a review from a team as a code owner July 3, 2025 14:10
Copy link
Collaborator

@rosecodym rosecodym left a comment

Choose a reason for hiding this comment

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

One small non-blocking request but otherwise this looks great! Thanks for doing it!

ctx.Logger().Info("starting projects enumeration",
"list_options", listOpts,
"all_available", *projectQueryOptions.Membership)
gitlabGroupsEnumerated.WithLabelValues(s.name).Set(0)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would you mind placing this metric reset next to the other one? I think it would make things a little clearer to the reader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's not necessary, as we're not enumerating groups in the simplified approach. I'll remove it. I must have overlooked this during the simplification process.

Comment on lines +644 to +645
// record the projectsWithNamespace for logging.
var projectsWithNamespace []string
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is only for logging the count, then we can make the memory usage efficient with something like:

var totalProjects int
...
totalProjects++
...
"count", totalProjects

@kashifkhan0771 kashifkhan0771 merged commit 7907482 into trufflesecurity:main Jul 9, 2025
13 checks passed
@kashifkhan0771 kashifkhan0771 deleted the update/oss-243 branch July 9, 2025 06:56
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.

3 participants