Skip to content

Commit e78e511

Browse files
author
Massimiliano Giovagnoli
committed
initial commit
Signed-off-by: Massimiliano Giovagnoli <me@maxgio.it>
0 parents  commit e78e511

File tree

19 files changed

+1269
-0
lines changed

19 files changed

+1269
-0
lines changed

.github/workflows/integration.yaml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Integration
2+
3+
on:
4+
push:
5+
branches: [ "*" ]
6+
pull_request:
7+
branches: [ "*" ]
8+
9+
jobs:
10+
golangci:
11+
name: lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Run golangci-lint
16+
uses: golangci/golangci-lint-action@v3.2.0
17+
with:
18+
version: v1.50.0
19+
only-new-issues: false
20+
args: --config .golangci.yml --timeout=5m

.github/workflows/release.yaml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
permissions:
9+
contents: write # needed to write releases
10+
id-token: write # needed for keyless signing
11+
packages: write # needed for ghcr access
12+
13+
jobs:
14+
goreleaser:
15+
runs-on: ubuntu-22.04
16+
steps:
17+
18+
- name: Checkout
19+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b #v3.0.2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Fetch
24+
run: git fetch --prune --force --tags
25+
26+
- name: Setup Go
27+
uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a #v3.2.1
28+
with:
29+
go-version: '1.20'
30+
31+
- uses: sigstore/cosign-installer@c3667d99424e7e6047999fb6246c0da843953c65 #v3.0.1
32+
33+
- uses: anchore/sbom-action/download-syft@448520c4f19577ffce70a8317e619089054687e3 #v0.13.4
34+
35+
- uses: docker/login-action@v2
36+
with:
37+
registry: ghcr.io
38+
username: ${{ github.repository_owner }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
40+
41+
- name: Publish release
42+
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b #4.2.0
43+
with:
44+
version: latest
45+
args: release --clean
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
.*.swp
3+
/wfind

.golangci.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
linters-settings:
2+
govet:
3+
check-shadowing: true
4+
maligned:
5+
suggest-new: true
6+
goconst:
7+
min-len: 2
8+
min-occurrences: 3
9+
gci:
10+
sections:
11+
- standard # Captures all standard packages if they do not match another section.
12+
- default # Contains all imports that could not be matched to another section type.
13+
- prefix(github.com/maxgio92/wfind) # Groups all imports with the specified Prefix.
14+
tagliatelle:
15+
case:
16+
rules:
17+
json: snake
18+
19+
linters:
20+
enable-all: true
21+
disable:
22+
- interfacer
23+
- godox
24+
- golint
25+
- scopelint
26+
- maligned
27+
- gochecknoglobals
28+
- gochecknoinits
29+
- exhaustivestruct
30+
- exhaustruct
31+
- ireturn
32+
- lll
33+
- nonamedreturns
34+
- wrapcheck
35+
- varnamelen
36+
37+
issues:
38+
exclude-rules:
39+
- path: /
40+
linters:
41+
- typecheck
42+
43+
run:
44+
skip-dirs: []

.goreleaser.yaml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
project_name: wfind
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- env:
9+
- CGO_ENABLED=0
10+
- GO111MODULE=on
11+
goos:
12+
- linux
13+
goarch:
14+
- amd64
15+
- arm64
16+
ldflags: |
17+
-X main.buildVersion={{ .Version }}
18+
-s
19+
-w
20+
21+
checksum:
22+
name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS'
23+
algorithm: sha256
24+
25+
changelog:
26+
sort: asc
27+
28+
# creates SBOMs of all archives and the source tarball using syft
29+
# https://goreleaser.com/customization/sbom
30+
sboms:
31+
- id: archive
32+
artifacts: archive
33+
- id: source
34+
artifacts: source
35+
36+
# signs the checksum file
37+
# all files (including the sboms) are included in the checksum, so we don't need to sign each one if we don't want to
38+
# https://goreleaser.com/customization/sign
39+
signs:
40+
- cmd: cosign
41+
env:
42+
- COSIGN_EXPERIMENTAL=1
43+
certificate: '${artifact}.pem'
44+
args:
45+
- sign-blob
46+
- '--output-certificate=${certificate}'
47+
- '--output-signature=${signature}'
48+
- '${artifact}'
49+
- "--yes" # needed on cosign 2.0.0+
50+
artifacts: all
51+
output: true
52+
53+
kos:
54+
- base_image: cgr.dev/chainguard/static
55+
repository: ghcr.io/maxgio92/wfind
56+
bare: true
57+
tags:
58+
- '{{ .Version }}'
59+
- '{{ .Major }}.{{ .Minor }}'
60+
- latest
61+
platforms:
62+
- linux/amd64
63+
- linux/arm64
64+
sbom: spdx
65+
66+
# signs our docker image
67+
# https://goreleaser.com/customization/docker_sign
68+
docker_signs:
69+
- cmd: cosign
70+
env:
71+
- COSIGN_EXPERIMENTAL=1
72+
artifacts: all
73+
output: true
74+
args:
75+
- 'sign'
76+
- '${artifact}'
77+
- "--yes" # needed on cosign 2.0.0+
78+

Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM scratch
2+
COPY wfind /wfind
3+
ENTRYPOINT ["/wfind"]
4+

Makefile

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
APP := wfind
2+
VERSION := 0.1.0
3+
4+
user := maxgio92
5+
oci_image := quay.io/$(user)/$(APP)
6+
7+
bins := docker git go gofumpt golangci-lint
8+
9+
PACKAGE_NAME := github.com/$(user)/$(APP)
10+
GOLANG_CROSS_VERSION ?= v$(shell sed -nE 's/go[[:space:]]+([[:digit:]]\.[[:digit:]]+)/\1/p' go.mod)
11+
12+
GIT_HEAD_COMMIT ?= $$($(git) rev-parse --short HEAD)
13+
GIT_TAG_COMMIT ?= $$($(git) rev-parse --short $(VERSION))
14+
GIT_MODIFIED_1 ?= $$($(git) diff $(GIT_HEAD_COMMIT) $(GIT_TAG_COMMIT) --quiet && echo "" || echo ".dev")
15+
GIT_MODIFIED_2 ?= $$($(git) diff --quiet && echo "" || echo ".dirty")
16+
GIT_MODIFIED ?= $$(echo "$(GIT_MODIFIED_1)$(GIT_MODIFIED_2)")
17+
GIT_REPO ?= $$($(git) config --get remote.origin.url)
18+
BUILD_DATE ?= $$($(git) log -1 --format="%at" | xargs -I{} date -d @{} +%Y-%m-%dT%H:%M:%S)
19+
20+
define declare_binpaths
21+
$(1) = $(shell command -v 2>/dev/null $(1))
22+
endef
23+
24+
$(foreach bin,$(bins),\
25+
$(eval $(call declare_binpaths,$(bin)))\
26+
)
27+
28+
.PHONY: doc
29+
doc:
30+
@go run doc/doc.go
31+
32+
.PHONY: build
33+
build:
34+
@$(go) build .
35+
36+
.PHONY: run
37+
run:
38+
@$(go) run .
39+
40+
.PHONY: test
41+
test:
42+
@$(go) test -v -cover -gcflags=-l ./...
43+
44+
.PHONY: lint
45+
lint: golangci-lint
46+
@$(golangci-lint) run ./...
47+
48+
.PHONY: golangci-lint
49+
golangci-lint:
50+
@$(go) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.0
51+
52+
.PHONY: gofumpt
53+
gofumpt:
54+
@$(go) install mvdan.cc/gofumpt@v0.3.1
55+
56+
.PHONY: oci/build
57+
oci/build: test
58+
@$(docker) build . -t $(oci_image):$(VERSION) -f Dockerfile \
59+
--build-arg GIT_HEAD_COMMIT=$(GIT_HEAD_COMMIT) \
60+
--build-arg GIT_TAG_COMMIT=$(GIT_TAG_COMMIT) \
61+
--build-arg GIT_MODIFIED=$(GIT_MODIFIED) \
62+
--build-arg GIT_REPO=$(GIT_REPO) \
63+
--build-arg GIT_LAST_TAG=$(VERSION) \
64+
--build-arg BUILD_DATE=$(BUILD_DATE)
65+
66+
.PHONY: oci/push
67+
oci/push: oci/build
68+
@$(docker) push $(oci_image):$(VERSION)
69+
70+
.PHONY: clean
71+
clean:
72+
@rm -f $(APP)
73+
74+
.PHONY: help
75+
help: list
76+
77+
.PHONY: list
78+
list:
79+
@LC_ALL=C $(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
80+

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# wfind: like find but for web sites
2+
3+
`wfind` (world wide web find) search for files in a web site directory hierarchy over HTTP and HTTPS, through HTML references.
4+
5+
The tool is inspired by GNU `find(1)` and `wget(1)`.
6+
7+
### Usage
8+
9+
```
10+
wfind URL [flags]
11+
```
12+
13+
#### Options
14+
15+
```
16+
-h, --help help for wfind
17+
-n, --name string Base of file name (the path with the leading directories removed) pattern.
18+
-r, --recursive Whether to examine entries recursing into directories. Disable to behave like GNU find -maxdepth=0 option. (default true)
19+
-t, --type string The file type
20+
-v, --verbose Enable verbosity to log all visited HTTP(s) files
21+
```
22+
23+
### In action
24+
25+
```shell
26+
$ wfind https://mirrors.edge.kernel.org/debian/dists/ -t f -n Release
27+
https://mirrors.edge.kernel.org/debian/dists/bullseye/Release
28+
https://mirrors.edge.kernel.org/debian/dists/buster/Release
29+
https://mirrors.edge.kernel.org/debian/dists/sid/Release
30+
https://mirrors.edge.kernel.org/debian/dists/stretch/Release
31+
...
32+
```

0 commit comments

Comments
 (0)