Skip to content
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

fixed gist direct link generation #2115

Merged
merged 3 commits into from
Nov 20, 2023
Merged

fixed gist direct link generation #2115

merged 3 commits into from
Nov 20, 2023

Conversation

joeleonjr
Copy link
Contributor

Description:

GitHub Gists are scanned using the trufflehog github --repo <gist_url> command, since a gist is just a git repo. At the moment, the GenerateLink function used to craft links to specific files from commit in GitHub repos containing secrets does not work properly for gists. The formatting does not include "blob" or "commit" and the fragment identifier works slightly differently (ex: /#file-filename-txt-L5).

I adjusted the logic so that it generates accurate direct links to gists containing secrets.

Here are two gists to test this out on:

https://gist.github.com/joeleonjr/be68e34b002e236160dbb394bbda86fb (note two different AWS canary tokens leaked at different commits)

https://gist.github.com/joeleonjr/21b3d4460c54d4f8e18a7f71f5d4cb21 (note the file name with multiple extensions...those are converted from "." into "-" by GH)

Checklist:

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

@joeleonjr joeleonjr requested a review from a team as a code owner November 17, 2023 18:29
@mcastorina
Copy link
Collaborator

Thanks! Could you also add a test case here?

@joeleonjr
Copy link
Contributor Author

Thanks! Could you also add a test case here?

Added! Please let me know if you need more.

Copy link
Collaborator

@mcastorina mcastorina left a comment

Choose a reason for hiding this comment

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

💯

@joeleonjr joeleonjr merged commit cd9c1ae into main Nov 20, 2023
8 checks passed
@joeleonjr joeleonjr deleted the gist-link-generation-fix branch November 20, 2023 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants