Overview
Base Audit Bot includes a webhook server that receives GitHub push notifications. When monitored repositories are updated, the bot automatically:- Posts tweets about repository updates
- Detects Solidity file changes
- Triggers re-audits for smart contract modifications
- Updates the database with the latest commit information
How Webhooks Work
The webhook server runs on port 5000 (configurable) and exposes two endpoints:/health: Health check endpoint/webhook/github: GitHub webhook receiver (viawebhook.py:40)
- Event payload containing commit information
- HMAC-SHA256 signature for verification
- Event type header
Prerequisites
Bot deployed and running
The webhook server starts automatically when the bot runs.Expected response:
Public URL or tunnel
GitHub needs to reach your webhook endpoint. Options:
- Production: Deploy to a server with a public IP/domain
- Testing: Use ngrok or similar tunnel service
- Cloud: Deploy to cloud platform with automatic URLs
Setting Up Webhooks
Step 1: Expose Your Webhook Endpoint
- Production (Nginx)
- Testing (ngrok)
- Cloud (Docker)
Use a reverse proxy with SSL:Your webhook URL:
https://bot.yourdomain.com/webhook/githubStep 2: Configure GitHub Webhook
Select events
Choose which events to receive:
Recommended: Just the push event
Recommended: Just the push event
Select “Just the push event”This triggers when:
- Commits are pushed
- Tags are pushed
- Branches are updated
Advanced: Let me select individual events
Advanced: Let me select individual events
If you want more control, select individual events:
- ✅ Pushes - Repository updates
- ✅ Pull requests - (Future support)
- ✅ Releases - (Future support)
Step 3: Verify Webhook
Check delivery status
In GitHub webhook settings, click on the webhook you just created.Go to “Recent Deliveries” tab.You should see a
ping event with:- ✅ Green checkmark
- HTTP 200 response
- Response body:
{"message": "pong"}
Webhook Events
The bot handles two types of events:Ping Event
Sent by GitHub to verify webhook configuration (viawebhook.py:92).
Bot response: Returns {"message": "pong"} with HTTP 200.
Push Event
Sent when commits are pushed to the repository (viawebhook.py:88).
Bot actions:
- Extracts repository and commit information
- Checks if any Solidity files (
.sol) were modified (viawebhook.py:120) - Calls
on_pushcallback to tweet about the update (viawebhook.py:148) - If Solidity files changed, calls
on_solidity_changeto trigger re-audit (viawebhook.py:155) - Updates database with latest commit SHA (via
webhook.py:228)