|
| 1 | +# Default recipe to display help |
| 2 | +default: |
| 3 | + @just --list |
| 4 | + |
| 5 | +# List of available commands |
| 6 | +alias help := default |
| 7 | + |
| 8 | +# Build the dalfox binary |
| 9 | +build: |
| 10 | + @echo "Building dalfox binary..." |
| 11 | + go build -o dalfox . |
| 12 | + |
| 13 | +# Run go unit tests |
| 14 | +test: |
| 15 | + @echo "Running Go unit tests..." |
| 16 | + go test ./... |
| 17 | + |
| 18 | +# Run linter and fix issues |
| 19 | +fix: |
| 20 | + @echo "Formatting code..." |
| 21 | + go fmt ./... |
| 22 | + @echo "Vetting code..." |
| 23 | + go vet ./... |
| 24 | + # Check if golangci-lint is installed and run it if available |
| 25 | + @if command -v golangci-lint > /dev/null 2>&1; then \ |
| 26 | + echo "Running golangci-lint..."; \ |
| 27 | + golangci-lint run --fix; \ |
| 28 | + else \ |
| 29 | + echo "Warning: golangci-lint not installed. Skipping linting."; \ |
| 30 | + fi |
| 31 | + |
| 32 | +# Update Go dependencies |
| 33 | +update: |
| 34 | + @echo "Updating Go modules..." |
| 35 | + go get -u ./... |
| 36 | + go mod tidy |
| 37 | + |
| 38 | +# Clean build artifacts |
| 39 | +clean: |
| 40 | + @echo "Cleaning build artifacts..." |
| 41 | + rm -f dalfox |
| 42 | + rm -rf vendor |
| 43 | + go clean |
| 44 | + |
| 45 | +# Set up the test environment for functional tests |
| 46 | +test-functional-setup: |
| 47 | + @echo "Setting up functional test environment..." |
| 48 | + go mod vendor |
| 49 | + go build -o dalfox . |
| 50 | + |
| 51 | +# Run the functional tests (requires RSpec) |
| 52 | +test-functional: test-functional-setup |
| 53 | + @echo "Running functional tests..." |
| 54 | + @if command -v bundle > /dev/null 2>&1; then \ |
| 55 | + bundle exec rspec spec/functional_tests/**/*_spec.rb; \ |
| 56 | + else \ |
| 57 | + echo "Error: Ruby bundler is not installed. Please install Ruby and Bundler first."; \ |
| 58 | + exit 1; \ |
| 59 | + fi |
| 60 | + |
| 61 | +# Run all tests (unit and functional) |
| 62 | +test-all: |
| 63 | + @echo "Running all tests..." |
| 64 | + @just test |
| 65 | + @just test-functional |
| 66 | + |
| 67 | +# Full development workflow: clean, update, build, test |
| 68 | +dev: clean update build test |
| 69 | + @echo "Development workflow completed successfully!" |
| 70 | + |
| 71 | +# Serve documentation site |
| 72 | +docs-serve: |
| 73 | + @echo "Starting documentation server..." |
| 74 | + cd docs || { echo "Error: Directory 'docs' not found"; exit 1; } |
| 75 | + if ! command -v bundle > /dev/null 2>&1; then \ |
| 76 | + echo "Error: Ruby bundler is not installed. Please install Ruby and Bundler first."; \ |
| 77 | + exit 1; \ |
| 78 | + fi |
| 79 | + if ! bundle check > /dev/null 2>&1; then \ |
| 80 | + echo "Error: Dependencies are not met. Please run 'just docs-install'."; \ |
| 81 | + exit 1; \ |
| 82 | + fi |
| 83 | + bundle exec jekyll s |
| 84 | + |
| 85 | +# Install documentation site dependencies |
| 86 | +docs-install: |
| 87 | + @echo "Installing documentation dependencies..." |
| 88 | + cd docs || { echo "Error: Directory 'docs' not found"; exit 1; } |
| 89 | + if ! command -v bundle > /dev/null 2>&1; then \ |
| 90 | + echo "Error: Ruby bundler is not installed. Please install Ruby and Bundler first."; \ |
| 91 | + exit 1; \ |
| 92 | + fi |
| 93 | + bundle install |
| 94 | + |
| 95 | +# Check remote assets |
| 96 | +assets-check: |
| 97 | + #!/usr/bin/env sh |
| 98 | + endpoints="xss-portswigger xss-payloadbox wl-params wl-assetnote-params" |
| 99 | + |
| 100 | + for target in $endpoints; do |
| 101 | + echo "Checking ${target}..." |
| 102 | + curl -s "https://assets.hahwul.com/${target}.json" | python3 -m json.tool || \ |
| 103 | + curl -s "https://assets.hahwul.com/${target}.json" |
| 104 | + done |
0 commit comments