From c163fb4ecd571333d8222413dadf79f62ab842d2 Mon Sep 17 00:00:00 2001 From: Hadi <112569860+anotherhadi@users.noreply.github.com> Date: Wed, 17 Sep 2025 21:26:54 +0200 Subject: [PATCH] Fatal only in cmd Signed-off-by: Hadi <112569860+anotherhadi@users.noreply.github.com> --- cmd/main.go | 12 ++++++++++-- github-recon/username/main.go | 12 +++++++----- github-recon/username/user.go | 8 ++++---- settings/settings.go | 4 ++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 841a504..814e1b6 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,6 +1,8 @@ package main import ( + "log" + recon_email "github.com/anotherhadi/github-recon/github-recon/email" recon_username "github.com/anotherhadi/github-recon/github-recon/username" github_recon_settings "github.com/anotherhadi/github-recon/settings" @@ -8,7 +10,10 @@ import ( ) func main() { - settings := github_recon_settings.GetSettings() + settings, err := github_recon_settings.GetSettings() + if err != nil { + log.Fatal(err) + } if !settings.Silent { utils.Header() @@ -23,7 +28,10 @@ func main() { } if settings.TargetType == github_recon_settings.TargetUsername { - result := recon_username.Username(settings) + result, err := recon_username.Username(settings) + if err != nil { + log.Fatal(err) + } writeJson(settings, result) } else { result := recon_email.Email(settings) diff --git a/github-recon/username/main.go b/github-recon/username/main.go index 6531a1f..ab11dd7 100644 --- a/github-recon/username/main.go +++ b/github-recon/username/main.go @@ -27,16 +27,18 @@ type UsernameResult struct { DeepScan DeepScanResult } -func Username(settings github_recon_settings.Settings) UsernameResult { - - result := UsernameResult{ +func Username(settings github_recon_settings.Settings) (result UsernameResult, err error) { + result = UsernameResult{ Target: settings.Target, TargetType: settings.TargetType, DateTime: time.Now().String(), } utils.PrintTitle(settings.Silent, "👤 User informations") - result.User = User(settings) + result.User, err = User(settings) + if err != nil { + return + } utils.PrintAvatar(settings, result.User.AvatarURL) utils.PrintStruct(settings, result.User, 0) @@ -74,5 +76,5 @@ func Username(settings github_recon_settings.Settings) UsernameResult { utils.PrintStruct(settings, result.DeepScan, 0) } - return result + return } diff --git a/github-recon/username/user.go b/github-recon/username/user.go index 6335a2e..fadbfbb 100644 --- a/github-recon/username/user.go +++ b/github-recon/username/user.go @@ -31,13 +31,13 @@ type UserResult struct { Plan string } -func User(s github_recon_settings.Settings) (response UserResult) { +func User(s github_recon_settings.Settings) (response UserResult, err error) { user, resp, err := s.Client.Users.Get(s.Ctx, s.Target) if resp.StatusCode == 404 { - s.Logger.Fatal("User not found with username") + return UserResult{}, fmt.Errorf("user not found with username: %s", s.Target) } if err != nil { - s.Logger.Fatal("Failed to fetch user's information", "err", err) + return UserResult{}, fmt.Errorf("failed to fetch user's information") } u := UserResult{ @@ -65,5 +65,5 @@ func User(s github_recon_settings.Settings) (response UserResult) { } utils.WaitForRateLimit(s, resp) - return u + return u, nil } diff --git a/settings/settings.go b/settings/settings.go index 0b4c9cc..fe7e75a 100644 --- a/settings/settings.go +++ b/settings/settings.go @@ -68,7 +68,7 @@ func GetDefaultSettings() Settings { } } -func GetSettings() (settings Settings) { +func GetSettings() (settings Settings, err error) { settings = GetDefaultSettings() //// Flag settings flag.Usage = func() { @@ -152,7 +152,7 @@ func GetSettings() (settings Settings) { settings.Target = strings.TrimPrefix(settings.Target, "@") // Remove the @ of the username if strings.Contains(settings.Target, " ") { - settings.Logger.Fatal("Target cannot contain spaces") + err = fmt.Errorf("target cannot contain spaces") } if strings.Contains(settings.Target, "@") {