From 4f1db656d25b7fe666d3e8a87b44c7bf03070db3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 6 Mar 2022 18:59:03 +0000 Subject: [PATCH 01/13] chore(deps): bump actions/checkout from 2 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/build-test.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .github/workflows/dockerhub-push.yml | 2 +- .github/workflows/lint-test.yml | 2 +- .github/workflows/release-binary.yml | 2 +- .github/workflows/sonarcloud.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index e4cd58188..35bca59d7 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -18,7 +18,7 @@ jobs: go-version: 1.17 - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Build run: go build ./... diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 545cdea93..601d89a17 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -23,7 +23,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v3 # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL diff --git a/.github/workflows/dockerhub-push.yml b/.github/workflows/dockerhub-push.yml index 2786e270c..02f1c566e 100644 --- a/.github/workflows/dockerhub-push.yml +++ b/.github/workflows/dockerhub-push.yml @@ -13,7 +13,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Get Github tag id: meta diff --git a/.github/workflows/lint-test.yml b/.github/workflows/lint-test.yml index 46ae20506..051f8fb74 100644 --- a/.github/workflows/lint-test.yml +++ b/.github/workflows/lint-test.yml @@ -9,7 +9,7 @@ jobs: name: Lint Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: actions/setup-go@v2 with: go-version: 1.17 diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 69995dac7..cb714d47f 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest steps: - name: "Check out code" - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: fetch-depth: 0 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index c869aa7ea..7792583c6 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -13,7 +13,7 @@ jobs: name: SonarCloud runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis From 948cb0d02fb414df278aa3e0f648ade3ff1837cd Mon Sep 17 00:00:00 2001 From: sandeep Date: Mon, 7 Mar 2022 01:09:38 +0530 Subject: [PATCH 02/13] dev version update --- v2/pkg/runner/banners.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index 7f11d2666..f4448594a 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -11,11 +11,11 @@ const banner = ` _______ __/ /_ / __(_)___ ____/ /__ _____ / ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/ (__ ) /_/ / /_/ / __/ / / / / /_/ / __/ / -/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.0 +/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.1-dev ` // Version is the current version of subfinder -const Version = `v2.5.0` +const Version = `v2.5.1-dev` // showBanner is used to show the banner to the user func showBanner() { From dd3e9950141320c68fb1d1b9bff5c53b64b51e7b Mon Sep 17 00:00:00 2001 From: LuitelSamikshya Date: Mon, 7 Mar 2022 09:47:01 -0600 Subject: [PATCH 03/13] filter ip from targets --- v2/pkg/runner/options.go | 4 +++- v2/pkg/runner/runner.go | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index ca20db7f8..8d22d1774 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -60,7 +60,8 @@ type Options struct { Proxy string // HTTP proxy RateLimit int // Maximum number of HTTP requests to send per second // YAMLConfig contains the unmarshalled yaml config file - Providers *Providers + Providers *Providers + ExcludeIps bool } // ParseOptions parses the command line flags provided by a user @@ -116,6 +117,7 @@ func ParseOptions() *Options { flagSet.StringVarP(&options.ResolverList, "rlist", "rL", "", "file containing list of resolvers to use"), flagSet.BoolVarP(&options.RemoveWildcard, "active", "nW", false, "display active subdomains only"), flagSet.StringVar(&options.Proxy, "proxy", "", "http proxy to use with subfinder"), + flagSet.BoolVarP(&options.ExcludeIps, "exclude-ip", "ei", false, "Exclude ips from the list of domains"), ) createGroup(flagSet, "debug", "Debug", diff --git a/v2/pkg/runner/runner.go b/v2/pkg/runner/runner.go index 917df96d9..feef4b9e2 100644 --- a/v2/pkg/runner/runner.go +++ b/v2/pkg/runner/runner.go @@ -6,6 +6,7 @@ import ( "io" "os" "path" + "regexp" "strings" "github.com/pkg/errors" @@ -71,9 +72,11 @@ func (r *Runner) RunEnumeration(ctx context.Context) error { // We keep enumerating subdomains for a given domain until we reach an error func (r *Runner) EnumerateMultipleDomains(ctx context.Context, reader io.Reader, outputs []io.Writer) error { scanner := bufio.NewScanner(reader) + ip, _ := regexp.Compile(`^([0-9\.]+$)`) for scanner.Scan() { domain, err := sanitize(scanner.Text()) - if errors.Is(err, ErrEmptyInput) { + isIp := ip.MatchString(domain) + if errors.Is(err, ErrEmptyInput) || (r.options.ExcludeIps && isIp) { continue } From 3be7e3da0d33a5f2b9a14e6adc45b191cc6c1a12 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:05:01 +0000 Subject: [PATCH 04/13] chore(deps): bump alpine from 3.15.0 to 3.15.1 Bumps alpine from 3.15.0 to 3.15.1. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e46693d45..e4a5a77ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.17-alpine AS build-env RUN go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest # Release -FROM alpine:3.15.0 +FROM alpine:3.15.1 RUN apk -U upgrade --no-cache \ && apk add --no-cache bind-tools ca-certificates COPY --from=build-env /go/bin/subfinder /usr/local/bin/subfinder From 47bb7a0a9b73f59bb0d6da80eb0f0cf9147109b6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 14:05:04 +0000 Subject: [PATCH 05/13] chore(deps): bump golang from 1.17-alpine to 1.18.0-alpine Bumps golang from 1.17-alpine to 1.18.0-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e46693d45..c41f539e9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Build -FROM golang:1.17-alpine AS build-env +FROM golang:1.18.0-alpine AS build-env RUN go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest # Release From 984f329069dfabc680b731f36321457092d33e5a Mon Sep 17 00:00:00 2001 From: Alexey Zhuchkov Date: Thu, 24 Mar 2022 23:43:58 +0300 Subject: [PATCH 06/13] Use json results for output --- v2/pkg/resolve/resolve.go | 4 ++-- v2/pkg/runner/outputter.go | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/v2/pkg/resolve/resolve.go b/v2/pkg/resolve/resolve.go index 3e254af4c..65c897362 100644 --- a/v2/pkg/resolve/resolve.go +++ b/v2/pkg/resolve/resolve.go @@ -25,8 +25,8 @@ type ResolutionPool struct { // HostEntry defines a host with the source type HostEntry struct { - Host string `json:"host"` - Source string `json:"source"` + Host string + Source string } // Result contains the result for a host resolution diff --git a/v2/pkg/runner/outputter.go b/v2/pkg/runner/outputter.go index 17bdd636c..24edf4512 100644 --- a/v2/pkg/runner/outputter.go +++ b/v2/pkg/runner/outputter.go @@ -17,13 +17,18 @@ type OutPutter struct { JSON bool } -type jsonResult struct { +type jsonSourceResult struct { + Host string `json:"host"` + Source string `json:"source"` +} + +type jsonSourceIPResult struct { Host string `json:"host"` IP string `json:"ip"` Source string `json:"source"` } -type jsonSourceResult struct { +type jsonSourcesResult struct { Host string `json:"host"` Sources []string `json:"sources"` } @@ -99,7 +104,7 @@ func writePlainHostIP(results map[string]resolve.Result, writer io.Writer) error func writeJSONHostIP(results map[string]resolve.Result, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) - var data jsonResult + var data jsonSourceIPResult for _, result := range results { data.Host = result.Host @@ -156,8 +161,11 @@ func writePlainHost(results map[string]resolve.HostEntry, writer io.Writer) erro func writeJSONHost(results map[string]resolve.HostEntry, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) + var data jsonSourceResult for _, result := range results { - err := encoder.Encode(result) + data.Host = result.Host + data.Source = result.Source + err := encoder.Encode(data) if err != nil { return err } @@ -179,7 +187,7 @@ func (o *OutPutter) WriteSourceHost(sourceMap map[string]map[string]struct{}, wr func writeSourceJSONHost(sourceMap map[string]map[string]struct{}, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) - var data jsonSourceResult + var data jsonSourcesResult for host, sources := range sourceMap { data.Host = host From d79e0f2769c3e27d242716bcaee70252d2c1670c Mon Sep 17 00:00:00 2001 From: Alexey Zhuchkov Date: Thu, 24 Mar 2022 23:47:54 +0300 Subject: [PATCH 07/13] Add input field to json output --- v2/pkg/runner/enumerate.go | 8 ++++---- v2/pkg/runner/outputter.go | 40 ++++++++++++++++++++++---------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/v2/pkg/runner/enumerate.go b/v2/pkg/runner/enumerate.go index 7222a40e5..45dff6a8e 100644 --- a/v2/pkg/runner/enumerate.go +++ b/v2/pkg/runner/enumerate.go @@ -119,15 +119,15 @@ func (r *Runner) EnumerateSingleDomain(ctx context.Context, domain string, outpu var err error for _, w := range outputs { if r.options.HostIP { - err = outputter.WriteHostIP(foundResults, w) + err = outputter.WriteHostIP(domain, foundResults, w) } else { if r.options.RemoveWildcard { - err = outputter.WriteHostNoWildcard(foundResults, w) + err = outputter.WriteHostNoWildcard(domain, foundResults, w) } else { if r.options.CaptureSources { - err = outputter.WriteSourceHost(sourceMap, w) + err = outputter.WriteSourceHost(domain, sourceMap, w) } else { - err = outputter.WriteHost(uniqueMap, w) + err = outputter.WriteHost(domain, uniqueMap, w) } } } diff --git a/v2/pkg/runner/outputter.go b/v2/pkg/runner/outputter.go index 24edf4512..25d981c52 100644 --- a/v2/pkg/runner/outputter.go +++ b/v2/pkg/runner/outputter.go @@ -19,17 +19,20 @@ type OutPutter struct { type jsonSourceResult struct { Host string `json:"host"` + Input string `json:"input"` Source string `json:"source"` } type jsonSourceIPResult struct { Host string `json:"host"` IP string `json:"ip"` + Input string `json:"input"` Source string `json:"source"` } type jsonSourcesResult struct { Host string `json:"host"` + Input string `json:"input"` Sources []string `json:"sources"` } @@ -69,17 +72,17 @@ func (o *OutPutter) createFile(filename string, appendtoFile bool) (*os.File, er } // WriteHostIP writes the output list of subdomain to an io.Writer -func (o *OutPutter) WriteHostIP(results map[string]resolve.Result, writer io.Writer) error { +func (o *OutPutter) WriteHostIP(input string, results map[string]resolve.Result, writer io.Writer) error { var err error if o.JSON { - err = writeJSONHostIP(results, writer) + err = writeJSONHostIP(input, results, writer) } else { - err = writePlainHostIP(results, writer) + err = writePlainHostIP(input, results, writer) } return err } -func writePlainHostIP(results map[string]resolve.Result, writer io.Writer) error { +func writePlainHostIP(_ string, results map[string]resolve.Result, writer io.Writer) error { bufwriter := bufio.NewWriter(writer) sb := &strings.Builder{} @@ -101,7 +104,7 @@ func writePlainHostIP(results map[string]resolve.Result, writer io.Writer) error return bufwriter.Flush() } -func writeJSONHostIP(results map[string]resolve.Result, writer io.Writer) error { +func writeJSONHostIP(input string, results map[string]resolve.Result, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) var data jsonSourceIPResult @@ -109,6 +112,7 @@ func writeJSONHostIP(results map[string]resolve.Result, writer io.Writer) error for _, result := range results { data.Host = result.Host data.IP = result.IP + data.Input = input data.Source = result.Source err := encoder.Encode(&data) @@ -120,27 +124,27 @@ func writeJSONHostIP(results map[string]resolve.Result, writer io.Writer) error } // WriteHostNoWildcard writes the output list of subdomain with nW flag to an io.Writer -func (o *OutPutter) WriteHostNoWildcard(results map[string]resolve.Result, writer io.Writer) error { +func (o *OutPutter) WriteHostNoWildcard(input string, results map[string]resolve.Result, writer io.Writer) error { hosts := make(map[string]resolve.HostEntry) for host, result := range results { hosts[host] = resolve.HostEntry{Host: result.Host, Source: result.Source} } - return o.WriteHost(hosts, writer) + return o.WriteHost(input, hosts, writer) } // WriteHost writes the output list of subdomain to an io.Writer -func (o *OutPutter) WriteHost(results map[string]resolve.HostEntry, writer io.Writer) error { +func (o *OutPutter) WriteHost(input string, results map[string]resolve.HostEntry, writer io.Writer) error { var err error if o.JSON { - err = writeJSONHost(results, writer) + err = writeJSONHost(input, results, writer) } else { - err = writePlainHost(results, writer) + err = writePlainHost(input, results, writer) } return err } -func writePlainHost(results map[string]resolve.HostEntry, writer io.Writer) error { +func writePlainHost(_ string, results map[string]resolve.HostEntry, writer io.Writer) error { bufwriter := bufio.NewWriter(writer) sb := &strings.Builder{} @@ -158,12 +162,13 @@ func writePlainHost(results map[string]resolve.HostEntry, writer io.Writer) erro return bufwriter.Flush() } -func writeJSONHost(results map[string]resolve.HostEntry, writer io.Writer) error { +func writeJSONHost(input string, results map[string]resolve.HostEntry, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) var data jsonSourceResult for _, result := range results { data.Host = result.Host + data.Input = input data.Source = result.Source err := encoder.Encode(data) if err != nil { @@ -174,23 +179,24 @@ func writeJSONHost(results map[string]resolve.HostEntry, writer io.Writer) error } // WriteSourceHost writes the output list of subdomain to an io.Writer -func (o *OutPutter) WriteSourceHost(sourceMap map[string]map[string]struct{}, writer io.Writer) error { +func (o *OutPutter) WriteSourceHost(input string, sourceMap map[string]map[string]struct{}, writer io.Writer) error { var err error if o.JSON { - err = writeSourceJSONHost(sourceMap, writer) + err = writeSourceJSONHost(input, sourceMap, writer) } else { - err = writeSourcePlainHost(sourceMap, writer) + err = writeSourcePlainHost(input, sourceMap, writer) } return err } -func writeSourceJSONHost(sourceMap map[string]map[string]struct{}, writer io.Writer) error { +func writeSourceJSONHost(input string, sourceMap map[string]map[string]struct{}, writer io.Writer) error { encoder := jsoniter.NewEncoder(writer) var data jsonSourcesResult for host, sources := range sourceMap { data.Host = host + data.Input = input keys := make([]string, 0, len(sources)) for source := range sources { keys = append(keys, source) @@ -205,7 +211,7 @@ func writeSourceJSONHost(sourceMap map[string]map[string]struct{}, writer io.Wri return nil } -func writeSourcePlainHost(sourceMap map[string]map[string]struct{}, writer io.Writer) error { +func writeSourcePlainHost(_ string, sourceMap map[string]map[string]struct{}, writer io.Writer) error { bufwriter := bufio.NewWriter(writer) sb := &strings.Builder{} From 7dd4b186994ccb70ac778a32df2d2a5cac133d73 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 28 Mar 2022 14:05:07 +0000 Subject: [PATCH 08/13] chore(deps): bump alpine from 3.15.1 to 3.15.2 Bumps alpine from 3.15.1 to 3.15.2. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 710fea813..1d9878c45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.18.0-alpine AS build-env RUN go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest # Release -FROM alpine:3.15.1 +FROM alpine:3.15.2 RUN apk -U upgrade --no-cache \ && apk add --no-cache bind-tools ca-certificates COPY --from=build-env /go/bin/subfinder /usr/local/bin/subfinder From 5b6342c0c95bea1c8b17f9aa7e2a69e4283f9b17 Mon Sep 17 00:00:00 2001 From: Ignacio Feijoo Date: Wed, 30 Mar 2022 04:26:35 -0300 Subject: [PATCH 09/13] fix -silent switch still show banner (#524) * fix readme golang demo for v2.5.0 * fix -silent switch still show banner * small refactor Co-authored-by: Sandeep Singh Co-authored-by: zhangchengguo Co-authored-by: Ignacio Feijoo Co-authored-by: mzack --- README.md | 19 ++++++------------- v2/pkg/runner/options.go | 7 +++++-- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index d6c91e316..2507cc482 100644 --- a/README.md +++ b/README.md @@ -242,23 +242,16 @@ import ( ) func main() { - config := runner.ConfigFile{ - // Use the default list of resolvers by marshaling it to the config - Resolvers: resolve.DefaultResolvers, - // Use the default list of passive sources - Sources: passive.DefaultSources, - // Use the default list of all passive sources - AllSources: passive.DefaultAllSources, - // Use the default list of recursive sources - Recursive: passive.DefaultRecursiveSources, - } - runnerInstance, err := runner.NewRunner(&runner.Options{ Threads: 10, // Thread controls the number of threads to use for active enumerations Timeout: 30, // Timeout is the seconds to wait for sources to respond MaxEnumerationTime: 10, // MaxEnumerationTime is the maximum amount of time in mins to wait for enumeration - YAMLConfig: config, - }) + Resolvers: resolve.DefaultResolvers, // Use the default list of resolvers by marshaling it to the config + Sources: passive.DefaultSources, // Use the default list of passive sources + AllSources: passive.DefaultAllSources, // Use the default list of all passive sources + Recursive: passive.DefaultRecursiveSources, // Use the default list of recursive sources + Providers: &runner.Providers{}, // Use empty api keys for all providers + }) buf := bytes.Buffer{} err = runnerInstance.EnumerateSingleDomain(context.Background(), "projectdiscovery.io", []io.Writer{&buf}) diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index 8d22d1774..2ed3cac17 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -66,8 +66,6 @@ type Options struct { // ParseOptions parses the command line flags provided by a user func ParseOptions() *Options { - showBanner() - // Migrate config to provider config if fileutil.FileExists(defaultConfigLocation) && !fileutil.FileExists(defaultProviderConfigLocation) { gologger.Info().Msgf("Detected old %s config file, trying to migrate providers to %s\n", defaultConfigLocation, defaultProviderConfigLocation) @@ -81,6 +79,7 @@ func ParseOptions() *Options { } options := &Options{} + var err error flagSet := goflags.NewFlagSet() flagSet.SetDescription(`Subfinder is a subdomain discovery tool that discovers subdomains for websites by using passive online sources.`) @@ -174,6 +173,10 @@ func ParseOptions() *Options { options.preProcessOptions() + if !options.Silent { + showBanner() + } + // Validate the options passed by the user and if any // invalid options have been used, exit. err = options.validateOptions() From 64dc23010419c3dc87ebe3ae3c4028f5e21574c8 Mon Sep 17 00:00:00 2001 From: Mzack9999 Date: Thu, 31 Mar 2022 17:17:40 +0200 Subject: [PATCH 10/13] Making config file recoverable errors non fatal (#526) * Making config file recoverable errors non fatal * making migration non-fatal --- v2/go.mod | 2 +- v2/go.sum | 2 ++ v2/pkg/runner/options.go | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/v2/go.mod b/v2/go.mod index 63d4d09fd..87cb618dc 100644 --- a/v2/go.mod +++ b/v2/go.mod @@ -33,7 +33,7 @@ require ( github.com/modern-go/reflect2 v1.0.1 // indirect github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/projectdiscovery/goflags v0.0.8-0.20220208063718-9bbeacc2fb8f + github.com/projectdiscovery/goflags v0.0.8-0.20220328195035-cc76049ee216 github.com/projectdiscovery/retryabledns v1.0.12-0.20210419174848-eec3ac17d61e // indirect github.com/projectdiscovery/stringsutil v0.0.0-20210804142656-fd3c28dbaafe // indirect golang.org/x/net v0.0.0-20210415231046-e915ea6b2b7d // indirect diff --git a/v2/go.sum b/v2/go.sum index a79ccc815..993b671ff 100644 --- a/v2/go.sum +++ b/v2/go.sum @@ -97,6 +97,8 @@ github.com/projectdiscovery/fileutil v0.0.0-20210928100737-cab279c5d4b5 h1:2dbm7 github.com/projectdiscovery/fileutil v0.0.0-20210928100737-cab279c5d4b5/go.mod h1:U+QCpQnX8o2N2w0VUGyAzjM3yBAe4BKedVElxiImsx0= github.com/projectdiscovery/goflags v0.0.8-0.20220208063718-9bbeacc2fb8f h1:FKTkdM1pPIL0gQRRQDoWjd/mZz+4DZ2Bk1l+ZbOJmIQ= github.com/projectdiscovery/goflags v0.0.8-0.20220208063718-9bbeacc2fb8f/go.mod h1:Jjwsf4eEBPXDSQI2Y+6fd3dBumJv/J1U0nmpM+hy2YY= +github.com/projectdiscovery/goflags v0.0.8-0.20220328195035-cc76049ee216 h1:Th8GrVWt6LJQAwneHikni4BpoLEPa69DPEnYCxAINmo= +github.com/projectdiscovery/goflags v0.0.8-0.20220328195035-cc76049ee216/go.mod h1:37KhVbVLllyuIAgpXGqcvE/hsFEwJ+ctEUSHawjhsBY= github.com/projectdiscovery/gologger v1.0.0/go.mod h1:Ok+axMqK53bWNwDSU1nTNwITLYMXMdZtRc8/y1c7sWE= github.com/projectdiscovery/gologger v1.1.4 h1:qWxGUq7ukHWT849uGPkagPKF3yBPYAsTtMKunQ8O2VI= github.com/projectdiscovery/gologger v1.1.4/go.mod h1:Bhb6Bdx2PV1nMaFLoXNBmHIU85iROS9y1tBuv7T5pMY= diff --git a/v2/pkg/runner/options.go b/v2/pkg/runner/options.go index 2ed3cac17..dd44fffd1 100644 --- a/v2/pkg/runner/options.go +++ b/v2/pkg/runner/options.go @@ -70,7 +70,7 @@ func ParseOptions() *Options { if fileutil.FileExists(defaultConfigLocation) && !fileutil.FileExists(defaultProviderConfigLocation) { gologger.Info().Msgf("Detected old %s config file, trying to migrate providers to %s\n", defaultConfigLocation, defaultProviderConfigLocation) if err := migrateToProviderConfig(defaultConfigLocation, defaultProviderConfigLocation); err != nil { - gologger.Fatal().Msgf("Could not migrate providers from existing config (%s) to provider config (%s): %s\n", defaultConfigLocation, defaultProviderConfigLocation, err) + gologger.Warning().Msgf("Could not migrate providers from existing config (%s) to provider config (%s): %s\n", defaultConfigLocation, defaultProviderConfigLocation, err) } else { //cleanup the existing config file post migration os.Remove(defaultConfigLocation) @@ -138,7 +138,8 @@ func ParseOptions() *Options { } if options.Config != defaultConfigLocation { - if err := flagSet.MergeConfigFile(options.Config); err != nil { + // An empty source file is not a fatal error + if err := flagSet.MergeConfigFile(options.Config); err != nil && !errors.Is(err, io.EOF) { gologger.Fatal().Msgf("Could not read config: %s\n", err) } } From 9a438c5eb4c4dca400646ca1849c896c1fbd5014 Mon Sep 17 00:00:00 2001 From: Sam James Date: Mon, 4 Apr 2022 17:33:08 +0100 Subject: [PATCH 11/13] Don't make missing providers-config fatal on first-run (#527) * fix readme golang demo for v2.5.0 * Don't make missing providers-config fatal on first-run It's okay if we fall back to the default config which is in memory & will get saved out when done parsing. This is on top of the work in #526, but a slightly different issue. See: https://github.com/projectdiscovery/subfinder/pull/526 Signed-off-by: Sam James Co-authored-by: Sandeep Singh Co-authored-by: zhangchengguo --- v2/pkg/runner/banners.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index f4448594a..b439db766 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -1,6 +1,9 @@ package runner import ( + "errors" + "os" + "github.com/projectdiscovery/gologger" "github.com/projectdiscovery/subfinder/v2/pkg/passive" "github.com/projectdiscovery/subfinder/v2/pkg/resolve" @@ -44,7 +47,9 @@ func (options *Options) loadProvidersFrom(location string) { } options.Providers = &Providers{} - if err := options.Providers.UnmarshalFrom(location); isFatalErr(err) { + // We skip bailing out if file doesn't exist because we'll create it + // at the end of options parsing from default via goflags. + if err := options.Providers.UnmarshalFrom(location); isFatalErr(err) && !errors.Is(err, os.ErrNotExist) { gologger.Fatal().Msgf("Could not read providers from %s: %s\n", location, err) } } From 95efd79d421378051f3f66ed9d90922640b7856e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 22:04:27 +0530 Subject: [PATCH 12/13] chore(deps): bump alpine from 3.15.2 to 3.15.3 (#531) Bumps alpine from 3.15.2 to 3.15.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1d9878c45..fe7c33729 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.18.0-alpine AS build-env RUN go install -v github.com/projectdiscovery/subfinder/v2/cmd/subfinder@latest # Release -FROM alpine:3.15.2 +FROM alpine:3.15.3 RUN apk -U upgrade --no-cache \ && apk add --no-cache bind-tools ca-certificates COPY --from=build-env /go/bin/subfinder /usr/local/bin/subfinder From 757c028da8b5080fa379211229d1908a3a401033 Mon Sep 17 00:00:00 2001 From: sandeep Date: Mon, 4 Apr 2022 22:06:36 +0530 Subject: [PATCH 13/13] banner update --- v2/pkg/runner/banners.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/v2/pkg/runner/banners.go b/v2/pkg/runner/banners.go index b439db766..b6196eea9 100644 --- a/v2/pkg/runner/banners.go +++ b/v2/pkg/runner/banners.go @@ -14,11 +14,11 @@ const banner = ` _______ __/ /_ / __(_)___ ____/ /__ _____ / ___/ / / / __ \/ /_/ / __ \/ __ / _ \/ ___/ (__ ) /_/ / /_/ / __/ / / / / /_/ / __/ / -/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.1-dev +/____/\__,_/_.___/_/ /_/_/ /_/\__,_/\___/_/ v2.5.1 ` // Version is the current version of subfinder -const Version = `v2.5.1-dev` +const Version = `v2.5.1` // showBanner is used to show the banner to the user func showBanner() {