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

Add resolver in katana #340

Merged
merged 4 commits into from
Mar 10, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ jobs:
name: Lint Test
runs-on: ubuntu-latest-16-cores
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.19
cache: true

- name: Checkout code
uses: actions/checkout@v3

- name: Run golangci-lint
uses: golangci/[email protected]
with:
version: latest
args: --timeout 5m
working-directory: .
working-directory: .
1 change: 1 addition & 0 deletions cmd/katana/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ pipelines offering both headless and non-headless crawling.`)
)

flagSet.CreateGroup("config", "Configuration",
flagSet.StringSliceVarP(&options.Resolvers, "resolvers", "r", nil, "list of custom resolver (file or comma separated)", goflags.FileCommaSeparatedStringSliceOptions),
flagSet.IntVarP(&options.MaxDepth, "depth", "d", 2, "maximum depth to crawl"),
flagSet.BoolVarP(&options.ScrapeJSResponses, "js-crawl", "jc", false, "enable endpoint parsing / crawling in javascript file"),
flagSet.IntVarP(&options.CrawlDuration, "crawl-duration", "ct", 0, "maximum duration to crawl the target for"),
Expand Down
6 changes: 5 additions & 1 deletion pkg/types/crawler_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ type CrawlerOptions struct {
func NewCrawlerOptions(options *Options) (*CrawlerOptions, error) {
extensionsValidator := extensions.NewValidator(options.ExtensionsMatch, options.ExtensionFilter)

fastdialerInstance, err := fastdialer.NewDialer(fastdialer.DefaultOptions)
dialerOpts := fastdialer.DefaultOptions
if len(options.Resolvers) > 0 {
dialerOpts.BaseResolvers = options.Resolvers
}
fastdialerInstance, err := fastdialer.NewDialer(dialerOpts)
if err != nil {
return nil, err
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ type Options struct {
HealthCheck bool
// ErrorLogFile specifies a file to write with the errors of all requests
ErrorLogFile string
// Resolvers contains custom resolvers
Resolvers goflags.StringSlice
// OutputMatchRegex is the regex to match output url
OutputMatchRegex goflags.StringSlice
// OutputFilterRegex is the regex to filter output url
Expand Down