mirror of
https://github.com/anotherhadi/github-recon.git
synced 2026-10-05 10:58:25 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
325397dfef | ||
|
|
dab0ba2b38 | ||
|
|
98769561c3 |
@@ -2,6 +2,7 @@ package recon
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
|
||||
github_recon_settings "github.com/anotherhadi/github-recon/settings"
|
||||
"github.com/anotherhadi/github-recon/utils"
|
||||
@@ -99,6 +100,9 @@ func Spoofing(s github_recon_settings.Settings) (response *SpoofingResult) {
|
||||
}
|
||||
utils.WaitForRateLimit(s, resp)
|
||||
|
||||
const maxRetries = 5
|
||||
const retryDelay = 2 * time.Second
|
||||
for i := 0; i < maxRetries; i++ {
|
||||
commits, _, err := s.Client.Repositories.ListCommits(s.Ctx, repo.Owner.GetLogin(), name, nil)
|
||||
if err != nil {
|
||||
s.Logger.Error("Error while listing commits", "err", err)
|
||||
@@ -112,8 +116,11 @@ func Spoofing(s github_recon_settings.Settings) (response *SpoofingResult) {
|
||||
response.Email = last.GetAuthor().GetEmail()
|
||||
response.Url = last.GetAuthor().GetHTMLURL()
|
||||
response.AvatarURL = last.GetAuthor().GetAvatarURL()
|
||||
} else {
|
||||
s.Logger.Error("Only one commit found, something went wrong.", "commits", commits)
|
||||
break
|
||||
}
|
||||
|
||||
s.Logger.Info("Only one commit found, retrying...", "attempt", i+1)
|
||||
time.Sleep(retryDelay)
|
||||
}
|
||||
|
||||
if response.Username == "" && response.Name == "" && response.Email == "" {
|
||||
|
||||
@@ -139,6 +139,11 @@ func DeepScan(s github_recon_settings.Settings) (response DeepScanResult) {
|
||||
}
|
||||
s.Logger.Info("Cloned all repositories", "path", tmp_folder)
|
||||
|
||||
if len(repositories) == 0 {
|
||||
s.Logger.Info("No repositories found for the user, skipping deep scan.")
|
||||
return
|
||||
}
|
||||
|
||||
authorOccurrences := Authors{}
|
||||
mapAuthorToIndex := make(map[string]int)
|
||||
for _, repo := range repositories {
|
||||
@@ -202,7 +207,7 @@ func DeepScan(s github_recon_settings.Settings) (response DeepScanResult) {
|
||||
Name: authorName,
|
||||
Email: authorEmail,
|
||||
FoundIn: []string{repoIdentifier},
|
||||
Levenshtein: utils.LevenshteinDistance(s.Target, authorName),
|
||||
Levenshtein: levenshteinDistanceAuthor(s.Target, authorName, authorEmail),
|
||||
})
|
||||
mapAuthorToIndex[trimmedLine] = len(authorOccurrences) - 1
|
||||
}
|
||||
@@ -380,3 +385,10 @@ func findEmailsAndOccurrencesInDir(rootPath string, username string) (Emails, er
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func levenshteinDistanceAuthor(target, name, email string) int {
|
||||
if strings.Contains(email, "@") {
|
||||
email = strings.SplitN(email, "@", 2)[0]
|
||||
}
|
||||
return slices.Min([]int{utils.LevenshteinDistance(target, name), utils.LevenshteinDistance(target, email)})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user