Skip to content

Commit 954cbe6

Browse files
authored
Merge pull request #973 from projectdiscovery/dev
httpx v1.0.7
2 parents 525aeb0 + 1752c2d commit 954cbe6

File tree

11 files changed

+174
-203
lines changed

11 files changed

+174
-203
lines changed

.github/workflows/dockerhub-push.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
password: ${{ secrets.DOCKER_TOKEN }}
3333

3434
- name: Build and push
35-
uses: docker/build-push-action@v3
35+
uses: docker/build-push-action@v4
3636
with:
3737
context: .
3838
platforms: linux/amd64,linux/arm64,linux/arm

.github/workflows/lint-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Checkout code
1717
uses: actions/checkout@v3
1818
- name: Run golangci-lint
19-
uses: golangci/golangci-lint-action@v3.3.1
19+
uses: golangci/golangci-lint-action@v3.4.0
2020
with:
2121
version: latest
2222
args: --timeout 5m

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
FROM golang:1.19.4-alpine AS builder
1+
FROM golang:1.20.0-alpine AS builder
22
ARG BUILD_SOURCE_TAG=latest
33
RUN apk add --no-cache git build-base gcc musl-dev
44
RUN go install -v github.com/projectdiscovery/httpx/cmd/httpx@${BUILD_SOURCE_TAG}
55

6-
FROM alpine:3.17.0
6+
FROM alpine:3.17.1
77
RUN apk -U upgrade --no-cache \
88
&& apk add --no-cache bind-tools ca-certificates
99
COPY --from=builder /go/bin/httpx /usr/local/bin/

cmd/httpx/httpx.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/projectdiscovery/gologger"
1010
"github.com/projectdiscovery/httpx/runner"
11+
errorutil "github.com/projectdiscovery/utils/errors"
1112
)
1213

