From b60b82689f760fc7e6bfaa6de1d2c9cd6f365d64 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Aug 2025 00:05:10 +0000 Subject: [PATCH 1/4] chore(deps): bump github.com/projectdiscovery/utils Bumps [github.com/projectdiscovery/utils](https://github.com/projectdiscovery/utils) from 0.4.20 to 0.4.23. - [Release notes](https://github.com/projectdiscovery/utils/releases) - [Changelog](https://github.com/projectdiscovery/utils/blob/main/CHANGELOG.md) - [Commits](https://github.com/projectdiscovery/utils/compare/v0.4.20...v0.4.23) --- updated-dependencies: - dependency-name: github.com/projectdiscovery/utils dependency-version: 0.4.23 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 6 ++++-- go.sum | 19 ++++++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index dde19d8..243c843 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,14 @@ module github.com/edoardottt/cariddi -go 1.23.0 +go 1.24.0 require ( github.com/fatih/color v1.18.0 github.com/gocolly/colly/v2 v2.2.0 ) +require golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 // indirect + require ( github.com/PuerkitoBio/goquery v1.10.3 // indirect github.com/andybalholm/cascadia v1.3.3 // indirect @@ -27,7 +29,7 @@ require ( github.com/nlnwa/whatwg-url v0.6.2 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/projectdiscovery/blackrock v0.0.1 // indirect - github.com/projectdiscovery/utils v0.4.20 + github.com/projectdiscovery/utils v0.4.23 github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d // indirect github.com/temoto/robotstxt v1.1.2 // indirect golang.org/x/net v0.39.0 // indirect diff --git a/go.sum b/go.sum index caf89ae..378132b 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/bits-and-blooms/bitset v1.20.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6 github.com/bits-and-blooms/bitset v1.22.0 h1:Tquv9S8+SGaS3EhyA+up3FXzmkhxPGjQQCkcs2uw7w4= github.com/bits-and-blooms/bitset v1.22.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= @@ -49,21 +49,24 @@ github.com/nlnwa/whatwg-url v0.6.2 h1:jU61lU2ig4LANydbEJmA2nPrtCGiKdtgT0rmMd2VZ/ github.com/nlnwa/whatwg-url v0.6.2/go.mod h1:x0FPXJzzOEieQtsBT/AKvbiBbQ46YlL6Xa7m02M1ECk= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/projectdiscovery/blackrock v0.0.1 h1:lHQqhaaEFjgf5WkuItbpeCZv2DUIE45k0VbGJyft6LQ= github.com/projectdiscovery/blackrock v0.0.1/go.mod h1:ANUtjDfaVrqB453bzToU+YB4cUbvBRpLvEwoWIwlTss= -github.com/projectdiscovery/utils v0.4.20 h1:7Fmjb+4YZJSzn7bL21sjF3wAR53eSi7VdAfDkDBUUwY= -github.com/projectdiscovery/utils v0.4.20/go.mod h1:RnC23+hI8j4drZFHQpMX92hV9++9d/yBeNr1pzcbF7Y= +github.com/projectdiscovery/utils v0.4.23 h1:fi6AVPIh2laomWO+Yy6G8YhvM4c2fDmQ/Viio6VZgyw= +github.com/projectdiscovery/utils v0.4.23/go.mod h1:2K2ymMPnp4/Zao5QulCDJzKjxdyZPsucQm6Fyo09JlA= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA= github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/temoto/robotstxt v1.1.2 h1:W2pOjSJ6SWvldyEuiFXNxz3xZ8aiWX5LbfDiOFd7Fxg= github.com/temoto/robotstxt v1.1.2/go.mod h1:+1AmkuG3IYkh1kv0d2qEB9Le88ehNO0zwOr3ujewlOo= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= +go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= @@ -71,6 +74,8 @@ golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDf golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8 h1:yqrTHse8TCMW1M1ZCP+VAR/l0kKxwaAIqN/il7x4voA= +golang.org/x/exp v0.0.0-20250106191152-7588d65b2ba8/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= From 1defae669f4c83eea6fe24b1e213c789cf82ad89 Mon Sep 17 00:00:00 2001 From: edoardottt Date: Wed, 20 Aug 2025 09:36:22 +0200 Subject: [PATCH 2/4] go1.24, golangci-lint v2.2.0 + updated config --- .github/workflows/go.yml | 6 ++--- .github/workflows/golangci-lint.yml | 10 +++---- .github/workflows/release-binary.yml | 8 +++--- .github/workflows/release-test.yml | 12 +++++---- .golangci.yml | 39 +++++++++++++--------------- go.mod | 2 +- internal/file/file.go | 2 +- internal/slice/slice.go | 6 ++++- pkg/crawler/colly.go | 7 +++-- pkg/crawler/scan.go | 10 +++++++ pkg/crawler/useragents.go | 6 ++++- pkg/input/check.go | 2 +- pkg/input/input.go | 8 ++++-- pkg/output/html.go | 2 -- pkg/output/output.go | 1 - pkg/output/responses.go | 2 +- 16 files changed, 70 insertions(+), 53 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 74202df..bdef80d 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,12 +11,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v5 with: - go-version: 1.23 + go-version: 1.24 - name: Build run: go build -v ./... diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 7c86415..15ccb5a 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -16,15 +16,15 @@ jobs: name: lint runs-on: ubuntu-latest steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v5 with: - go-version: 1.23 - - uses: actions/checkout@v3 + go-version: 1.24 + - uses: actions/checkout@v4 - name: golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v8 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.61.0 + version: v2.2.0 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/.github/workflows/release-binary.yml b/.github/workflows/release-binary.yml index 66cf1df..bc483ba 100644 --- a/.github/workflows/release-binary.yml +++ b/.github/workflows/release-binary.yml @@ -11,18 +11,18 @@ jobs: runs-on: ubuntu-latest steps: - name: "Check out code" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: "Set up Go" - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: 1.23.x + go-version: 1.24 - name: "Create release on GitHub" timeout-minutes: 10 - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: args: "release --clean" version: latest diff --git a/.github/workflows/release-test.yml b/.github/workflows/release-test.yml index 5755a9d..e510774 100644 --- a/.github/workflows/release-test.yml +++ b/.github/workflows/release-test.yml @@ -12,17 +12,19 @@ jobs: runs-on: ubuntu-latest steps: - name: "Check out code" - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v5 with: - go-version: 1.23.x + go-version: 1.24 - name: release test - uses: goreleaser/goreleaser-action@v4 + uses: goreleaser/goreleaser-action@v6 with: args: "release --clean --snapshot" - version: latest \ No newline at end of file + version: latest + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 37d3766..3a92f45 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,7 +1,6 @@ +version: "2" linters: - # Enable all available linters. - # Default: false - disable-all: true + default: none enable: - asciicheck - bodyclose @@ -20,10 +19,8 @@ linters: - goheader - gomodguard - goprintffuncname - - gosimple - govet - ineffassign - - lll - misspell - mnd - nakedret @@ -32,24 +29,24 @@ linters: - rowserrcheck - sqlclosecheck - staticcheck - - stylecheck - testpackage - - typecheck - unconvert - unparam - unused - whitespace - - wsl - -linters-settings: - wsl: - strict-append: false - enforce-err-cuddling: true - - mnd: - # Values always ignored: "1", "1.0", "0" and "0.0" - # Default: [] - ignored-numbers: - - '2' - ignored-files: - - 'crawler/useragents.go' + - wsl_v5 + exclusions: + generated: lax + presets: + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ \ No newline at end of file diff --git a/go.mod b/go.mod index dde19d8..2b04ae9 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/edoardottt/cariddi -go 1.23.0 +go 1.24.0 require ( github.com/fatih/color v1.18.0 diff --git a/internal/file/file.go b/internal/file/file.go index f054761..52abf2a 100644 --- a/internal/file/file.go +++ b/internal/file/file.go @@ -192,8 +192,8 @@ func ReadHTTPRequestFromFile(inputFile string) (*http.Request, error) { defer f.Close() buf := bufio.NewReader(f) - req, err := http.ReadRequest(buf) + req, err := http.ReadRequest(buf) if err != nil { fmt.Println("Cannot read request from input file.") return req, err diff --git a/internal/slice/slice.go b/internal/slice/slice.go index 82b47cf..d631f9b 100644 --- a/internal/slice/slice.go +++ b/internal/slice/slice.go @@ -33,6 +33,10 @@ import ( "time" ) +const ( + coupleSize = 2 +) + // RemoveDuplicateValues removes duplicates from a slice // of strings. func RemoveDuplicateValues(strSlice []string) []string { @@ -86,7 +90,7 @@ func CheckCookies(input string) []*http.Cookie { for _, pair := range pairs { couple := strings.Split(pair, ":") - if len(couple) != 2 { + if len(couple) != coupleSize { continue } diff --git a/pkg/crawler/colly.go b/pkg/crawler/colly.go index a48c867..94560e3 100644 --- a/pkg/crawler/colly.go +++ b/pkg/crawler/colly.go @@ -68,8 +68,8 @@ func New(scan *Scan) *Results { if scan.Intensive { var err error - targetTemp, err = urlUtils.GetRootHost(fmt.Sprintf("%s://%s", protocolTemp, targetTemp)) + targetTemp, err = urlUtils.GetRootHost(fmt.Sprintf("%s://%s", protocolTemp, targetTemp)) if err != nil { fmt.Println(err.Error()) os.Exit(1) @@ -153,8 +153,8 @@ func New(scan *Scan) *Results { filetype := &scanner.FileType{} // Skip if no scanning is enabled - if !(scan.EndpointsFlag || scan.SecretsFlag || (1 <= scan.FileType && scan.FileType <= 7) || - scan.ErrorsFlag || scan.InfoFlag || scan.JSON) { + if !scan.EndpointsFlag && !scan.SecretsFlag && (scan.FileType < 1 || scan.FileType > 7) && + !scan.ErrorsFlag && !scan.InfoFlag && !scan.JSON { return } @@ -201,7 +201,6 @@ func New(scan *Scan) *Results { jsonOutput, err := output.GetJSONString( r, secrets, parameters, filetype, errors, infos, ) - if err == nil { fmt.Println(string(jsonOutput)) } else { diff --git a/pkg/crawler/scan.go b/pkg/crawler/scan.go index a784b34..b6d90e8 100644 --- a/pkg/crawler/scan.go +++ b/pkg/crawler/scan.go @@ -73,7 +73,9 @@ func huntSecrets(target, body string, secretsFile *[]string) []scanner.SecretMat } mu.Lock() + secrets = append(secrets, secretMatch) + mu.Unlock() } }(secret) @@ -108,7 +110,9 @@ func huntSecrets(target, body string, secretsFile *[]string) []scanner.SecretMat } mu.Lock() + secrets = append(secrets, secretMatch) + mu.Unlock() } }(re) @@ -140,6 +144,7 @@ func EndpointsMatch(target string, endpointsFile *[]string) []scanner.EndpointMa } } } + endpoints = append(endpoints, scanner.EndpointMatched{Parameters: matched, URL: target}) } else { for _, parameter := range *endpointsFile { @@ -149,6 +154,7 @@ func EndpointsMatch(target string, endpointsFile *[]string) []scanner.EndpointMa } } } + endpoints = append(endpoints, scanner.EndpointMatched{Parameters: matched, URL: target}) } @@ -203,7 +209,9 @@ func huntErrors(target, body string) []scanner.ErrorMatched { } mutex.Lock() + results = append(results, localResults...) + mutex.Unlock() }(err) } @@ -231,7 +239,9 @@ func huntInfos(target, body string) []scanner.InfoMatched { for _, match := range matches { mu.Lock() + infosSlice = append(infosSlice, scanner.InfoMatched{Info: infoItem, URL: target, Match: match[0]}) + mu.Unlock() } }(infoItem) diff --git a/pkg/crawler/useragents.go b/pkg/crawler/useragents.go index 66b2a7a..b532df9 100644 --- a/pkg/crawler/useragents.go +++ b/pkg/crawler/useragents.go @@ -35,6 +35,10 @@ import ( "time" ) +const ( + hundred = 100 +) + // genOsString generates a random OS string for a User Agent. func genOsString() string { source := rand.NewSource(time.Now().UnixNano()) @@ -151,7 +155,7 @@ func GenerateRandomUserAgent() string { source := rand.NewSource(time.Now().UnixNano()) rng := rand.New(source) - decision := rng.Intn(100) + decision := rng.Intn(hundred) var ua string if decision%2 == 0 { diff --git a/pkg/input/check.go b/pkg/input/check.go index 663fe98..2443221 100644 --- a/pkg/input/check.go +++ b/pkg/input/check.go @@ -64,7 +64,7 @@ func CheckFlags(flags Input) { } if flags.Extensions != 0 { - if !(1 <= flags.Extensions && flags.Extensions <= 7) { + if flags.Extensions < 1 || flags.Extensions > 7 { fmt.Println("The extension value must go from 1 (juicy) to 7 (not juicy).") os.Exit(1) } diff --git a/pkg/input/input.go b/pkg/input/input.go index d2f718e..f576b38 100644 --- a/pkg/input/input.go +++ b/pkg/input/input.go @@ -36,6 +36,10 @@ import ( pdutils "github.com/projectdiscovery/utils/file" ) +const ( + coupleSize = 2 +) + // ScanTargets return the array of elements // taken as input on stdin. func ScanTargets() []string { @@ -50,7 +54,7 @@ func ScanTargets() []string { sc := bufio.NewScanner(os.Stdin) for sc.Scan() { domain := strings.ToLower(sc.Text()) - if len(domain) > 2 { + if len(domain) > coupleSize { result = append(result, domain) } } @@ -74,7 +78,7 @@ func GetHeaders(input string) map[string]string { for _, header := range headers { var parts []string if strings.Contains(header, ":") { - parts = strings.SplitN(header, ":", 2) + parts = strings.SplitN(header, ":", coupleSize) } else { continue } diff --git a/pkg/output/html.go b/pkg/output/html.go index 0434ef9..da2b51e 100644 --- a/pkg/output/html.go +++ b/pkg/output/html.go @@ -37,7 +37,6 @@ import ( ) const ( - //nolint:all HTMLBanner = ` @@ -97,7 +96,6 @@ const (
` - //nolint:all HTMLBannerFooter = `