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

Match/filter #582

Merged
merged 13 commits into from
Aug 11, 2022
Merged

Match/filter #582

merged 13 commits into from
Aug 11, 2022

Conversation

LuitelSamikshya
Copy link
Contributor

@LuitelSamikshya LuitelSamikshya commented Jul 25, 2022

closes #575

@LuitelSamikshya LuitelSamikshya self-assigned this Jul 25, 2022
@LuitelSamikshya LuitelSamikshya linked an issue Jul 25, 2022 that may be closed by this pull request
@LuitelSamikshya LuitelSamikshya added Type: Enhancement Most issues will probably ask for additions or changes. Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Jul 25, 2022
v2/pkg/runner/enumerate.go Outdated Show resolved Hide resolved
v2/pkg/runner/validate.go Outdated Show resolved Hide resolved
@Mzack9999 Mzack9999 requested a review from ehsandeep July 27, 2022 04:12
@Mzack9999
Copy link
Member

$ go run . -d example.com -match "megalom.*" -silent
megalom.example.com
$ go run . -d example.com -filter "megalom.*" -silent | wc -l
   22800

@forgedhallpass forgedhallpass self-requested a review July 29, 2022 12:40
Copy link
Contributor

@forgedhallpass forgedhallpass left a comment

Choose a reason for hiding this comment

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

This functionality requires extensive tests with positive and negative scenarios!

@Mzack9999 Mzack9999 self-requested a review August 3, 2022 07:56
v2/pkg/runner/enumerate_test.go Outdated Show resolved Hide resolved
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.

The following test will fail:

t.Run("Filter and Match", func(t *testing.T) {
	options.Filter = []string{"example.com"}
	options.Match = []string{"www.example.com"}
	err := options.validateOptions()
	if err != nil {
		t.Fatalf("Expected nil got %v while validation\n", err)
	}
	runner, err := NewRunner(options)
	if err != nil {
		t.Fatalf("Expected nil got %v while creating runner\n", err)
	}
	subdomain := []string{"example.com", "www.example.com"}
	for _, sub := range subdomain {
		match := runner.filterAndMatchSubdomain(sub)
		require.True(t, match, "Expecting a boolean True value ")
	}
})

While compiling the regexes, I think we need to use anchors (^ and $) for those not containing wildcards (e.g. example.com => ^example\.com$). Otherwise, all strings containing the regular expression value will match.

@ehsandeep ehsandeep merged commit 1e0d18d into dev Aug 11, 2022
@ehsandeep ehsandeep deleted the match/filter branch August 11, 2022 15:51
@ehsandeep ehsandeep added Status: Completed Nothing further to be done with this issue. Awaiting to be closed. and removed Status: Review Needed The issue has a PR attached to it which needs to be reviewed labels Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Completed Nothing further to be done with this issue. Awaiting to be closed. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Filter the output based on a given scope
4 participants