Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .githooks/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# commit-msg — validate Conventional Commits format
set -euo pipefail

MSG_FILE="$1"
MSG=$(head -1 "$MSG_FILE")

# Pattern: type(optional-scope): description
# Allowed types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert
PATTERN='^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(.+\))?: .{1,}'

if ! echo "$MSG" | grep -qE "$PATTERN"; then
echo ""
echo "ERROR: Commit message does not follow Conventional Commits format."
echo ""
echo " Expected: <type>(<scope>): <description>"
echo ""
echo " Types: feat, fix, docs, style, refactor, perf, test, build, ci, chore, revert"
echo ""
echo " Examples:"
echo " feat(banner-grabber): add JSON output"
echo " fix(netutil): handle IPv6 correctly"
echo " ci: add arm64 build target"
echo ""
echo " Your message: $MSG"
echo ""
exit 1
fi
72 changes: 72 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/usr/bin/env bash
# pre-commit — fast checks: formatting & linting (runs in <30s)
set -euo pipefail

RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'

info() { printf "${CYAN}[hook]${NC} %s\n" "$*"; }
pass() { printf "${GREEN}[hook] ✓${NC} %s\n" "$*"; }
fail() { printf "${RED}[hook] ✗${NC} %s\n" "$*"; }

STAGED=$(git diff --cached --name-only --diff-filter=ACMR)
HAS_GO=false
HAS_RUST=false

echo "$STAGED" | grep -qE '\.(go)$' && HAS_GO=true || true
echo "$STAGED" | grep -qE '\.(rs|toml)$' && HAS_RUST=true || true
echo "$STAGED" | grep -qE '(Cargo\.toml|Cargo\.lock)' && HAS_RUST=true || true

ERRORS=0

# ─── Go ──────────────────────────────────────────────────────────
if $HAS_GO; then
info "Go: checking formatting..."
UNFORMATTED=$(gofmt -l . 2>/dev/null || true)
if [ -n "$UNFORMATTED" ]; then
fail "Go files need formatting:"
echo "$UNFORMATTED" | sed 's/^/ /'
ERRORS=$((ERRORS + 1))
else
pass "Go formatting"
fi

info "Go: running linter..."
if ! golangci-lint run ./... 2>&1; then
fail "golangci-lint"
ERRORS=$((ERRORS + 1))
else
pass "golangci-lint"
fi
fi

# ─── Rust ────────────────────────────────────────────────────────
if $HAS_RUST; then
info "Rust: checking formatting..."
if ! cargo fmt --all -- --check 2>&1; then
fail "cargo fmt"
ERRORS=$((ERRORS + 1))
else
pass "cargo fmt"
fi

info "Rust: running clippy..."
if ! cargo clippy --all-targets --all-features -- -D warnings 2>&1; then
fail "cargo clippy"
ERRORS=$((ERRORS + 1))
else
pass "cargo clippy"
fi
fi

# ─── Result ──────────────────────────────────────────────────────
if [ "$ERRORS" -gt 0 ]; then
echo ""
fail "Commit blocked — fix the $ERRORS error(s) above."
echo " Tip: run 'make lint' to reproduce locally."
exit 1
fi

pass "All pre-commit checks passed."
58 changes: 58 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env bash
# pre-push — full validation: tests + build (mirrors CI pipeline)
set -euo pipefail

RED='\033[0;31m'
GREEN='\033[0;32m'
CYAN='\033[0;36m'
NC='\033[0m'

info() { printf "${CYAN}[hook]${NC} %s\n" "$*"; }
pass() { printf "${GREEN}[hook] ✓${NC} %s\n" "$*"; }
fail() { printf "${RED}[hook] ✗${NC} %s\n" "$*"; }

ERRORS=0

# ─── Go ──────────────────────────────────────────────────────────
info "Go: running tests..."
if ! go test -race ./... 2>&1; then
fail "Go tests"
ERRORS=$((ERRORS + 1))
else
pass "Go tests"
fi

