High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
scripts: add run-gosec.sh for local security scanning
Mariob91701fc0c85
diff --git a/scripts/README.md b/scripts/README.mdindex c07dd1ba..3772b36d 100644--- a/scripts/README.md+++ b/scripts/README.md@@ -1,76 +1,31 @@-# Pinchtab Scripts+# Scripts-## Auto-Start Setup+Development and CI helper scripts.-### Quick Install+## Security Scanning-```bash-./scripts/install-autostart.sh-```--This will:-- Build and install pinchtab to `/usr/local/bin`-- Configure auto-start on boot-- Start the service immediately--### macOS (launchd)--The installer creates a LaunchAgent that:-- Runs pinchtab on login-- Restarts automatically if it crashes-- Logs to `/tmp/pinchtab.*.log`--Manual control:-```bash-# Start/stop-launchctl start com.pinchtab.bridge-launchctl stop com.pinchtab.bridge--# Check status-launchctl list | grep pinchtab--# View logs-tail -f /tmp/pinchtab.*.log-```--### Linux (systemd)+### `run-gosec.sh`-The installer creates a systemd user service that:-- Runs pinchtab on boot-- Restarts automatically if it crashes-- Logs to systemd journal+Run the gosec security scanner locally with the same configuration as CI.-Manual control:+**Usage:**```bash-# Start/stop-sudo systemctl start pinchtab@$USER-sudo systemctl stop pinchtab@$USER--# Check status-sudo systemctl status pinchtab@$USER--# View logs-sudo journalctl -u pinchtab@$USER -f+./scripts/run-gosec.sh```-### Uninstall--```bash-./scripts/uninstall-autostart.sh-```--### Custom Configuration--Edit environment variables in:-- **macOS**: `~/Library/LaunchAgents/com.pinchtab.bridge.plist`-- **Linux**: `/etc/systemd/system/[email protected]`+**What it checks:**+- G112 (Slowloris vulnerability)+- G204 (Command injection)-Common environment variables:-- `BRIDGE_PORT` - HTTP port (default: 9867)-- `BRIDGE_TOKEN` - Auth token (optional)-- `BRIDGE_HEADLESS` - Run Chrome headless (default: true)-- `BRIDGE_PROFILE` - Chrome profile directory+**Notes:**+- First run will install gosec to `~/go/bin/gosec`+- Scan takes 1-2 minutes (same as CI)+- Results saved to `gosec-results.json`+- Exits with code 1 if critical issues found (same as CI)-## Other Scripts+**CI behavior:**+- Only runs when Go files (`.go`, `go.mod`, `go.sum`) change+- Skipped when only docs/workflows change (path filtering)+- Same exclusions as local scan-- `check.sh` - Run all pre-push checks (format, vet, build, test)\ No newline at end of file+**Tip:** Run this before pushing to catch security issues early!diff --git a/scripts/run-gosec.sh b/scripts/run-gosec.shnew file mode 100755index 00000000..4648d048--- /dev/null+++ b/scripts/run-gosec.sh@@ -0,0 +1,52 @@+#!/bin/bash+# Run gosec security scan locally with the same config as CI+set -e++# Ensure ~/go/bin is in PATH+export PATH="$HOME/go/bin:$PATH"++# Check if gosec is installed+if ! command -v gosec &> /dev/null; then+ echo "Installing gosec..."+ go install github.com/securego/gosec/v2/cmd/gosec@latest+fi++echo "Running gosec (this may take 1-2 minutes)..."+echo ""++# Run gosec with the same config as CI+# Note: This scans all Go code, same as the CI does+gosec -exclude=G301,G302,G304,G306,G404,G107,G115,G703,G704,G705,G706 \+ -fmt=json \+ -out=gosec-results.json \+ ./... || true++# Check for critical findings (same as CI)+ISSUES=$(cat gosec-results.json | jq '[.Issues[] | select(.rule_id == "G112" or .rule_id == "G204")] | length')++echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+echo "Security Scan Results"+echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"+cat gosec-results.json | jq -r '.Stats'+echo ""+echo "Critical issues (G112, G204): $ISSUES"++if [ "$ISSUES" -gt 0 ]; then+ echo ""+ echo "❌ CRITICAL ISSUES FOUND (will fail CI):"+ cat gosec-results.json | jq -r '.Issues[] | select(.rule_id == "G112" or .rule_id == "G204")'+ exit 1+else+ echo "✅ No critical issues (CI will pass)"++ TOTAL=$(cat gosec-results.json | jq '.Stats.found')+ if [ "$TOTAL" -gt 0 ]; then+ echo ""+ echo "ℹ️ Other issues found (excluded from CI):"+ cat gosec-results.json | jq -r '.Issues[0:5] | .[] | " \(.severity): \(.rule_id) at \(.file):\(.line)"'+ echo ""+ echo "Full report: gosec-results.json"+ fi+fi++echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"