Skip to content

Fixed gitlab detector#4371

Merged
kashifkhan0771 merged 11 commits into
trufflesecurity:mainfrom
kashifkhan0771:fix/oss-281
Aug 13, 2025
Merged

Fixed gitlab detector#4371
kashifkhan0771 merged 11 commits into
trufflesecurity:mainfrom
kashifkhan0771:fix/oss-281

Conversation

@kashifkhan0771

@kashifkhan0771 kashifkhan0771 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Description:

Fixes: #4370

Checklist:

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

@kashifkhan0771 kashifkhan0771 requested a review from a team August 7, 2025 06:36

@shahzadhaider1 shahzadhaider1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor (non-blocking) suggestions.

Comment thread pkg/detectors/gitlab/v1/gitlab.go
Comment thread pkg/detectors/gitlab/v2/gitlab_v2.go
@kashifkhan0771 kashifkhan0771 self-assigned this Aug 7, 2025
for _, endpoint := range s.Endpoints() {
s1 := detectors.Result{
DetectorType: detectorspb.DetectorType_Gitlab,
Raw: []byte(resMatch),

@amanfcp amanfcp Aug 7, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In a single data string, if we have 2 set of credentials and only 2nd endpoint is correct, it would not be possible to identify why one result is verified and the other is not.

Suggested change
Raw: []byte(resMatch),
Raw: []byte(resMatch),
RawV2: []byte(resMatch + endpoint),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I had considered this change but hesitated, concerned it might duplicate existing results in the Enterprise.
I think @rosecodym can comment better on this change.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yup, you're right. Raw/RawV2 is like a primary key, and updating it even slightly can have impacts on the enterprise data, so let's not touch that. Instead, we can store the endpoint in the extra data.

@amanfcp amanfcp Aug 7, 2025

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This could cause problems in diagnosing issues later on in enterprise too. This just might require migration.
Also, I'm positive that "adding" a RawV2 won't require migration
@rosecodym awaiting your response.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, adding a RawV2 that wasn't there before is fine and won't affect the deduplication fingerprinting.
Changing Raw or RawV2 will cause issues though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks @dustin-decker for the clarification - I updated the code.

@amanfcp amanfcp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! Thanks @kashifkhan0771

@kashifkhan0771 kashifkhan0771 merged commit 836ed28 into trufflesecurity:main Aug 13, 2025
13 checks passed
peterfraedrich pushed a commit to peterfraedrich/trufflehog that referenced this pull request Mar 15, 2026
* Fixed gitlab detector

* moved validations outside endpoints loop

* resolved comments

* resolved comments
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.

Custom Verifier are not working in new version

4 participants