From 146eebe9235e01712bf56a745def6f8c15127573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Do=C4=9Fan=20Can=20Bak=C4=B1r?= Date: Thu, 11 Jan 2024 17:34:18 +0300 Subject: [PATCH] minor refactor --- v2/examples/main.go | 5 +---- v2/pkg/subscraping/sources/crtsh/crtsh.go | 8 ++++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/v2/examples/main.go b/v2/examples/main.go index da5a25c64..d6baf9d91 100644 --- a/v2/examples/main.go +++ b/v2/examples/main.go @@ -5,10 +5,8 @@ import ( "context" "io" "log" - "strconv" "github.com/projectdiscovery/subfinder/v2/pkg/runner" - contextutil "github.com/projectdiscovery/utils/context" ) func main() { @@ -33,8 +31,7 @@ func main() { output := &bytes.Buffer{} // To run subdomain enumeration on a single domain - ctx, _ := contextutil.WithValues(context.Background(), contextutil.ContextArg("All"), contextutil.ContextArg(strconv.FormatBool(subfinderOpts.All))) - if err = subfinder.EnumerateSingleDomainWithCtx(ctx, "hackerone.com", []io.Writer{output}); err != nil { + if err = subfinder.EnumerateSingleDomainWithCtx(context.Background(), "hackerone.com", []io.Writer{output}); err != nil { log.Fatalf("failed to enumerate single domain: %v", err) } diff --git a/v2/pkg/subscraping/sources/crtsh/crtsh.go b/v2/pkg/subscraping/sources/crtsh/crtsh.go index 6a7c09d28..d01a6e99f 100644 --- a/v2/pkg/subscraping/sources/crtsh/crtsh.go +++ b/v2/pkg/subscraping/sources/crtsh/crtsh.go @@ -63,10 +63,10 @@ func (s *Source) getSubdomainsFromSQL(ctx context.Context, domain string, sessio defer db.Close() limitClause := "" - all := ctx.Value(contextutil.ContextArg("All")).(contextutil.ContextArg) - allBool, _ := strconv.ParseBool(string(all)) - if !allBool { - limitClause = "LIMIT 10000" + if all, ok := ctx.Value(contextutil.ContextArg("All")).(contextutil.ContextArg); ok { + if allBool, err := strconv.ParseBool(string(all)); err == nil && !allBool { + limitClause = "LIMIT 10000" + } } query := fmt.Sprintf(`WITH ci AS (