-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 585c8ad
Showing
56 changed files
with
9,599 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "gomod" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" | ||
|
||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "weekly" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
schedule: | ||
- cron: '25 23 * * 6' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze | ||
runs-on: ubuntu-latest | ||
permissions: | ||
actions: read | ||
contents: read | ||
security-events: write | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
language: [ 'go' ] | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
|
||
- name: Autobuild | ||
uses: github/codeql-action/autobuild@v3 | ||
|
||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: golangci-lint | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
branches: | ||
- main | ||
pull_request: | ||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '1.22' | ||
cache: false | ||
- uses: actions/checkout@v4 | ||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v5 | ||
with: | ||
version: latest | ||
args: -v --disable lll --disable interfacer --disable gochecknoglobals |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
project_name: ipscout | ||
|
||
env: | ||
- GO111MODULE=on | ||
- GOPROXY=https://proxy.golang.org | ||
- CGO_ENABLED=0 | ||
|
||
before: | ||
hooks: | ||
- make clean | ||
- go mod tidy | ||
builds: | ||
- | ||
id: macos-ipscout | ||
binary: ipscout | ||
goos: | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- "-s -w -X main.version={{ .Version }} -X main.sha={{ .ShortCommit }} -X main.buildDate={{ .Date }} -X main.tag={{ .Tag }}" | ||
hooks: | ||
post: | ||
- | | ||
sh -c ' | ||
cat > /tmp/ipscout_gon_arm64.hcl << EOF | ||
source = ["./dist/macos-ipscout_darwin_arm64/ipscout"] | ||
bundle_id = "uk.co.lessknown.ipscout" | ||
apple_id { | ||
username = "[email protected]" | ||
provider = "VBZY8FBYR5" | ||
} | ||
sign { | ||
application_identity = "Developer ID Application: Jonathan Hadfield (VBZY8FBYR5)" | ||
} | ||
zip { | ||
output_path = "./dist/ipscout_darwin_arm64.zip" | ||
} | ||
EOF | ||
gon -log-level=info -log-json /tmp/ipscout_gon_arm64.hcl | ||
echo $? | ||
' | ||
echo $? | ||
- | | ||
sh -c ' | ||
cat > /tmp/ipscout_gon_amd64.hcl << EOF | ||
source = ["./dist/macos-ipscout_darwin_amd64_v1/ipscout"] | ||
bundle_id = "uk.co.lessknown.ipscout" | ||
apple_id { | ||
username = "[email protected]" | ||
provider = "VBZY8FBYR5" | ||
} | ||
sign { | ||
application_identity = "Developer ID Application: Jonathan Hadfield (VBZY8FBYR5)" | ||
} | ||
zip { | ||
output_path = "./dist/ipscout_darwin_amd64_v1.zip" | ||
} | ||
EOF | ||
echo $? | ||
gon -log-level=info -log-json /tmp/ipscout_gon_amd64.hcl | ||
echo $? | ||
' | ||
- | ||
id: ipscout | ||
binary: ipscout | ||
env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- freebsd | ||
goarch: | ||
- amd64 | ||
- arm | ||
- arm64 | ||
flags: | ||
- -trimpath | ||
ldflags: | ||
- "-s -w -X main.version={{ .Version }} -X main.sha={{ .ShortCommit }} -X main.buildDate={{ .Date }} -X main.tag={{ .Tag }}" | ||
|
||
brews: | ||
- | ||
name: ipscout | ||
homepage: 'https://github.com/jonhadfield/ipscout' | ||
description: 'A command line tool useful for network administrators and security analysts to quickly identify the origin and threat of an IP address.' | ||
repository: | ||
owner: jonhadfield | ||
name: homebrew-ipscout | ||
|
||
archives: | ||
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" | ||
builds: | ||
- macos-ipscout | ||
- ipscout | ||
format: tar.gz | ||
format_overrides: | ||
- goos: windows | ||
format: zip | ||
files: | ||
- none* | ||
|
||
release: | ||
github: | ||
owner: jonhadfield | ||
name: ipscout | ||
prerelease: auto | ||
name_template: '{{ .Tag }}' | ||
extra_files: | ||
- glob: ./dist/ipscout_darwin*.zip | ||
|
||
announce: | ||
skip: true | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-devel" | ||
|
||
changelog: | ||
sort: asc | ||
filters: | ||
exclude: | ||
- README | ||
- test | ||
- ignore | ||
|
||
checksum: | ||
name_template: 'checksums.txt' | ||
# | ||
#universal_binaries: | ||
# - | ||
# id: ipscout | ||
# replace: true | ||
|
||
#notarize: | ||
# macos: | ||
# - enabled: '{{ isEnvSet "MACOS_SIGN_P12" }}' | ||
# ids: | ||
# - ipscout | ||
# sign: | ||
# certificate: "{{.Env.MACOS_SIGN_P12}}" | ||
# password: "{{.Env.MACOS_SIGN_PASSWORD}}" | ||
# notarize: | ||
# issuer_id: "{{.Env.MACOS_NOTARY_ISSUER_ID}}" | ||
# key_id: "{{.Env.MACOS_NOTARY_KEY_ID}}" | ||
# key: "{{.Env.MACOS_NOTARY_KEY}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
FROM --platform=linux/amd64 golang:1.22-bookworm AS base | ||
ARG BUILD_SHA | ||
ARG BUILD_TAG | ||
ARG BUILD_DATE | ||
WORKDIR /src | ||
|
||
COPY ./ . | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y git coreutils && \ | ||
apt-get clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
ENV GOPROXY=https://proxy.golang.org | ||
RUN --mount=type=cache,target=/go/pkg/mod \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go mod download | ||
|
||
FROM base AS builder | ||
ARG BUILD_SHA | ||
ARG BUILD_TAG | ||
ARG BUILD_DATE | ||
ENV CGO_ENABLED=0 | ||
|
||
RUN mkdir /app | ||
COPY ./ /app/ | ||
WORKDIR /app | ||
RUN echo "Building version: [$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" | ||
RUN --mount=target=. \ | ||
--mount=type=cache,target=/go/pkg/mod \ | ||
--mount=type=cache,target=/root/.cache/go-build \ | ||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X \"github.com/jonhadfield/ipscout/cmd.version=[${BUILD_TAG}-${BUILD_SHA}] ${BUILD_DATE} UTC\" -X \"github.com/jonhadfield/ipscout/cmd.semver=${BUILD_TAG}\"" -o /out/ipscout \ | ||
&& chmod +x /out/ipscout | ||
|
||
FROM --platform=linux/amd64 gcr.io/distroless/static-debian12:nonroot-amd64 | ||
LABEL maintainer="Jon Hadfield [email protected]" | ||
|
||
WORKDIR /app | ||
COPY --from=builder /out/ipscout /app/ipscout | ||
|
||
ENTRYPOINT ["/app/ipscout"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Jon Hadfield | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
SOURCE_FILES?=$$(go list ./...) | ||
TEST_PATTERN?=. | ||
TEST_OPTIONS?=-race -v | ||
|
||
setup: | ||
go get -u github.com/go-critic/go-critic/... | ||
go get -u github.com/alecthomas/gometalinter | ||
go get -u golang.org/x/tools/cmd/cover | ||
gometalinter --install | ||
|
||
clean: | ||
rm -rf ./dist | ||
|
||
# This requires credentials are set for all providers!!! | ||
test: | ||
echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test -v -timeout=600s -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && rm coverage.tmp | ||
|
||
cover: test | ||
go tool cover -html=coverage.txt | ||
|
||
fmt: | ||
goimports -w . && gofumpt -l -w . | ||
|
||
lint: | ||
golangci-lint run --disable lll --disable interfacer --disable gochecknoglobals --disable gochecknoinits --enable wsl --enable revive --enable gosec --enable unused --enable gocritic --enable gofmt --enable goimports --enable misspell --enable unparam --enable goconst --enable wrapcheck | ||
ci: lint test | ||
|
||
BUILD_TAG := $(shell git describe --tags 2>/dev/null) | ||
BUILD_SHA := $(shell git rev-parse --short HEAD) | ||
BUILD_DATE := $(shell date -u '+%Y/%m/%d:%H:%M:%S') | ||
LATEST_TAG := $(shell git describe --abbrev=0 2>/dev/null) | ||
|
||
build: | ||
CGO_ENABLED=0 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout" | ||
|
||
build-all: fmt | ||
GOOS=darwin CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_darwin_amd64" | ||
GOOS=darwin CGO_ENABLED=0 GOARCH=arm64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_darwin_arm64" | ||
GOOS=linux CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_linux_amd64" | ||
GOOS=linux CGO_ENABLED=0 GOARCH=386 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_linux_386" | ||
GOOS=linux CGO_ENABLED=0 GOARCH=arm go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_linux_arm" | ||
GOOS=linux CGO_ENABLED=0 GOARCH=arm64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_linux_arm64" | ||
GOOS=netbsd CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_netbsd_amd64" | ||
GOOS=openbsd CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_openbsd_amd64" | ||
GOOS=freebsd CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_freebsd_amd64" | ||
GOOS=windows CGO_ENABLED=0 GOARCH=amd64 go build -ldflags '-s -w -X "github.com/jonhadfield/ipscout/cmd.version=[$(BUILD_TAG)-$(BUILD_SHA)] $(BUILD_DATE) UTC" -X "github.com/jonhadfield/ipscout/cmd.semver=$(BUILD_TAG)"' -o ".local_dist/ipscout_windows_amd64.exe" | ||
|
||
critic: | ||
gocritic check ./... | ||
|
||
mac-install: build | ||
install .local_dist/ipscout /usr/local/bin/ipscout | ||
|
||
linux-install: build | ||
sudo install .local_dist/ipscout /usr/local/bin/ipscout | ||
|
||
install: build | ||
go install ./... | ||
|
||
find-updates: | ||
go list -u -m -json all | go-mod-outdated -update -direct | ||
|
||
NAME := ghcr.io/jonhadfield/ipscout | ||
TAG := $(shell git rev-parse --short HEAD) | ||
IMG := ${NAME}:${TAG} | ||
LATEST := ${NAME}:latest | ||
|
||
build-docker: | ||
docker build --platform=linux/amd64 --build-arg BUILD_TAG="$(BUILD_TAG)" --build-arg BUILD_SHA="$(BUILD_SHA)" --build-arg BUILD_DATE="$(BUILD_DATE) UTC" -t ${IMG} . | ||
docker tag ${IMG} ${LATEST} | ||
docker tag ${LATEST} ipscout:latest | ||
docker tag ${LATEST} docker.io/jonhadfield/ipscout:latest | ||
|
||
pull-image: | ||
docker pull jonhadfield/ipscout:latest | ||
|
||
scan-image: pull-image | ||
trivy image jonhadfield/ipscout:latest | ||
|
||
build-latest-docker-tag: | ||
docker build --build-arg="TAG=$(LATEST_TAG)" -f ./docker/Dockerfile -t ipscout ./docker | ||
|
||
release: | ||
goreleaser && git push --follow-tags | ||
|
||
help: | ||
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | ||
|
||
.DEFAULT_GOAL := build |
Oops, something went wrong.