fixed gist direct link generation #2115
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
GitHub Gists are scanned using the
trufflehog github --repo <gist_url>
command, since a gist is just a git repo. At the moment, theGenerateLink
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:
make test-community
)?make lint
this requires golangci-lint)?