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
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Binaries
bin/
secret-hunter
*.exe
*.dll
*.so
*.dylib

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

# Output of the go coverage tool
*.out
coverage.txt

# Go workspace file
go.work

# IDE
.idea/
.vscode/
*.swp
*.swo
*~

# OS
.DS_Store
Thumbs.db

# Output files
*.sarif
secrets-report.*

# Test data
test-data/

# Temporary files
/tmp/
*.tmp
49 changes: 49 additions & 0 deletions .secretignore.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Secret Hunter Ignore File
# Add patterns for files/directories to exclude from scanning

# Dependencies
node_modules/
vendor/
venv/
.venv/
__pycache__/

# Build artifacts
dist/
build/
*.min.js
*.min.css
*.bundle.js

# Lockfiles
package-lock.json
yarn.lock
Gemfile.lock
Pipfile.lock
poetry.lock
go.sum

# Logs
*.log
logs/

# IDE
.idea/
.vscode/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db

# Test data
test/
tests/
*_test.go
*_test.py
*.test

# Documentation
docs/
*.md
78 changes: 78 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.PHONY: build test clean install run help

# Build variables
BINARY_NAME=secret-hunter
BINARY_DIR=bin
GO_FILES=$(shell find . -name '*.go' -type f)
VERSION?=1.0.0

help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'

build: ## Build the binary
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BINARY_DIR)
@go build -ldflags="-X main.version=$(VERSION)" -o $(BINARY_DIR)/$(BINARY_NAME) ./cmd/secret-hunter
@echo "Build complete: $(BINARY_DIR)/$(BINARY_NAME)"

test: ## Run tests
@echo "Running tests..."
@go test -v ./...

test-coverage: ## Run tests with coverage
@echo "Running tests with coverage..."
@go test -v -coverprofile=coverage.out ./...
@go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"

clean: ## Clean build artifacts
@echo "Cleaning..."
@rm -rf $(BINARY_DIR)
@rm -f coverage.out coverage.html
@rm -f *.sarif secrets-report.*
@echo "Clean complete"

install: build ## Install the binary to GOPATH/bin
@echo "Installing $(BINARY_NAME)..."
@go install ./cmd/secret-hunter
@echo "Install complete"

run: build ## Build and run with default settings
@echo "Running $(BINARY_NAME)..."
@./$(BINARY_DIR)/$(BINARY_NAME)

run-test: build ## Run on test data
@echo "Running on test data..."
@./$(BINARY_DIR)/$(BINARY_NAME) --paths=test-data --verbose

lint: ## Run linters
@echo "Running linters..."
@which golangci-lint > /dev/null 2>&1 || (echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest" && exit 1)
@golangci-lint run ./...

fmt: ## Format code
@echo "Formatting code..."
@go fmt ./...
@gofmt -s -w .

vet: ## Run go vet
@echo "Running go vet..."
@go vet ./...

deps: ## Download dependencies
@echo "Downloading dependencies..."
@go mod download
@go mod tidy

generate-config: build ## Generate example config
@echo "Generating config..."
@./$(BINARY_DIR)/$(BINARY_NAME) --generate-config=example-config.yaml

check: fmt vet test ## Run formatting, vetting, and tests

all: clean deps check build ## Clean, get deps, run checks, and build

.DEFAULT_GOAL := help
Loading
Loading