Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't make missing providers-config fatal on first-run #527

Merged
merged 4 commits into from
Apr 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
7 changes: 6 additions & 1 deletion v2/pkg/runner/banners.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
}
}