1314
func main() {
@@ -58,3 +59,9 @@ func main() {
5859
httpxRunner.RunEnumeration()
5960
httpxRunner.Close()
6061
}
62+
63+
func init() {
64+
if os.Getenv("DEBUG") != "" {
65+
errorutil.ShowStackTrace = true
66+
}
67+
}

cmd/integration-test/library.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ func (h *httpxLibrary) Execute() error {
4444

4545
httpxRunner.RunEnumeration()
4646

47-
expected := "https://scanme.sh:443"
47+
// httpx removes default ports for simplicity Ref: https://pkg.go.dev/github.com/projectdiscovery/httpx/common/stringz#RemoveURLDefaultPort
48+
expected := "https://scanme.sh"
4849

4950
if got != expected {
5051
return errIncorrectResult(expected, got)

common/httpx/httpx.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
retryablehttp "github.com/projectdiscovery/retryablehttp-go"
2020
pdhttputil "github.com/projectdiscovery/utils/http"
2121
stringsutil "github.com/projectdiscovery/utils/strings"
22+
urlutil "github.com/projectdiscovery/utils/url"
2223
"golang.org/x/net/context"
2324
"golang.org/x/net/http2"
2425
)
@@ -330,11 +331,15 @@ func (h *HTTPX) NewRequest(method, targetURL string) (req *retryablehttp.Request
330331

331332
// NewRequest from url
332333
func (h *HTTPX) NewRequestWithContext(ctx context.Context, method, targetURL string) (req *retryablehttp.Request, err error) {
333-
req, err = retryablehttp.NewRequestWithContext(ctx, method, targetURL, nil)
334+
urlx, err := urlutil.ParseURL(targetURL, h.Options.Unsafe)
334335
if err != nil {
335-
return
336+
return nil, err
336337
}
337338

339+
req, err = retryablehttp.NewRequestFromURLWithContext(ctx, method, urlx, nil)
340+
if err != nil {
341+
return nil, err
342+
}
338343
// Skip if unsafe is used
339344
if !h.Options.Unsafe {
340345
// set default user agent

common/stringz/stringz.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,18 @@ func RemoveURLDefaultPort(rawURL string) string {
9393
return rawURL
9494
}
9595

96-
if u.Scheme == urlutil.HTTP && u.Port == "80" || u.Scheme == urlutil.HTTPS && u.Port == "443" {
97-
u.Port = ""
96+
if u.Scheme == urlutil.HTTP && u.Port() == "80" || u.Scheme == urlutil.HTTPS && u.Port() == "443" {
97+
u.TrimPort()
9898
}
9999
return u.String()
100100
}
101101

102102
func GetInvalidURI(rawURL string) (bool, string) {
103103
if _, err := url.Parse(rawURL); err != nil {
104104
if u, err := urlutil.Parse(rawURL); err == nil {
105-
return true, u.RequestURI
105+
return true, u.GetRelativePath()
106106
}
107107
}
108-
109108
return false, ""
110109
}
111110

go.mod

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,31 +10,29 @@ require (
1010
github.com/hbakhtiyor/strsim v0.0.0-20190107154042-4d2bbb273edf
1111
github.com/julienschmidt/httprouter v1.3.0
1212
github.com/logrusorgru/aurora v2.0.3+incompatible
13-
github.com/microcosm-cc/bluemonday v1.0.21
13+
github.com/microcosm-cc/bluemonday v1.0.22
1414
github.com/miekg/dns v1.1.50 // indirect
1515
github.com/pkg/errors v0.9.1
1616
github.com/projectdiscovery/cdncheck v0.0.4-0.20220413175814-b47bc2d578b1
17-
github.com/projectdiscovery/clistats v0.0.9
17+
github.com/projectdiscovery/clistats v0.0.12
1818
github.com/projectdiscovery/fdmax v0.0.4
19-
github.com/projectdiscovery/fileutil v0.0.3 // indirect
2019
github.com/projectdiscovery/goconfig v0.0.0-20210804090219-f893ccd0c69c
2120
github.com/projectdiscovery/goflags v0.1.6
2221
github.com/projectdiscovery/gologger v1.1.7
23-
github.com/projectdiscovery/hmap v0.0.6
22+
github.com/projectdiscovery/hmap v0.0.7
2423
github.com/projectdiscovery/iputil v0.0.2 // indirect
2524
github.com/projectdiscovery/mapcidr v1.0.3
26-
github.com/projectdiscovery/rawhttp v0.0.8-0.20210814181734-56cca67b6e7e
27-
github.com/projectdiscovery/retryablehttp-go v1.0.3-0.20220506110515-811d938bd26d
28-
github.com/projectdiscovery/sliceutil v0.0.1 // indirect
25+
github.com/projectdiscovery/rawhttp v0.1.9-0.20230208140210-81c468e769ed
26+
github.com/projectdiscovery/retryablehttp-go v1.0.11-0.20230208144003-54f3176b2916
2927
github.com/projectdiscovery/stringsutil v0.0.2 // indirect
30-
github.com/projectdiscovery/wappalyzergo v0.0.76
28+
github.com/projectdiscovery/wappalyzergo v0.0.81
3129
github.com/remeh/sizedwaitgroup v1.0.0
3230
github.com/rs/xid v1.4.0
33-
go.etcd.io/bbolt v1.3.6 // indirect
31+
go.etcd.io/bbolt v1.3.7 // indirect
3432
go.uber.org/atomic v1.10.0 // indirect
35-
golang.org/x/net v0.5.0
36-
golang.org/x/sys v0.4.0 // indirect
37-
golang.org/x/text v0.6.0
33+
golang.org/x/net v0.6.0
34+
golang.org/x/sys v0.5.0 // indirect
35+
golang.org/x/text v0.7.0
3836
)
3937

4038
require github.com/spaolacci/murmur3 v1.1.0
@@ -47,13 +45,13 @@ require (
4745
github.com/mitchellh/mapstructure v1.5.0
4846
github.com/projectdiscovery/asnmap v0.0.1
4947
github.com/projectdiscovery/dsl v0.0.3
50-
github.com/projectdiscovery/fastdialer v0.0.19
51-
github.com/projectdiscovery/ratelimit v0.0.4
52-
github.com/projectdiscovery/tlsx v1.0.3
53-
github.com/projectdiscovery/utils v0.0.4-0.20230102120019-c7a04e2045be
48+
github.com/projectdiscovery/fastdialer v0.0.22
49+
github.com/projectdiscovery/ratelimit v0.0.6
50+
github.com/projectdiscovery/tlsx v1.0.4
51+
github.com/projectdiscovery/utils v0.0.8-0.20230208160155-47c6b52af9f0
5452
github.com/stretchr/testify v1.8.1
5553
go.uber.org/multierr v1.9.0
56-
golang.org/x/exp v0.0.0-20221230185412-738e83a70c30
54+
golang.org/x/exp v0.0.0-20230206171751-46f607a40771
5755
)
5856

5957
require (
@@ -66,58 +64,60 @@ require (
6664
github.com/beorn7/perks v1.0.1 // indirect
6765
github.com/cespare/xxhash/v2 v2.2.0 // indirect
6866
github.com/cnf/structhash v0.0.0-20201127153200-e1b16c1ebc08 // indirect
69-
github.com/cockroachdb/errors v1.9.0 // indirect
70-
github.com/cockroachdb/logtags v0.0.0-20211118104740-dabe8e521a4f // indirect
71-
github.com/cockroachdb/pebble v0.0.0-20221229212011-811a8c0e741b // indirect
67+
github.com/cockroachdb/errors v1.9.1 // indirect
68+
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
69+
github.com/cockroachdb/pebble v0.0.0-20230207164304-7d1e4ba7ffd0 // indirect
7270
github.com/cockroachdb/redact v1.1.3 // indirect
7371
github.com/davecgh/go-spew v1.1.1 // indirect
7472
github.com/dimchansky/utfbom v1.1.1 // indirect
7573
github.com/dsnet/compress v0.0.1 // indirect
76-
github.com/getsentry/sentry-go v0.16.0 // indirect
74+
github.com/getsentry/sentry-go v0.18.0 // indirect
7775
github.com/gogo/protobuf v1.3.2 // indirect
7876
github.com/golang/protobuf v1.5.2 // indirect
7977
github.com/gorilla/css v1.0.0 // indirect
8078
github.com/json-iterator/go v1.1.12 // indirect
81-
github.com/klauspost/compress v1.15.13 // indirect
79+
github.com/klauspost/compress v1.15.15 // indirect
8280
github.com/kr/pretty v0.3.1 // indirect
8381
github.com/kr/text v0.2.0 // indirect
8482
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
8583
github.com/mholt/archiver v3.1.1+incompatible // indirect
8684
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8785
github.com/modern-go/reflect2 v1.0.2 // indirect
8886
github.com/nwaples/rardecode v1.1.0 // indirect
87+
github.com/nxadm/tail v1.4.8 // indirect
8988
github.com/pierrec/lz4 v2.6.0+incompatible // indirect
9089
github.com/pmezard/go-difflib v1.0.0 // indirect
9190
github.com/projectdiscovery/blackrock v0.0.0-20220628111055-35616c71b2dc // indirect
91+
github.com/projectdiscovery/freeport v0.0.4 // indirect
9292
github.com/projectdiscovery/networkpolicy v0.0.3 // indirect
9393
github.com/projectdiscovery/reflectutil v0.0.0-20210804085554-4d90952bf92f // indirect
94-
github.com/projectdiscovery/retryabledns v1.0.17 // indirect
94+
github.com/projectdiscovery/retryabledns v1.0.20 // indirect
9595
github.com/prometheus/client_golang v1.14.0 // indirect
9696
github.com/prometheus/client_model v0.3.0 // indirect
9797
github.com/prometheus/common v0.39.0 // indirect
9898
github.com/prometheus/procfs v0.9.0 // indirect
9999
github.com/rogpeppe/go-internal v1.9.0 // indirect
100-
github.com/saintfish/chardet v0.0.0-20120816061221-3af4cd4741ca // indirect
100+
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect
101101
github.com/syndtr/goleveldb v1.0.0 // indirect
102-
github.com/tidwall/btree v1.4.3 // indirect
102+
github.com/tidwall/btree v1.6.0 // indirect
103103
github.com/tidwall/buntdb v1.2.10 // indirect
104-
github.com/tidwall/gjson v1.14.3 // indirect
104+
github.com/tidwall/gjson v1.14.4 // indirect
105105
github.com/tidwall/grect v0.1.4 // indirect
106106
github.com/tidwall/match v1.1.1 // indirect
107-
github.com/tidwall/pretty v1.2.0 // indirect
107+
github.com/tidwall/pretty v1.2.1 // indirect
108108
github.com/tidwall/rtred v0.1.2 // indirect
109109
github.com/tidwall/tinyqueue v0.1.1 // indirect
110110
github.com/ulikunitz/xz v0.5.11 // indirect
111111
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6 // indirect
112-
github.com/weppos/publicsuffix-go v0.15.1-0.20220724114530-e087fba66a37 // indirect
112+
github.com/weppos/publicsuffix-go v0.20.0 // indirect
113113
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
114114
github.com/yl2chen/cidranger v1.0.2 // indirect
115-
github.com/zmap/rc2 v0.0.0-20131011165748-24b9757f5521 // indirect
115+
github.com/zmap/rc2 v0.0.0-20190804163417-abaa70531248 // indirect
116116
github.com/zmap/zcertificate v0.0.0-20180516150559-0e3d58b1bac4 // indirect
117-
github.com/zmap/zcrypto v0.0.0-20220803033029-557f3e4940be // indirect
118-
golang.org/x/crypto v0.1.0 // indirect
119-
golang.org/x/mod v0.6.0 // indirect
120-
golang.org/x/tools v0.2.0 // indirect
117+
github.com/zmap/zcrypto v0.0.0-20230205235340-d51ce4775101 // indirect
118+
golang.org/x/crypto v0.5.0 // indirect
119+
golang.org/x/mod v0.8.0 // indirect
120+
golang.org/x/tools v0.5.0 // indirect
121121
google.golang.org/protobuf v1.28.1 // indirect
122122
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
123123
gopkg.in/ini.v1 v1.67.0 // indirect

0 commit comments

Comments
 (0)