Skip to content

Conversation

@mustansir14
Copy link
Contributor

@mustansir14 mustansir14 commented Jan 19, 2026

Description:

When a TruffleHog user attempts to filter on specific repositories within Github using the repositories configuration, the scanner does not respect the endpoint configured and instead defaults to using github.com.

After some investigation, I found that this was because of the fact that the normalizeRepo function doesn't respect the Endpoint field and always prefixes the repos with https://github.com. This causes the filteredRepoCache to be incorrectly set. Even though the client is configured to use the endpoint, mismatch with the cache causes the scan to fail.

Checklist:

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

@mustansir14 mustansir14 requested a review from a team January 19, 2026 08:53
@mustansir14 mustansir14 requested a review from a team as a code owner January 19, 2026 08:53
if u, err := url.Parse(repo); err == nil {
parts := strings.Split(u.Path, "/")
if len(parts) >= 2 {
repoName = parts[len(parts)-2] + "/" + strings.TrimSuffix(parts[len(parts)-1], ".git")
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential trailing slash bug: if we ever get input like https://github.com/owner/repo.git/ for example, then this will give us repo.git/

Copy link
Contributor

Choose a reason for hiding this comment

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

➕ I would probably use strings.TrimRight to remove any trailing slashes and then path.Base to just get the base name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree. I didn't touch it because I didn't wanna change existing logic, but I guess yeah, this can be made better

Copy link
Contributor

@camgunz camgunz left a comment

Choose a reason for hiding this comment

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

Just the small trailing slash thing--maybe add a test case for that too

if u, err := url.Parse(repo); err == nil {
parts := strings.Split(u.Path, "/")
if len(parts) >= 2 {
repoName = parts[len(parts)-2] + "/" + strings.TrimSuffix(parts[len(parts)-1], ".git")
Copy link
Contributor

Choose a reason for hiding this comment

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

➕ I would probably use strings.TrimRight to remove any trailing slashes and then path.Base to just get the base name.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

// we want to remove any path components from the endpoint and just use the host
u.Path = "/" + repo
fullURL = u.String()
}
Copy link

Choose a reason for hiding this comment

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

Enterprise check uses wrong condition for standard GitHub

High Severity

The normalizeRepo function uses s.conn.Endpoint != "" to detect GitHub Enterprise, but this condition is also true when users explicitly set the endpoint to "https://api.github.com" (standard GitHub API). In this case, the function incorrectly generates repository URLs using api.github.com as the host (e.g., https://api.github.com/org/repo) instead of the correct github.com (e.g., https://github.com/org/repo). The connector code correctly handles this by checking if the endpoint equals cloudV3Endpoint or matches endsWithGithub, but normalizeRepo does not use the same logic.

Fix in Cursor Fix in Web

Copy link
Contributor

Choose a reason for hiding this comment

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

is this related to this?

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.

4 participants