Skip to content

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
@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
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

5 participants