Skip to content

Commit

Permalink
dependencies up (#92)
Browse files Browse the repository at this point in the history
  • Loading branch information
s0rg authored Jun 9, 2024
1 parent 78b2e50 commit 2b540f1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 33 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ on:
branches:
- master

concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
lint:
runs-on: ubuntu-latest
Expand All @@ -22,7 +26,7 @@ jobs:
with:
go-version: ^1.22
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v5
- name: goreleaser-check
uses: goreleaser/goreleaser-action@v5
with:
Expand All @@ -43,8 +47,8 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
run: make test
- name: test-coverage
if: ${{ false && github.event_name == 'push' }}
uses: paambaati/codeclimate-action@v5.0.0
if: ${{ github.event_name == 'push' }}
uses: paambaati/codeclimate-action@v6.0.0
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
with:
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ issues:
- gosec
- path: ._test\.go
linters:
- canonicalheader
- dupword
- ifshort
- cyclop
Expand Down
2 changes: 1 addition & 1 deletion cmd/crawley/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
fBrute, fNoHeads bool
fSkipSSL, fScanJS bool
fScanCSS, fScanALL bool
fSubdomains bool
fSubdomains bool
fDirsPolicy, fProxyAuth string
fRobotsPolicy, fUA string
fDelay time.Duration
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ go 1.22
require (
github.com/s0rg/compflag v1.1.0
github.com/s0rg/set v1.2.0
github.com/tdewolff/parse/v2 v2.7.12
golang.org/x/net v0.24.0
github.com/tdewolff/parse/v2 v2.7.14
golang.org/x/net v0.26.0
)
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ github.com/s0rg/compflag v1.1.0 h1:xhCUPLy+5Ue/Q9I/nIcLti2Ul6P42JYx4UvtYoDXmlQ=
github.com/s0rg/compflag v1.1.0/go.mod h1:XMntVpc3+jpmBe0s8xo4w9swH8T9ARGkMC9HFiDRoUw=
github.com/s0rg/set v1.2.0 h1:53b207YMktNQJXYei/oHuTR5oOO2e9+eieZOncYsh9g=
github.com/s0rg/set v1.2.0/go.mod h1:xz3nDbjF4nyMLvAHvmE7rigXpNrKKTsi6iANznIB1/4=
github.com/tdewolff/parse/v2 v2.7.12 h1:tgavkHc2ZDEQVKy1oWxwIyh5bP4F5fEh/JmBwPP/3LQ=
github.com/tdewolff/parse/v2 v2.7.12/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/parse/v2 v2.7.14 h1:100KJ+QAO3PpMb3uUjzEU/NpmCdbBYz6KPmCIAfWpR8=
github.com/tdewolff/parse/v2 v2.7.14/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52 h1:gAQliwn+zJrkjAHVcBEYW/RFvd2St4yYimisvozAYlA=
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w=
golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8=
golang.org/x/net v0.26.0 h1:soB7SVo0PWrY4vPW/+ay0jKDNScG2X9wFeYlXIvJsOQ=
golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE=
2 changes: 1 addition & 1 deletion internal/crawler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (c *config) String() (rv string) {
sb.WriteString(" +css")
}

if c.Subdomains{
if c.Subdomains {
sb.WriteString(" +subdomains")
}

Expand Down
42 changes: 23 additions & 19 deletions internal/crawler/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,24 +73,28 @@ func prepareFilter(tags []string) links.TokenFilter {

func canCrawl(a, b *url.URL, d int, subdomains bool) (yes bool) {
if a.Host != b.Host {
if subdomains{
domainA := strings.Split(a.Host, ".")
domainB := strings.Split(b.Host, ".")
if len(domainA) >= len(domainB){
// The base domain must be shorter than the found domain
return
}
j := len(domainB) - 1
for i := len(domainA) - 1; i >= 0 && j >= 0; i-- {
// Traverse each domain from the end, to check if their top-level domain are the same
if domainA[i] != domainB[j] {
// not the same top-level host
return
}
j--
if !subdomains {
return false
}

domainA := strings.Split(a.Host, ".")
domainB := strings.Split(b.Host, ".")

if len(domainA) >= len(domainB) {
// The base domain must be shorter than the found domain
return false
}

j := len(domainB) - 1

for i := len(domainA) - 1; i >= 0 && j >= 0; i-- {
// Traverse each domain from the end, to check if their top-level domain are the same
if domainA[i] != domainB[j] {
// not the same top-level host
return false
}
} else{
return

j--
}
}

Expand All @@ -106,11 +110,11 @@ func canCrawl(a, b *url.URL, d int, subdomains bool) (yes bool) {

depth, found := relativeDepth(apath, bpath)
if !found {
return
return false
}

if d >= 0 && depth > d {
return
return false
}

return true
Expand Down
6 changes: 3 additions & 3 deletions internal/crawler/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ func TestCanCrawl(t *testing.T) {
t.Parallel()

type args struct {
b *url.URL
u *url.URL
d int
b *url.URL
u *url.URL
d int
subdomains bool
}

Expand Down

0 comments on commit 2b540f1

Please sign in to comment.