Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsandeep committed Sep 29, 2022
0 parents commit ec3adcd
Show file tree
Hide file tree
Showing 29 changed files with 2,005 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.dockerignore
*.idea
**/.git
*.gitignore
*.sh
Makefile
LICENSE
README.md
43 changes: 43 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:

# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "Type: Maintenance"

# Maintain dependencies for go modules
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "Type: Maintenance"

# Maintain dependencies for docker
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "weekly"
target-branch: "dev"
commit-message:
prefix: "chore"
include: "scope"
labels:
- "Type: Maintenance"
21 changes: 21 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 🔨 Build Test
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
name: Test Builds
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Check out code
uses: actions/checkout@v3

- name: Build client
run: make cli
40 changes: 40 additions & 0 deletions .github/workflows/dockerhub-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 🌥 Docker Push

on:
workflow_run:
workflows: ["🎉 Release Binary"]
types:
- completed
workflow_dispatch:

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Git Checkout
uses: actions/checkout@v3

- name: Get Github tag
id: meta
run: |
echo "::set-output name=tag::$(curl --silent --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' --header 'content-type: application/json' \
"https://api.github.com/repos/projectdiscovery/asnmap/releases/latest" | jq -r .tag_name)"
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: projectdiscovery/asnmap:latest,projectdiscovery/asnmap:${{ steps.meta.outputs.tag }}
23 changes: 23 additions & 0 deletions .github/workflows/lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 🙏🏻 Lint Test
on:
push:
pull_request:
workflow_dispatch:

jobs:
lint:
name: Lint Test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: "Set up Go"
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v3.1.0
with:
version: latest
args: --timeout 5m
working-directory: .
30 changes: 30 additions & 0 deletions .github/workflows/release-binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: 🎉 Release Binary
on:
create:
tags:
- v*
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
-
name: "Check out code"
uses: actions/checkout@v3
with:
fetch-depth: 0
-
name: "Set up Go"
uses: actions/setup-go@v3
with:
go-version: 1.18
-
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
name: "Create release on GitHub"
uses: goreleaser/goreleaser-action@v3
with:
args: "release --rm-dist"
version: latest
workdir: .
21 changes: 21 additions & 0 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run Tests
on:
push:
pull_request:
workflow_dispatch:

jobs:
build:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Check out code
uses: actions/checkout@v3

- name: Run test
run: make test
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
*.idea

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
dist/
22 changes: 22 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
builds:
- binary: asnmap
id: asnmap
main: ./cmd/asnmap/
goos:
- linux
- windows
- darwin
goarch:
- amd64
- 386
- arm
- arm64

archives:
- id: tgz
format: tar.gz
replacements:
darwin: macOS
format_overrides:
- goos: windows
format: zip
28 changes: 28 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
##
##Build
##
FROM golang:1.18 AS builder

WORKDIR /asnmap

COPY go.mod go.sum cmd . ./

RUN go build -o "asnmap" ./cmd/asnmap/

#
#Deploy
#
FROM alpine:3.16.2

RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 && \
apk update && \
apk add ca-certificates wget && \
apk add ca-certificates && \
rm -rf /var/cache/apk/* && \
wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub && \
wget https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.30-r0/glibc-2.30-r0.apk && \
apk --no-cache add glibc-2.30-r0.apk

COPY --from=builder /libs/asnmap .

ENTRYPOINT [ "./asnmap" ]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 ProjectDiscovery

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.
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOMOD=$(GOCMD) mod
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean

.PHONY: cli test tidy

cli:
$(GOBUILD) -v -ldflags="-extldflags=-static" -o "asnmap" ./cmd/asnmap/
test:
$(GOCLEAN) -testcache
$(GOTEST) -v ./...
tidy:
$(GOMOD) tidy
Loading

0 comments on commit ec3adcd

Please sign in to comment.