Skip to content

Commit 63130de

Browse files
committed
Merge branch 'dev' into pr/2226
2 parents 3cac134 + 7b8fd15 commit 63130de

File tree

21 files changed

+603
-225
lines changed

21 files changed

+603
-225
lines changed

.github/auto_assign.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
addReviewers: true
2+
reviewers:
3+
- dogancanbakir
4+
- dwisiswant0
5+
- mzack9999
6+
7+
numberOfReviewers: 1
8+
skipKeywords:
9+
- '@dependabot'

.github/workflows/stale.yaml

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,41 @@
1-
name: 'Close stale issues and PR'
1+
name: 💤 Stale
2+
23
on:
34
schedule:
4-
- cron: '30 1 * * *'
5+
- cron: "0 0 * * 0" # Weekly
56

67
jobs:
78
stale:
89
runs-on: ubuntu-latest
10+
permissions:
11+
actions: write
12+
contents: write # only for delete-branch option
13+
issues: write
14+
pull-requests: write
915
steps:
1016
- uses: actions/stale@v9
1117
with:
12-
only-labels: "Status: Abandoned, Type: Question"
13-
stale-issue-label: stale
14-
stale-issue-message: 'This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 90 days.'
15-
close-issue-message: 'This issue was closed because it has been stalled for 90 days with no activity.'
16-
days-before-stale: 14
17-
days-before-close: 90
18-
days-before-pr-stale: -1
19-
days-before-pr-close: -1
20-
stale-pr-message: ''
21-
close-pr-message: ''
18+
days-before-stale: 90
19+
days-before-close: 7
20+
stale-issue-label: "Status: Stale"
21+
stale-pr-label: "Status: Stale"
22+
stale-issue-message: >
23+
This issue has been automatically marked as stale because it has not
24+
had recent activity. It will be closed in 7 days if no further
25+
activity occurs. Thank you for your contributions!
26+
stale-pr-message: >
27+
This pull request has been automatically marked as stale due to
28+
inactivity. It will be closed in 7 days if no further activity
29+
occurs. Please update if you wish to keep it open.
30+
close-issue-message: >
31+
This issue has been automatically closed due to inactivity. If you
32+
think this is a mistake or would like to continue the discussion,
33+
please comment or feel free to reopen it.
34+
close-pr-message: >
35+
This pull request has been automatically closed due to inactivity.
36+
If you think this is a mistake or would like to continue working on
37+
it, please comment or feel free to reopen it.
38+
close-issue-label: "Status: Abandoned"
39+
close-pr-label: "Status: Abandoned"
40+
exempt-issue-labels: "Status: Abandoned"
41+
exempt-pr-labels: "Status: Abandoned"

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
# Installation Instructions
6464

65-
`httpx` requires **go1.21** to install successfully. Run the following command to get the repo:
65+
`httpx` requires **go >=1.24.0** to install successfully. Run the following command to get the repo:
6666

6767
```sh
6868
go install -v github.com/projectdiscovery/httpx/cmd/httpx@latest
@@ -85,10 +85,6 @@ This will display help for the tool. Here are all the switches it supports.
8585

8686

8787
```console
88-
Usage:
89-
./httpx [flags]
90-
91-
Flags:
9288
httpx is a fast and multi-purpose HTTP toolkit that allows running multiple probes using the retryablehttp library.
9389

9490
Usage:
@@ -115,8 +111,9 @@ PROBES:
115111
-bp, -body-preview display first N characters of response body (default 100)
116112
-server, -web-server display server name
117113
-td, -tech-detect display technology in use based on wappalyzer dataset
114+
-cff, -custom-fingerprint-file string path to a custom fingerprint file for technology detection
118115
-method display http request method
119-
-websocket display server using websocket
116+
-ws, -websocket display server using websocket
120117
-ip display host ip
121118
-cname display host cname
122119
-extract-fqdn, -efqdn get domain and subdomains from response body and header in jsonl/csv output
@@ -203,6 +200,8 @@ OUTPUT:
203200
-svrc, -store-vision-recon-cluster include visual recon clusters (-ss and -sr only)
204201
-pr, -protocol string protocol to use (unknown, http11)
205202
-fepp, -filter-error-page-path string path to store filtered error pages (default "filtered_error_page.json")
203+
-lof, -list-output-fields list available output field names for filtering
204+
-eof, -exclude-output-fields string[] exclude specified output fields from results
206205