info "Go: building tools..."
if ! go build ./tools/... 2>&1; then
fail "Go build"
ERRORS=$((ERRORS + 1))
else
pass "Go build"
fi

# ─── Rust ────────────────────────────────────────────────────────
info "Rust: running tests..."
if ! cargo test --all 2>&1; then
fail "Rust tests"
ERRORS=$((ERRORS + 1))
else
pass "Rust tests"
fi

info "Rust: building..."
if ! cargo build --release 2>&1; then
fail "Rust build"
ERRORS=$((ERRORS + 1))
else
pass "Rust build"
fi

# ─── Result ──────────────────────────────────────────────────────
if [ "$ERRORS" -gt 0 ]; then
echo ""
fail "Push blocked — fix the $ERRORS error(s) above."
echo " Tip: run 'make test && make build' to reproduce locally."
exit 1
fi

pass "All pre-push checks passed."
39 changes: 39 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
name: Bug Report
about: Report a bug in one of the tools
title: "[BUG] "
labels: bug
assignees: ""
---

## Tool

<!-- Which tool is affected? e.g., banner-grabber, port-knocking-scanner -->

## Description

<!-- A clear description of the bug -->

## Steps to Reproduce

1.
2.
3.

## Expected Behavior

<!-- What should have happened -->

## Actual Behavior

<!-- What actually happened -->

## Environment

- **OS:** <!-- e.g., Ubuntu 24.04, macOS 15 -->
- **Tool version:** <!-- e.g., v0.1.0 or commit hash -->
- **Go/Python/Rust version:** <!-- e.g., go1.24, python3.12, rust1.78 -->

## Additional Context

<!-- Logs, screenshots, etc. -->
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
name: Feature Request
about: Suggest a new tool or feature
title: "[FEATURE] "
labels: enhancement
assignees: ""
---

## Summary

<!-- Brief description of the feature or new tool -->

## Motivation

<!-- Why is this needed? What problem does it solve? -->

## Proposed Solution

<!-- How would you implement it? -->

## Language

<!-- Go / Python / Rust -->

## Additional Context

<!-- References, links, related tools, etc. -->
28 changes: 28 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Description

<!-- What does this PR do? -->

## Type of Change

- [ ] New tool
- [ ] Bug fix
- [ ] Enhancement to existing tool
- [ ] Documentation
- [ ] CI/CD

## Tool(s) Affected

<!-- e.g., banner-grabber, port-knocking-scanner -->

## Checklist

- [ ] Code follows project conventions
- [ ] Tests added/updated
- [ ] Tool-specific README updated (if applicable)
- [ ] Root README tool table updated (if new tool)
- [ ] Linters pass locally (`make lint`)
- [ ] CI passes

## Screenshots / Output

<!-- If applicable, add screenshots or command output -->
93 changes: 93 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Go

on:
push:
branches: [main]
paths:
- "go.mod"
- "go.sum"
- "tools/**"
- "libs/netutil/**"
- ".github/workflows/go.yml"
- ".golangci.yml"
pull_request:
branches: [main]
paths:
- "go.mod"
- "go.sum"
- "tools/**"
- "libs/netutil/**"
- ".github/workflows/go.yml"
- ".golangci.yml"

permissions:
contents: read

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.24"

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpcap-dev

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.24"

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpcap-dev

- name: Run tests
run: go test -v -race -coverprofile=coverage.out ./...

- name: Upload coverage
uses: actions/upload-artifact@v4
with:
name: go-coverage
path: coverage.out

build:
name: Build
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: "1.24"

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libpcap-dev

- name: Build all commands
run: |
for tool in tools/*/; do
TOOL_NAME=$(basename "$tool")
echo "=== Building $TOOL_NAME ==="
CGO_ENABLED=1 go build -ldflags="-s -w" -o "bin/${TOOL_NAME}" "./${tool}"
done

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: go-binaries-linux-amd64
path: bin/
Loading
Loading