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

fix filter and match functionality in lib #775

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Conversation

dogancanbakir
Copy link
Member

Closes #716

package main

import (
	"math"

	"github.com/projectdiscovery/gologger"
	"github.com/projectdiscovery/gologger/levels"
	"github.com/projectdiscovery/katana/pkg/engine/standard"
	"github.com/projectdiscovery/katana/pkg/output"
	"github.com/projectdiscovery/katana/pkg/types"
)

func main() {
	gologger.DefaultLogger.SetMaxLevel(levels.LevelSilent)

	options := &types.Options{
		MaxDepth:         3,           // Maximum depth to crawl
		FieldScope:       "rdn",       // Crawling Scope Field
		BodyReadSize:     math.MaxInt, // Maximum response size to read
		Timeout:          10,          // Timeout is the time to wait for request in seconds
		Concurrency:      10,          // Concurrency is the number of concurrent crawling goroutines
		OutputMatchRegex: []string{"policies"},
		Parallelism:      10,            // Parallelism is the number of urls processing goroutines
		Delay:            0,             // Delay is the delay between each crawl requests in seconds
		RateLimit:        150,           // Maximum requests to send per second
		Strategy:         "depth-first", // Visit strategy (depth-first, breadth-first)
		OnResult: func(result output.Result) { // Callback function to execute for result
			gologger.Info().Msg(result.Request.URL)
		},
	}
	crawlerOptions, err := types.NewCrawlerOptions(options)
	if err != nil {
		gologger.Fatal().Msg(err.Error())
	}
	defer crawlerOptions.Close()
	crawler, err := standard.New(crawlerOptions)
	if err != nil {
		gologger.Fatal().Msg(err.Error())
	}
	defer crawler.Close()
	var input = "https://www.hackerone.com"
	err = crawler.Crawl(input)
	if err != nil {
		gologger.Warning().Msgf("Could not crawl %s: %s", input, err.Error())
	}
}
$ go run .
https://www.hackerone.com/policies
https://www.hackerone.com/policies/employee-participation
https://www.hackerone.com/policies/community-code-of-conduct
https://www.hackerone.com/policies/faq
https://www.hackerone.com/policies/live-hacking-roe
https://www.hackerone.com/policies/clear-rules-of-engagement
https://www.hackerone.com/policies/pentest-rules-of-engagement
https://www.hackerone.com/policies/code-of-conduct

Copy link
Member

@Mzack9999 Mzack9999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

$ go run katana.sdk.go
...
https://www.hackerone.com/policies
https://www.hackerone.com/policies/employee-participation
...

@Mzack9999 Mzack9999 added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Feb 26, 2024
@ehsandeep ehsandeep merged commit 72eb8a4 into dev Feb 26, 2024
13 checks passed
@ehsandeep ehsandeep deleted the fix_filter_in_lib branch February 26, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Katana Library: OutputMatchRegex & OutputFilterRegex not functioning as expected
3 participants