207206
CONFIGURATIONS:
208207
-config string path to the httpx configuration file (default $HOME/.config/httpx/config.yaml)
@@ -211,6 +210,7 @@ CONFIGURATIONS:
211210
-deny string[] denied list of IP/CIDR's to process (file or comma separated)
212211
-sni, -sni-name string custom TLS SNI name
213212
-random-agent enable Random User-Agent to use (default true)
213+
-auto-referer set the Referer header to the current URL (default false)
214214
-H, -header string[] custom http headers to send with request
215215
-http-proxy, -proxy string http proxy to use (eg http://127.0.0.1:8080)
216216
-unsafe send raw requests skipping golang normalization

cmd/functional-test/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ func runFunctionalTests() error {
4141
if err != nil {
4242
return errors.Wrap(err, "could not open test cases")
4343
}
44-
defer file.Close()
44+
defer func() {
45+
_ = file.Close()
46+
}()
4547

4648
scanner := bufio.NewScanner(file)
4749
for scanner.Scan() {

cmd/integration-test/http.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type standardHttpGet struct {
4949
func (h *standardHttpGet) Execute() error {
5050
router := httprouter.New()
5151
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
52-
fmt.Fprintf(w, "This is a test")
52+
_, _ = fmt.Fprintf(w, "This is a test")
5353
r.Close = true
5454
}))
5555
var ts *httptest.Server
@@ -100,7 +100,7 @@ func (h *issue276) Execute() error {
100100
router.GET("/redirect", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
101101
w.Header().Add("Location", ts.URL+"/redirect")
102102
w.WriteHeader(302)
103-
fmt.Fprintf(w, "<html><body><title>Object moved</title></body></html>")
103+
_, _ = fmt.Fprintf(w, "<html><body><title>Object moved</title></body></html>")
104104
}))
105105
ts = httptest.NewServer(router)
106106
defer ts.Close()
@@ -163,7 +163,7 @@ func (h *issue303) Execute() error {
163163
// mimic a misconfigured web server behavior declaring gzip body
164164
w.Header().Add("Content-Encoding", "gzip")
165165
// but sending it uncompressed
166-
fmt.Fprint(w, "<html><body>This is a test</body></html>")
166+
_, _ = fmt.Fprint(w, "<html><body>This is a test</body></html>")
167167
}))
168168
ts = httptest.NewServer(router)
169169
defer ts.Close()
@@ -191,7 +191,7 @@ func (h *issue363) Execute() error {
191191
router.GET("/redirect", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
192192
w.Header().Add("Location", ts.URL+"/redirect")
193193
w.WriteHeader(302)
194-
fmt.Fprintf(w, "<html><body><title>Object moved</title></body></html>")
194+
_, _ = fmt.Fprintf(w, "<html><body><title>Object moved</title></body></html>")
195195
}))
196196
ts = httptest.NewServer(router)
197197
defer ts.Close()
@@ -214,7 +214,7 @@ func (h *issue400) Execute() error {
214214
router.POST("/receive", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
215215
w.Header().Add("Content-Type", "application/json")
216216
data, _ := io.ReadAll(r.Body)
217-
fmt.Fprintf(w, "data received %s", data)
217+
_, _ = fmt.Fprintf(w, "data received %s", data)
218218
}))
219219
ts = httptest.NewServer(router)
220220
defer ts.Close()
@@ -238,7 +238,7 @@ func (h *issue414) Execute() error {
238238
router.POST(uripath, httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
239239
w.Header().Add("Content-Type", "application/json")
240240
data, _ := io.ReadAll(r.Body)
241-
fmt.Fprintf(w, "data received %s", data)
241+
_, _ = fmt.Fprintf(w, "data received %s", data)
242242
}))
243243
ts = httptest.NewServer(router)
244244
defer ts.Close()
@@ -265,7 +265,7 @@ func (h *titleUnwantedChars) Execute() error {
265265
uriPath := "/index"
266266
router.GET(uriPath, httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
267267
htmlResponse := "<html><head><title>\v\fProject\n\r Discovery\n - Httpx\t></title></head><body>test data</body></html>"
268-
fmt.Fprint(w, htmlResponse)
268+
_, _ = fmt.Fprint(w, htmlResponse)
269269
}))
270270
ts = httptest.NewServer(router)
271271
defer ts.Close()
@@ -290,7 +290,7 @@ func (h *issue480) Execute() error {
290290
uriPath := "////////////////../../../../../../../../etc/passwd"
291291
router.GET(uriPath, httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
292292
htmlResponse := "<html><body>ok from uri</body></html>"
293-
fmt.Fprint(w, htmlResponse)
293+
_, _ = fmt.Fprint(w, htmlResponse)
294294
}))
295295
ts = httptest.NewServer(router)
296296
defer ts.Close()
@@ -314,7 +314,7 @@ func (h *customHeader) Execute() error {
314314
router := httprouter.New()
315315
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
316316
w.Header().Add("Content-Type", "application/json")
317-
fmt.Fprint(w, `{"status": "ok"}`)
317+
_, _ = fmt.Fprint(w, `{"status": "ok"}`)
318318
}))
319319
ts = httptest.NewServer(router)
320320
defer ts.Close()
@@ -341,7 +341,7 @@ func (h *outputMatchCondition) Execute() error {
341341
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
342342
w.Header().Add("Content-Type", "application/json")
343343
w.WriteHeader(200)
344-
fmt.Fprint(w, `{"status": "ok"}`)
344+
_, _ = fmt.Fprint(w, `{"status": "ok"}`)
345345
}))
346346
ts = httptest.NewServer(router)
347347
defer ts.Close()
@@ -365,7 +365,7 @@ func (h *outputFilterCondition) Execute() error {
365365
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
366366
w.Header().Add("Content-Type", "application/json")
367367
w.WriteHeader(200)
368-
fmt.Fprint(w, `{"status": "ok"}`)
368+
_, _ = fmt.Fprint(w, `{"status": "ok"}`)
369369
}))
370370
ts = httptest.NewServer(router)
371371
defer ts.Close()
@@ -390,7 +390,7 @@ func (h *outputAll) Execute() error {
390390
router.GET("/", httprouter.Handle(func(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
391391
w.Header().Add("Content-Type", "application/json")
392392
w.WriteHeader(200)
393-
fmt.Fprint(w, `{"status": "ok"}`)
393+
_, _ = fmt.Fprint(w, `{"status": "ok"}`)
394394
}))
395395
ts = httptest.NewServer(router)
396396
defer ts.Close()

cmd/integration-test/library.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ func (h *httpxLibrary) Execute() error {
2222
if err != nil {
2323
return err
2424
}
25-
defer os.RemoveAll(testFile)
25+
defer func() {
26+
_ = os.RemoveAll(testFile)
27+
}()
2628

2729
var got string
2830

@@ -64,7 +66,9 @@ func (h *httpxLibraryWithStream) Execute() error {
6466
if err != nil {
6567
return err
6668
}
67-
defer os.RemoveAll(testFile)
69+
defer func() {
70+
_ = os.RemoveAll(testFile)
71+
}()
6872

6973
var got string
7074

common/customports/customport.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,14 @@ func (c *CustomPorts) Set(value string) error {
7777
}
7878
highP, err := strconv.Atoi(potentialRange[1])
7979
if err != nil {
80-
return errors.Wrap(err, fmt.Sprintf("Could not cast last port of your port range(%s) to integer from your value: %s", potentialPort, potentialRange[1]))
80+
return errors.Wrap(err, fmt.Sprintf("could not cast last port of your port range(%s) to integer from your value: %s", potentialPort, potentialRange[1]))
8181
}
8282
if err := checkPortValue(highP); err != nil {
8383
return errors.Wrap(err, fmt.Sprintf("last port of your range(%d)", lowP))
8484
}
8585

8686
if lowP > highP {
87-
return fmt.Errorf("First value of port range should be lower than the last port from your range: [%d, %d]", lowP, highP)
87+
return fmt.Errorf("first value of port range should be lower than the last port from your range: [%d, %d]", lowP, highP)
8888
}
8989

9090
for i := lowP; i <= highP; i++ {

common/httpx/httpx.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func New(options *Options) (*HTTPX, error) {
155155

156156
if httpx.Options.Protocol == "http11" {
157157
// disable http2
158-
os.Setenv("GODEBUG", "http2client=0")
158+
_ = os.Setenv("GODEBUG", "http2client=0")
159159
transport.TLSNextProto = map[string]func(string, *tls.Conn) http.RoundTripper{}
160160
}
161161

@@ -359,7 +359,7 @@ func (h *HTTPX) getResponse(req *retryablehttp.Request, unsafeOptions UnsafeOpti
359359
func (h *HTTPX) doUnsafeWithOptions(req *retryablehttp.Request, unsafeOptions UnsafeOptions) (*http.Response, error) {
360360
method := req.Method
361361
headers := req.Header
362-
targetURL := req.URL.String()
362+
targetURL := req.String()
363363
body := req.Body
364364
options := rawhttp.DefaultOptions
365365
options.Timeout = h.Options.Timeout
@@ -435,6 +435,9 @@ func (h *HTTPX) SetCustomHeaders(r *retryablehttp.Request, headers map[string]st
435435
userAgent := useragent.PickRandom()
436436
r.Header.Set("User-Agent", userAgent.Raw) //nolint
437437
}
438+
if h.Options.AutoReferer && r.Header.Get("Referer") == "" {
439+
r.Header.Set("Referer", r.String())
440+
}
438441
}
439442

440443
func (httpx *HTTPX) setCustomCookies(req *http.Request) {
@@ -448,7 +451,7 @@ func (httpx *HTTPX) setCustomCookies(req *http.Request) {
448451
func (httpx *HTTPX) Sanitize(respStr string, trimLine, normalizeSpaces bool) string {
449452
respStr = httpx.htmlPolicy.Sanitize(respStr)
450453
if trimLine {
451-
respStr = strings.Replace(respStr, "\n", "", -1)
454+
respStr = strings.ReplaceAll(respStr, "\n", "")
452455
}
453456
if normalizeSpaces {
454457
respStr = httputilz.NormalizeSpaces(respStr)

common/httpx/option.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
// Options contains configuration options for the client
1313
type Options struct {
1414
RandomAgent bool
15+
AutoReferer bool
1516
DefaultUserAgent string
1617
Proxy string
1718
// Deprecated: use Proxy

common/pagetypeclassifier/pagetypeclassifier.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package pagetypeclassifier
33
import (
44
_ "embed"
55

6-
"github.com/jaytaylor/html2text"
6+
htmltomarkdown "github.com/JohannesKaufmann/html-to-markdown/v2"
77
"github.com/projectdiscovery/utils/ml/naive_bayes"
88
)
99

@@ -31,7 +31,7 @@ func (n *PageTypeClassifier) Classify(html string) string {
3131
}
3232

3333
func htmlToText(html string) string {
34-
text, err := html2text.FromString(html, html2text.Options{TextOnly: true})
34+
text, err := htmltomarkdown.ConvertString(html)
3535
if err != nil {
3636
panic(err)
3737
}

0 commit comments

Comments
 (0)