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

File writing ops respect filters/matchers #1720

Merged
merged 1 commit into from
May 29, 2024
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
4 changes: 2 additions & 2 deletions common/httpx/csp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

"github.com/PuerkitoBio/goquery"
"github.com/projectdiscovery/httpx/common/slice"
mapsutil "github.com/projectdiscovery/utils/maps"
stringsutil "github.com/projectdiscovery/utils/strings"
)

Expand Down Expand Up @@ -49,7 +49,7 @@ func (h *HTTPX) CSPGrab(r *Response) *CSPData {
}

if len(domains) > 0 {
return &CSPData{Domains: slice.ToSlice(domains)}
return &CSPData{Domains: mapsutil.GetKeys(domains)}
}
return nil
}
Expand Down
11 changes: 3 additions & 8 deletions common/httpx/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ package httpx

import (
"regexp"
"strings"

stringsutil "github.com/projectdiscovery/utils/strings"
)

// Filter defines a generic filter interface to apply to responses
Expand All @@ -17,13 +18,7 @@ type FilterString struct {

// Filter a response with strings filtering
func (f FilterString) Filter(response *Response) (bool, error) {
for _, keyword := range f.Keywords {
if strings.Contains(response.Raw, keyword) {
return true, nil
}
}

return false, nil
return stringsutil.ContainsAnyI(response.Raw, f.Keywords...), nil
}

// FilterRegex defines a filter of type regex
Expand Down
4 changes: 3 additions & 1 deletion common/httpx/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net"
"strings"
"time"

stringsutil "github.com/projectdiscovery/utils/strings"
)

// SupportPipeline checks if the target host supports HTTP1.1 pipelining by sending x probes
Expand Down Expand Up @@ -48,7 +50,7 @@ func (h *HTTPX) SupportPipeline(protocol, method, host string, port int) bool {

// The check is very naive, but it works most of the times
for _, s := range strings.Split(string(reply), "\n\n") {
if strings.Contains(s, "HTTP/1.1") || strings.Contains(s, "HTTP/1.0") {
if stringsutil.ContainsAnyI(s, "HTTP/1.1", "HTTP/1.0") {
gotReplies++
}
}
Expand Down
2 changes: 0 additions & 2 deletions common/slice/doc.go

This file was deleted.

40 changes: 0 additions & 40 deletions common/slice/slice.go

This file was deleted.

4 changes: 2 additions & 2 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (
customport "github.com/projectdiscovery/httpx/common/customports"
fileutilz "github.com/projectdiscovery/httpx/common/fileutil"
"github.com/projectdiscovery/httpx/common/httpx"
"github.com/projectdiscovery/httpx/common/slice"
"github.com/projectdiscovery/httpx/common/stringz"
"github.com/projectdiscovery/utils/auth/pdcp"
"github.com/projectdiscovery/utils/env"
fileutil "github.com/projectdiscovery/utils/file"
sliceutil "github.com/projectdiscovery/utils/slice"
stringsutil "github.com/projectdiscovery/utils/strings"
updateutils "github.com/projectdiscovery/utils/update"
)
Expand Down Expand Up @@ -663,7 +663,7 @@ func (options *Options) ValidateOptions() error {

if options.Hashes != "" {
for _, hashType := range strings.Split(options.Hashes, ",") {
if !slice.StringSliceContains([]string{"md5", "sha1", "sha256", "sha512", "mmh3", "simhash"}, strings.ToLower(hashType)) {
if !sliceutil.Contains([]string{"md5", "sha1", "sha256", "sha512", "mmh3", "simhash"}, strings.ToLower(hashType)) {
gologger.Error().Msgf("Unsupported hash type: %s\n", hashType)
}
}
Expand Down
Loading
Loading